Why SITL and HITL HIL message receivers are separated


While comparing functionality of Simulator interface for SITL (Software In The Loop) and HITL (Hardware In The Loop) simulations, I’ve noticed in the simulation documentation that:

SITL build of PX4 uses SimulatorMavlink.cpp (opens new window)to handle these messages while a hardware build in HIL mode uses mavlink_receiver.cpp

And it seems like for SITL, the HIL messages are sent through TCP connection (port 4560), and with HITL it uses the serial port connection (by default: /dev/ttyACM0).


  1. Why is the Simulator ↔ SITL interface done via TCP? Any reason why it’s not done through UDP?
  2. Why does the Simulator need a dedicated SimulatorMavlink.cpp (opens new window), other than the already existing mavlink_receiver.cpp to support HIL message interactions?
  3. What would be the disadvantage to pipe in the HIL messages through a UDP port, so that it gets handled in mavlink_receiver.cpp?

Perhaps @Jaeyoung-Lim you have comment in these topics?

Because all messages need to arrive exactly once and in order for lockstep to work.

Because that’s how it was done initially, and sometimes it’s handy as simulator specific functionality can be put there:

We could probably make it work. I believe @dagar was in favor of changing this too.

1 Like