Controlling PWM Values with Python

Hi, I am controlling my ROV with a Python script for an autonomous mission. But when I tried to send manual control it fails and it only goes in one dimension. I used this page as reference:
What can be the problem with this?

Also, when I tried to set target depth/attitude as referenced here:
I am facing with this error:
DEPTH_HOLD_MODE = master.mode_mapping()[DEPTH_HOLD]
TypeError: ‘NoneType’ object is not subscriptable

The motors, which are working, are connected to single ESCs. Others are connected to a fourth motor controller.

Hi @cagan, sorry for the delay on responding to this.

Are you saying you have multiple motors connected to one ESC? From the FAQs on our T200 product page:

Are you able to control each motor individually from the Motors Setup page in QGroundControl?

I’m not sure what’s going on there - I’ll need to look more into it.

Following up on this, because BlueOS has additional MAVLink components for the camera manager and some other systems, there are multiple heartbeats. Accordingly the first heartbeat received through the MAVLink connection is not necessarily a heartbeat from the vehicle, so it’s necessary to wait until a correct one has been found. That can be done with something like the following:

from pymavlink import mavutil

... # create the connection

# wait for vehicle heartbeat before sending commands
ensure_autopilot_heartbeat = (
    f'HEARTBEAT.get_srcSystem() == {master.target_system} and '
    f'HEARTBEAT.get_srcComponent() == {mavutil.mavlink.MAV_COMP_ID_AUTOPILOT1}'
master.recv_match(type='HEARTBEAT', condition=ensure_autopilot_heartbeat, blocking=True)

... # rest of the program