HIL Simulation with Functional Motors / Actuators

Hello I see that in HIL mode the motors / actuator output got blocked. I want to unblock it and run HIL simulation with working motors / actuators, so I can see how the servo movement in real word. I try to modify some part of the source but got stuck. Please help.


I might be missing something here, but why would you use HIL if you already want to test motors?
I guess HIL is meant to test the code execution on the Hardware while the sensors are simulated.

I have to read the PWM output when running HIL for school project.

Hi @muhammad_jogja!

I’m working on a simulation project and I’m also trying to enable the motors in HIL mode.
Did you manage to make it?

@muhammad_jogja, @lui2j
Did you get PWM output and servo movement with HIL simulation?
I tried to get the servo moved in HIL simulation with x-plane, but never works.

I got it working. This is what I did:

  1. I used the latest px4 firmware (v1.11.1 - also works on current master branch)
  2. I only changed one file (state_machine_helper.cpp): Commented the line armed->lockdown = true; inside if (hil_enabled) { block
  3. I compiled, built and then uploaded this firmware in QGC v3.5.6
  4. In QGC I disabled HITL then rebooted vehicle and then selected Standard-Plane as the airframe
  5. I pressed the safety switch to check if my servos are working as per the radio control.
  6. Then, I enabled HITL, again rebooted the vehicle and selected ‘HIL-Star’ as my airframe.

Note: At this point, the servos should still be active and controlled by radio.

  1. I launched XPlane-11 and started a flight
  2. In QGC, I opened the HIL widget to connect with X-Plane 11
  3. Then, I armed the vehicle

After arming; the real servos and the X-Plane aircraft wings should both be working and you should also be able to fly the plane using the radio.

I hope this helps someone