Consecutive commands in depth hold mode

We are using depth hold mode while testing using a wifi connection.

import time
from pymavlink import mavutil

mavutil.set_dialect("ardupilotmega")

autopilot = mavutil.mavlink_connection('/dev/ttyACM0')

msg = None

# wait for autopilot connection
while msg is None:
		msg = autopilot.recv_msg()

#print msg

# The values of these heartbeat fields is not really important here
# I just used the same numbers that QGC uses
# It is standard practice for any system communicating via mavlink emit the HEARTBEAT message at 1Hz! Your autopilot may not behave the way you want otherwise!
autopilot.mav.heartbeat_send(
6, # type
8, # autopilot
192, # base_mode
0, # custom_mode
4, # system_status
3  # mavlink_version
)

autopilot.mav.command_long_send(
1, # autopilot system id
1, # autopilot component id
400, # command id, ARM/DISARM
0, # confirmation
1, # arm!
0,0,0,0,0,0 # unused parameters for this command
)
print 'this is arm'

autopilot.mav.manual_control_send(1, 0, 0, -50, 0, 0)
print 'this is down'
time.sleep(2)

#autopilot.set_mode(2)
#print 'Alt HOld'
autopilot.mav.command_long_send(1,1,176,0,2,0,0,0,0,0,0)
print 'Alt HOld'

time.sleep(2)

autopilot.mav.command_long_send(
1, # autopilot system id
1, # autopilot component id
400, # command id, ARM/DISARM
0, # confirmation
0, # disarm!
0,0,0,0,0,0 # unused parameters for this command
)
print 'disarm'

#time.sleep(1)

autopilot.mav.command_long_send(
1, # autopilot system id
1, # autopilot component id
400, # command id, ARM/DISARM
0, # confirmation
1, # arm!
0,0,0,0,0,0 # unused parameters for this command
)
print 'this is arm 2'

t=8
while(t):
	autopilot.mav.manual_control_send(1, 2000, 0, 500, 0, 0)
	print 'this is forward'
	time.sleep(2)
	t=t-1

autopilot.mav.manual_control_send(1, 0, 1500, 500, 0, 0)
print 'sway'
	
autopilot.mav.command_long_send(
1, # autopilot system id
1, # autopilot component id
400, # command id, ARM/DISARM
0, # confirmation
0, # disarm!
0,0,0,0,0,0 # unused parameters for this command
)
print 'disarm'

the bot performs the depth hold mode and after giving a command the bot performs the command and gets disarmed
We cannot use more than one command after going into depth hold.
please revert as soon as possible

@vatsal_shah,

We have some examples of how to use pymavlink with the ROV, please, take a look here.

About your code, you need to connect via UDP to mavproxy, take a look in our software components to see how the mavlink communication is handle.

You need to send the HEARTBEAT message to the autopilot at 1Hz. This is a safety mechanism.

How do we send the heartbeat continuously at 1Hz through python script? so at the end, the above code works as intended.

Please help. It’s urgent.

while(True):
    send_heartbeat():
    time.sleep(1)

Or if you want to do other things:

lastHeartbeat_t = 0
while(True)
    t = time.time()
    if (t > lastHeartbeat_t + 1):
        send_heartbeat
        lastHeartbeat_t = t

    ...do other things...

Thanks a lot.

And one more thing.

using the below python script,

connection.mav.manual_control_send(1,1000,0,0,0,0,0) #forward 1000

how to run only the front motors? We do not want the back thrusters to rotate.

This is not possible, why do you want to do this?

Because one of our rear thruster’s has issues. It does not rotate at the same speed as others. And so the bot travels in a curved trajectory. And we do not have time to get the replacement. So please help.

Unplug the two motors that you do not want to spin.