Turn off lockdown in HIL?

I’m running a modified version of the PX4 software on a Pixracer. The PWM outputs are set to control slow-moving flaps, rather than rotors, so safety is not really an issue here. However, if these flaps malfunction in flight, it could lead to catastrophic failure of the vehicle. I’m wondering if it’s possible to disable HIL lockdown to allow the servos to move in HIL and make testing software changes easier and safer.

I’ve tried commenting out all the lines that set “armed->lockdown = true”, but it hasn’t worked. I tried using the debug cable and sending “commander lockdown off”, but it didn’t work. I’ve also tried logging the “actuator_armed” topic, and checking the “lockdown” and “manual_lockdown” fields, but they seem to indicate lockdown is off. I have tested and confirmed that the servos work properly outside of HIL.

Any help would be greatly appreciated.

Thought I’d reply since I figured out the issue. In HIL, the simulated servo driver, pwm_out_sim, is started alongside the physical servo driver, px4fmu. This causes the device name pwm_output0 (the primary servo channel) to be registered by the simulated driver instead of the physical one. Under normal, non-HIL use, the device name pwm_output0 is occupied by the physical driver. Under HIL, the physical driver is still started, but it’s registered under pwm_output1, which means it misses all messages, including primary servo commands.

To fix this, I edited the init script (rcS) to not start pwm_out_sim in HIL. Of course, for this to work, you must also set armed->lockdown = false, or comment out lines that say armed->lockdown = true.

It’s a little irritating that this wasn’t documented - setting lockdown to false is not enough to disable lockdown, you have to disable pwm_out_sim. And the physical driver didn’t throw any warnings, messages, etc. to indicate that it in fact was not registered under the primary servo device name. It took me over a month to figure this out.

Anyway, hope this helps someone.

1 Like

Hi @zfurman!
I’m trying to enable motors in HIL mode for a simulation project. In this way, your post was very helpful.
However, the real motors still don’t work.

Do you know if there is another change to be made in the code?

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

1 Like

It works, thank you! But when I apply takeoff, the plane in the simulator does not move, the propellers just spinning in its location. I am using Gazebo with a quadcopter Pixhawk 4. Did you encounter this problem?

Brother, I also encountered the same problem and wanted to drive the real motor in HITL mode. I have a few questions to ask you. Which version of PX4 do you use? Can you tell me the specific operating steps and areas that need to be changed?