# PX4 disarmed automatically

**URL:** <https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126>\
**Category:** ArduSub\
**Tags:** ardusub, pymavlink\
**Created:** [April 18, 2025, 7:37am UTC](https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126 "2025-04-18T07:37:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chang-M](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@chang-M](https://discuss.bluerobotics.com/u/chang-M)\
**Post date:** [April 18, 2025, 7:37am UTC](https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126/1 "2025-04-18T07:37:55Z")

</div>

Hi! our team want to develop a program to let the rov reach a target depth, when i use pymavlink `manual_control_send` to left rov reach a target depth, and then change to DEPTH\_HOLD mode after `time.sleep(0.1)`, the PX4 seems disarmed automatically. Is it because the machine has entered a certain protection state? How can I make it not disarmed automatically?

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [April 18, 2025, 12:01pm UTC](https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126/2 "2025-04-18T12:01:12Z")

</div>

Hi @chang-M,

> [@chang-M](#):
>
> the PX4 seems disarmed automatically.

> [@Lumen R2 brightness control with pixhawk](https://discuss.bluerobotics.com/t/lumen-r2-brightness-control-with-pixhawk/10460/2):
>
> PX4 is an autopilot flight stack (software), that can run on a flight controller board. We (Blue Robotics) develop and support [ArduSub](https://www.ardusub.com/), which is a separate and unrelated autopilot software tailored to underwater vehicles, that can run on some of the same flight controller boards (like the Pixhawk 1 and the Pixhawk 4). If you’re wanting to use the PX4 firmware then we won’t be able to help you - you’ll need to ask your question on the [PX4 forum](https://discuss.px4.io/).

Operating a vehicle generally involves more than just commanding it to move, and you haven’t provided code or described the steps you’re taking to set up the connection to the autopilot.

> [@chang-M](#):
>
> Is it because the machine has entered a certain protection state?

There are [some failsafes](https://discuss.bluerobotics.com/t/t200-python-manual-control-error/11479/2) that may be relevant, but more generally the [`HEARTBEAT`](https://mavlink.io/en/messages/common.html#HEARTBEAT), [`SYS_STATUS`](https://mavlink.io/en/messages/common.html#SYS_STATUS), and [`STATUS_TEXT`](https://mavlink.io/en/messages/common.html#STATUS_TEXT) messages may help you to determine if/when something is going wrong, and what is causing it.

Have you tried controlling the vehicle with a standard control station software like Cockpit or QGroundControl, to see whether that also has issues when you try to enter depth hold mode? If they have the same issue then there might be a problem with your external pressure sensor (e.g. it may be disconnected, or damaged), which may be preventing the autopilot from estimating its depth. In that case you may wish to submit a [product problem](https://bluerobotics.com/help/?want=report) report, to get help from our support team, or to wherever you bought your depth sensor from.

If it works fine with a standard software then the issue is most likely with your code, in which case I’d recommend posting your code and describing the difference in observed behaviour from what you’re trying to get it to do.

---

<div class="post-metadata">

**Author:** ![chang-M](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@chang-M](https://discuss.bluerobotics.com/u/chang-M)\
**Post date:** [April 21, 2025, 2:11am UTC](https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126/3 "2025-04-21T02:11:06Z")

</div>

Thanks for your reply!

This situation occurs in some scenarios. I want to use pymavlink to make an automatic motion program of a robot, but whenever I switch to ALT\_HOLD mode, and then send a MANUAL\_CONTROL instruction for a period of time, and then when the sending is stopped, the robot’s PX4 will automatically enter the disarm state.

The simple logic of the code is roughly like this:

```auto
#switch to ALT_HUD
mode_id = self.master.mode_mapping()['ALT_HOLD']
while not self.master.wait_heartbeat().custom_mode == mode_id:
        self.master.set_mode(mode_id)

#send MANUAL_CONTROL message for a while
second = 2
end_time = time.time()+second
        while time.time()<end_time:
            self.master.mav.manual_control_send(self.master.target_system, x, y, z, r,self.buttons)
            time.sleep(0.1)

```

Should I use other messages instead of MANUAL\_CONTROL in ALT\_HUD or GUIDED modes to guide the movement of the robot.

---

<div class="post-metadata">

**Author:** ![chang-M](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@chang-M](https://discuss.bluerobotics.com/u/chang-M)\
**Post date:** [April 21, 2025, 3:04am UTC](https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126/4 "2025-04-21T03:04:01Z")

</div>

I checked the [source code](https://github.com/ArduPilot/ardupilot/tree/Sub-4.5/ArduSub), I found that it was because the remote control signal was interrupted for a period of time and caused the machine to enter the failsafe state, which led to automatic disarm. I want to know, in addition to making a thread that sends control signals regularly, what mavlink message is generally used to guide the robot’s movement when developing automatic cruisers, especially in ALT\_HUD and GUIDED modes.

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [April 24, 2025, 5:28am UTC](https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126/5 "2025-04-24T05:28:09Z")

</div>

> [@chang-M](#):
>
> I checked the [source code](https://github.com/ArduPilot/ardupilot/tree/Sub-4.5/ArduSub), I found that it was because the remote control signal was interrupted for a period of time and caused the machine to enter the failsafe state, which led to automatic disarm.

Indeed - as I mentioned,

> [@EliotBR](#):
>
> There are [some failsafes](https://discuss.bluerobotics.com/t/t200-python-manual-control-error/11479/2)

> [@chang-M](#):
>
> what mavlink message is generally used to guide the robot’s movement when developing automatic cruisers, especially in ALT\_HUD and GUIDED modes.

`ALT_HOLD` mode can be controlled using [`RC_CHANNELS_OVERRIDE`](https://gist.github.com/ES-Alexander/ee1dd479dd728b7cef1bf936f9114e71#file-rc_override_example-py-L163) or [`MANUAL_CONTROL`](https://mavlink.io/en/messages/common.html#MANUAL_CONTROL) messages, although be aware that the altitude/depth target will get updated if you send controls as part of those commands which move the vehicle vertically.

`GUIDED` mode generally requires the vehicle to have a valid position estimate, and is most commonly used as part of autonomous missions, which include commands like [`MAV_CMD_NAV_WAYPOINT`](https://mavlink.io/en/messages/common.html#MAV_CMD_NAV_WAYPOINT). If you want to use it for more direct control then it can instead be commanded using [`MAV_CMD_DO_REPOSITION`](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_REPOSITION) and the like.

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [April 29, 2025, 6:34am UTC](https://discuss.bluerobotics.com/t/px4-disarmed-automatically/20126/6 "2025-04-29T06:34:55Z")

</div>

A post was merged into an existing topic: [GUIDED mode requirement](https://discuss.bluerobotics.com/t/guided-mode-requirement/20171/5)
