필터 지우기
필터 지우기

Obtain msg from Pixhawk

조회 수: 7 (최근 30일)
Xiaowei Xing
Xiaowei Xing 2023년 11월 17일
댓글: Xiaowei Xing 2023년 11월 28일
I want to read messages from Pixhawk and send commands to Pixhawk with Simulink or MATLAB.
Some information: Pixhawk 4, MATLAB r2023b, Holybro telemetry radio.
I attach a telemetry radio on a local computer and attach a telemetry radio on Pixhawk. Here are some screenshots of my simulink model. In this case, I want to read attitude measurements. However, it shows that the values of roll, pitch and yaw are always zero, even if I rotate Pixhawk.
I also tried to play with ports with MATLAB. But I have not figured out how to receive a complete frame of msg. Here are some screenshot of my script and results. I think the length of "data" in the workspace should be 280 at most according to https://mavlink.io/en/guide/serialization.html (maybe I did not understand that correctly).
Thanks in advance.

채택된 답변

Ankur Bose
Ankur Bose 2023년 11월 27일
In you MATLAB script, add the below two lines of code
dialect = mavlinkdialect("common.xml");
msg = deserializemsg(dialect,buffer);
This will decode the received data in the base workspace in the variable "msg".
You can do same thing in Simulink. Your model looks correct. Remove the header and terminator values from the Serial Receive block.
  댓글 수: 1
Xiaowei Xing
Xiaowei Xing 2023년 11월 28일
Thanks Mr. Bose. I tried with MALTAB script and it worked ; )

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by