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?
Hi @chang-M,
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.
There are some failsafes that may be relevant, but more generally the HEARTBEAT
, SYS_STATUS
, and 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 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.
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:
#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.
I checked the source code, 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.
Indeed - as I mentioned,
ALT_HOLD
mode can be controlled using RC_CHANNELS_OVERRIDE
or 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
. If you want to use it for more direct control then it can instead be commanded using MAV_CMD_DO_REPOSITION
and the like.