# Turn off lockdown in HIL?

**URL:** <https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600>\
**Category:** PX4 Autopilot\
**Created:** [October 5, 2017, 4:08am UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600 "2017-10-05T04:08:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zfurman](https://discuss.px4.io/letter_avatar_proxy/v4/letter/z/6bbea6/32.png) [@zfurman](https://discuss.px4.io/u/zfurman)\
**Post date:** [October 5, 2017, 4:08am UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/1 "2017-10-05T04:08:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zfurman](https://discuss.px4.io/letter_avatar_proxy/v4/letter/z/6bbea6/32.png) [@zfurman](https://discuss.px4.io/u/zfurman)\
**Post date:** [November 26, 2017, 11:36pm UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/2 "2017-11-26T23:36:36Z")

</div>

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)](https://github.com/zfurman56/Firmware/commit/92018bbd4742a1138646d6a0ff18f3d20ecaf031) 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](https://github.com/zfurman56/Firmware/commit/ded1b109570a9d725b795bdc92066fef213188e1) 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.

---

<div class="post-metadata">

**Author:** ![lui2j](https://discuss.px4.io/letter_avatar_proxy/v4/letter/l/48db29/32.png) [@lui2j](https://discuss.px4.io/u/lui2j)\
**Post date:** [June 8, 2018, 1:57pm UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/3 "2018-06-08T13:57:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![HashimAifi](https://discuss.px4.io/user_avatar/discuss.px4.io/hashimaifi/32/7332_2.png) [@HashimAifi](https://discuss.px4.io/u/HashimAifi)\
**Post date:** [November 5, 2020, 10:41am UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/4 "2020-11-05T10:41:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Heba](https://discuss.px4.io/letter_avatar_proxy/v4/letter/h/da6949/32.png) [@Heba](https://discuss.px4.io/u/Heba)\
**Post date:** [September 3, 2021, 3:24pm UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/5 "2021-09-03T15:24:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![DaShen96](https://discuss.px4.io/user_avatar/discuss.px4.io/dashen96/32/13292_2.png) [@DaShen96](https://discuss.px4.io/u/DaShen96)\
**Post date:** [October 12, 2023, 9:14am UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/6 "2023-10-12T09:14:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![seemsgroup](https://discuss.px4.io/letter_avatar_proxy/v4/letter/s/ac91a4/32.png) [@seemsgroup](https://discuss.px4.io/u/seemsgroup)\
**Post date:** [March 13, 2024, 7:47am UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/7 "2024-03-13T07:47:14Z")

</div>

Hi, I’m pretty sure OP was using v1.11 release for the steps above. There’s a file called state\_machine\_helper.cpp in it with the line armed-\>lockdown = true that can be commented out.

---

<div class="post-metadata">

**Author:** ![susususupernova](https://discuss.px4.io/user_avatar/discuss.px4.io/susususupernova/32/16580_2.png) [@susususupernova](https://discuss.px4.io/u/susususupernova)\
**Post date:** [June 9, 2024, 11:34am UTC](https://discuss.px4.io/t/turn-off-lockdown-in-hil/4600/8 "2024-06-09T11:34:01Z")

</div>

Hello! I think your post is very helpful!  
However, the link about how to edit the init script is 404 now, so I cannot solve the problem.  
Do you still remember how to edit the init script? Thank you a lot!
