Python interface for bluerov2 parameters

Hi,

I am trying to write an interface in python which displays various parameters of the ROV (tilt, flight mode, …)
I get the different messages that arrive vi pymavlink.

Here is my code:

    master = mavutil.mavlink_connection('udpin:0.0.0.0:14551')
    master.wait_heartbeat()

    while True:
        try:

            ack_msg2 = master.recv_match(type=['SERVO_OUTPUT_RAW', 'HEARTBEAT', 'VFR_HUD'], blocking=True)
            ack_msg2 = ack_msg2.to_dict()
            
            if ack_msg2['mavpackettype'] == 'SERVO_OUTPUT_RAW':
                # lumière
                print(str(int(((ack_msg2['servo9_raw']-1000)/100)-1))+"/8")
                #tilt
                print(round(((ack_msg2['servo10_raw']-1100)/(1900-1100))*100))
                
            elif ack_msg2['mavpackettype'] == 'HEARTBEAT':
                # Mode navigation
                if ack_msg2['custom_mode'] == 0:
                    mode = 'STABILIZE'
                elif ack_msg2['custom_mode'] == 2:
                    mode = 'DEPTH HOLD'
                elif ack_msg2['custom_mode'] == 19:
                    mode = 'MANUAL'
                else:
                    mode = 'UNKNOWN'
                print(mode)
                
            elif ack_msg2['mavpackettype'] == 'VFR_HUD':
                print(round(ack_msg2['alt'], 1))
                
        except:
            pass
        time.sleep(0.1)

The problem is that updating a parameter on the interface (flight mode for example) sometimes takes several seconds because you have to wait for mavlink to send the corresponding message.
In QGC, the interface update is immediate.
How to remedy this?

Another question: I can’t find which mavlink message to retrieve to have the motor gain parameters, and opening of the gripper, and camera status (video on / off)

Regards,
Nico

You have a 0.1s sleep and print calls that take some time of the IO, try to remove both calls.

It’s not possible to access gain values from the joystick input, if you want to change it grammatically, try to use JS_THR_GAIN parameter or P gain parameters if you are using one of the stabilization flight modes.

For the gripper, is not possible, the PWM output gives an velocity reference for the gripper and not a position.
Check the gripper manual here: “Provide a servo PWM pulse at 1500 μs for no movement. Provide a servo PWM pulse greater than 1530 μs to open gripper. Provide a servo PWM pulse less than 1470 μs to close gripper.”

For the video, we are working on it, probably 0.0.22 version of companion. You can check more about it here.

Hi,

For motor power, I only want to read the value to display it in the interface.
The value of the JS_THR_GAIN parameter does not change when I increase or when I decrease the power, so there must be another parameter.

Nico

Hi @AWDRONE,

Check the NAMED_VALUE_FLOAT messages coming from the autopilot, the pilot gain and other parameters are reported using it:

you can run watch NAMED_VALUE_FLOAT in mavproxy and you should get something like this:

< NAMED_VALUE_FLOAT {time_boot_ms : 98875, name : InputHold, value : 0.0}
< NAMED_VALUE_FLOAT {time_boot_ms : 99127, name : CamTilt, value : 0.5}
< NAMED_VALUE_FLOAT {time_boot_ms : 99127, name : CamPan, value : 0.5}
< NAMED_VALUE_FLOAT {time_boot_ms : 99127, name : TetherTrn, value : 0.0}
< NAMED_VALUE_FLOAT {time_boot_ms : 99127, name : Lights1, value : 0.0}
< NAMED_VALUE_FLOAT {time_boot_ms : 99127, name : Lights2, value : 0.5}
< NAMED_VALUE_FLOAT {time_boot_ms : 99127, name : PilotGain, value : 0.5}
< NAMED_VALUE_FLOAT {time_boot_ms : 99127, name : InputHold, value : 0.0}