UAV Toolbox Support for PX4 Autopilots – HIL_SENSOR MAVLink message data not accepted by stock PX4 flight controller
Hi everyone,
I am experiencing a strange issue creating a Simulink quadrotor simulation environment for testing the stock PX4 flight controller. I am adapting the model from this Simulink PX4 example: Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model. However, instead of running the flight controller on PX4 by creating a custom Simulink controller, I want to use the stock PX4 flight controller.
At first I tried running PX4 using just "make px4_sitl none_iris" in a fresh PX4 installation, and then running the Simulink model. This kind of works – PX4 waits for connection from a simulator, and then connects when the plant model is run. However, it immediately experiences 14 pre-flight failures, which means it does not arm. It does not display all of these errors, but they seem to be related to the sensors + others not listed.
I found some errors in the original simulink-based plant model (the heartbeat signal is broadcasting that it is a submarine? But also does not seem to be necessary in the first place) as well as some incorrect units being published to MAVLink. Fixing these does not seem to help.
I found a python file that creates a dummy drone that is convincing enough for PX4 to connect to. The code is attached to this post in the dummy sim file. Running the above make command and then the sim convinces PX4 that everything is good to go and the commander arms. I created a new Simulink file that just populates HIL_GPS, HIL_SENSOR and HIL_STATE_QUATERNION with the same data from the python file (base values, random offsets, scale, etc.).
Running PX4 and connecting to this sim clears 9 of the 14 pre-flight failures. The remaining 5 are all connected to the sensor message – the flight controller claims it is receiving invalid or no data from the accelerometer, gyroscope, compass and barometer. An image of the error is attached below.
All of this information should be provided by the HIL_SENSOR message, which is fully populated in the Simulink file and sent over UDP/TCP the same way all the other MAVLink messages are being sent. Why the HIL_SENSOR data is specifically not working is beyond me. Same values in the python script seem to be fine. Also, every sensor is failing, so I doubt I have messed up one or two inputs in the Simulink bus assignment. Attahced below is an image of the HIL_SENSOR assignment. I have also attached the Simulink file (called MinimumViableModel) as well as necessary support scripts.
Any help would be appreciated! I hope I have attached everything necessary to reproduce the issue.Hi everyone,
I am experiencing a strange issue creating a Simulink quadrotor simulation environment for testing the stock PX4 flight controller. I am adapting the model from this Simulink PX4 example: Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model. However, instead of running the flight controller on PX4 by creating a custom Simulink controller, I want to use the stock PX4 flight controller.
At first I tried running PX4 using just "make px4_sitl none_iris" in a fresh PX4 installation, and then running the Simulink model. This kind of works – PX4 waits for connection from a simulator, and then connects when the plant model is run. However, it immediately experiences 14 pre-flight failures, which means it does not arm. It does not display all of these errors, but they seem to be related to the sensors + others not listed.
I found some errors in the original simulink-based plant model (the heartbeat signal is broadcasting that it is a submarine? But also does not seem to be necessary in the first place) as well as some incorrect units being published to MAVLink. Fixing these does not seem to help.
I found a python file that creates a dummy drone that is convincing enough for PX4 to connect to. The code is attached to this post in the dummy sim file. Running the above make command and then the sim convinces PX4 that everything is good to go and the commander arms. I created a new Simulink file that just populates HIL_GPS, HIL_SENSOR and HIL_STATE_QUATERNION with the same data from the python file (base values, random offsets, scale, etc.).
Running PX4 and connecting to this sim clears 9 of the 14 pre-flight failures. The remaining 5 are all connected to the sensor message – the flight controller claims it is receiving invalid or no data from the accelerometer, gyroscope, compass and barometer. An image of the error is attached below.
All of this information should be provided by the HIL_SENSOR message, which is fully populated in the Simulink file and sent over UDP/TCP the same way all the other MAVLink messages are being sent. Why the HIL_SENSOR data is specifically not working is beyond me. Same values in the python script seem to be fine. Also, every sensor is failing, so I doubt I have messed up one or two inputs in the Simulink bus assignment. Attahced below is an image of the HIL_SENSOR assignment. I have also attached the Simulink file (called MinimumViableModel) as well as necessary support scripts.
Any help would be appreciated! I hope I have attached everything necessary to reproduce the issue. Hi everyone,
I am experiencing a strange issue creating a Simulink quadrotor simulation environment for testing the stock PX4 flight controller. I am adapting the model from this Simulink PX4 example: Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model. However, instead of running the flight controller on PX4 by creating a custom Simulink controller, I want to use the stock PX4 flight controller.
At first I tried running PX4 using just "make px4_sitl none_iris" in a fresh PX4 installation, and then running the Simulink model. This kind of works – PX4 waits for connection from a simulator, and then connects when the plant model is run. However, it immediately experiences 14 pre-flight failures, which means it does not arm. It does not display all of these errors, but they seem to be related to the sensors + others not listed.
I found some errors in the original simulink-based plant model (the heartbeat signal is broadcasting that it is a submarine? But also does not seem to be necessary in the first place) as well as some incorrect units being published to MAVLink. Fixing these does not seem to help.
I found a python file that creates a dummy drone that is convincing enough for PX4 to connect to. The code is attached to this post in the dummy sim file. Running the above make command and then the sim convinces PX4 that everything is good to go and the commander arms. I created a new Simulink file that just populates HIL_GPS, HIL_SENSOR and HIL_STATE_QUATERNION with the same data from the python file (base values, random offsets, scale, etc.).
Running PX4 and connecting to this sim clears 9 of the 14 pre-flight failures. The remaining 5 are all connected to the sensor message – the flight controller claims it is receiving invalid or no data from the accelerometer, gyroscope, compass and barometer. An image of the error is attached below.
All of this information should be provided by the HIL_SENSOR message, which is fully populated in the Simulink file and sent over UDP/TCP the same way all the other MAVLink messages are being sent. Why the HIL_SENSOR data is specifically not working is beyond me. Same values in the python script seem to be fine. Also, every sensor is failing, so I doubt I have messed up one or two inputs in the Simulink bus assignment. Attahced below is an image of the HIL_SENSOR assignment. I have also attached the Simulink file (called MinimumViableModel) as well as necessary support scripts.
Any help would be appreciated! I hope I have attached everything necessary to reproduce the issue. simulink, sitl, software in the loop, px4, sensor data MATLAB Answers — New Questions