read mavlink from Pixhawk in simulink UAV toolbox
15 views (last 30 days)
I would like to use the UAV toolbox Mavlink deserializer to bring in mavlink data from a Pixhawk through a serial port. I have setup my model as shown:
Not sure why but I only get sparse data from heartbeart and nothing from the other message types; it is also very slow to read in the display.
Has anyone done something like this before?
Arun Mathamkode on 10 Dec 2021
Edited: Arun Mathamkode on 10 Dec 2021
I assume you are using the Serial recieve block from ICT toolbox. Probably the trick is in choosing the right baudrate, samepletime and data size. Are you using the USB port of the Pixhawk to read data or any other telemetry serial port? The baud rate need to be configured based on the baudrate configuration of the serial port you are using. If it is USB port, I would suggest 921600, and depend on the data flow, you need to choose right the same time and data size as well. You can consider keeping a small sample time (say 10ms or 5 ms) for a data size around 100 to start with. The Simulink will be running in non-realtime, hence you can consider using the Simulink pacing option as well. Since the ICT serial block deosnot support partial serial read operation, you may need to experiment with the data size and sample time for optimal performance. One more input for better performance is to execute the MAVLink Deserializer block only when new data is available. Since the serial recieve block is configured to provide previous data when no new data is available, unnecessarily the MAVLink decoder willbe decoding the same data for every sampletime. Consider moving the decoder block into an enabled subsystem and use the Status signal from the Serial block as the trigger signal.