I’m working on a bare-bones SITL simulator that communicates with PX4.
I have read the documentation provided in the PX4 docs (Simulation | PX4 User Guide) and I have implemented a simple event loop where I periodically publish messages to PX4.
I’m currently using the MAVLink c++ library to communicate to PX4 over TCP (tcp port 4560) and I’m receiving the initial COMMAND_LONG message for HIL_ACTUATOR_CONTROLS frequency, along with a HEARTBEAT.
After this initial “handshake” sequence I periodically post the following messages (from the simulator to PX4):
but PX4 is not responding with any additional message (from the documentation I was expecting a HIL_ACTUATOR_CONTROLS message).
Is there any documentation on the correct handshake sequence and/or any message I might have forgotten?
Thanks in advance.
Not an expert, but I do know that HIL is a “special state”. I think this is enabled by setting Parameter Reference | PX4 User Guide in your airfame.
If that is done, then eventually PX4-Autopilot/mavlink_main.cpp at master · PX4/PX4-Autopilot · GitHub will be called to emit the message.
But, as I say, I don’t know for sure.
thanks for the info!
I tried changing the SYS_HITL parameter to 1 and rebooted the autopilot.
I double-checked that upon restart the parameter was kept unchanged.
Still, I am not receiving any HIL_ACTUATOR_CONTROLS.
Could this be due to invalid sensor readings? I am passing zeroed out values for most things (airspeed, ground speed, attitude, etc…).Thanks
@LeonardoC Have you checked the simulator module that your HIL module if the mavlink commands are received, and marked as valid?
I just tried sending dummy values for the HIL_SENSOR message by copying what jmavsim sends.
With those, I’m getting the HIL_ACTUATOR_CONTROLS message response!
It was a problem with the contents of my message, not the delivery.
Thanks for your help!
hi @LeonardoC , I am trying to establish such a SITL between PX4 and a Simulink implemented model, can you give tips on how to establish the TCP connection and how to exchange the mavlink messages ?
It would be great if you can post your answer for the following topic:
SIL/HIL with matlab/simulink models - PX4 Autopilot / Comms - Discussion Forum, for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink
I met the same issue, could you show me how to receive the HIL_ACTUATOR_CONTROLS?