How do I connect and read data from pixhawk 6x when using simulink/ UAVToolbox?

16 views (last 30 days)
I am trying to have a play around with simulink and the UAVToolbox but am having issues in simply connecting to the pixhawk.
During the hardware setup for PX4 in simulink, (building firmware, uploading, testing connection etc), I am unable to read accelerometer data, however the odd thing is that I AM able to build and upload the firmware. I am very confused as to why it can connect when uploading, but not when trying to read data. Additionally I dont have this problem when using things such as QGC.
As far as I am aware, the port for uploading is the same as reading (/dev/ttyACM0), regardless of this I have tried various ports and still no connection.
What do I need to do for this to connect and read from my pixhawk?
Note: I am trying to do this with pixhawk 6x as the target to be deployed in to a physical aircraft, NOT SITL or HITL, alot of the examples and tutorials cover only simulated scenarios and they are not helpful in my current situation, so please do not refer me to any of them unless it specifically refers to a connection issue like this, thank you.
System - Ubuntu 20.04
any help would be great,
thanks
  4 Comments
Owen
Owen on 7 Jan 2025
Not sure you've read my question properly then, or maybe I've not been clear! Im not asking if it is supported, I've read the documentation and I'm aware that its supported (I wouldn't even bother if it wasnt!).
My question is, how do I actually get the data from the pixhawk or rather what troubleshooting can I do (I've already read the small amount of documentation on troubleshooting with no success hence my question here), I can upload firmware during the hardware setup, but when I press the "read accelerometer data" button I get an error saying it could not access the data. That is what I am trying to find out.

Sign in to comment.

Accepted Answer

Owen
Owen on 8 Jan 2025
So I have identified the problem - nothing on the matlab or pc/system side.
The problem originates from the com port becoming "blocked" after being flashed with 1.14.0, I confirmed this after finding I could not connect to QGC, additionally I was able to get the accelerometer data after flashing unsuported firmware (a custom version of 1.15.2 that I know works).
This issue gets mentioned here with an explanation as to why it happens
Not entirely sure what the actual solution is however, but will update when I determine one. As 1.14.0 is the latest version that is supported I'll still need to find a way to get it working but for now I'll continue with my custom version and work with caution and hope it doesnt blow up :)

More Answers (1)

Ankur Bose
Ankur Bose on 15 Jan 2025
I believe you are running into a known issue where a newer version of the Pixhawk 6x board is only supported by the PX4 Firmware version 1.14.3. To workaround the issue. this is what I suggest
  1. Launch Windows subsystem for Linux (WSL) and in that navigate to your cloned directory of PX4.
  2. Run the below command in WSL
  3. git checkout v1.14.3 -f
  4. git submodule update --init --recursive
Once the above commands are completed, launch hardware setup screen from MATLAB again. In the "Validate PX4" screen, you might get a warning that the PX4 firmware version is not tested but you can ignore it for now and go ahead and finish the setup screen. After this you should be able to run and upload Simulink models

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!