# Python interface for bluerov2 parameters

**URL:** <https://discuss.bluerobotics.com/t/python-interface-for-bluerov2-parameters/7522>\
**Category:** Blue Robotics Software\
**Created:** [June 10, 2020, 6:39am UTC](https://discuss.bluerobotics.com/t/python-interface-for-bluerov2-parameters/7522 "2020-06-10T06:39:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AWDRONE](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@AWDRONE](https://discuss.bluerobotics.com/u/AWDRONE)\
**Post date:** [June 10, 2020, 6:39am UTC](https://discuss.bluerobotics.com/t/python-interface-for-bluerov2-parameters/7522/1 "2020-06-10T06:39:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![patrickelectric](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/patrickelectric/32/2162_2.png) [@patrickelectric](https://discuss.bluerobotics.com/u/patrickelectric)\
**Post date:** [June 10, 2020, 3:39pm UTC](https://discuss.bluerobotics.com/t/python-interface-for-bluerov2-parameters/7522/2 "2020-06-10T15:39:00Z")

</div>

> [@AWDRONE](#):
>
> 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.

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

> [@AWDRONE](#):
>
> 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)

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](https://bluerobotics.com/store/rov/bluerov2-accessories/newton-gripper-asm-r1-rp/): “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](https://discuss.bluerobotics.com/t/control-bluerov2-with-ipad/7517/4).

---

<div class="post-metadata">

**Author:** ![AWDRONE](https://avatars.discourse-cdn.com/v4/letter/a/848f3c/32.png) [@AWDRONE](https://discuss.bluerobotics.com/u/AWDRONE)\
**Post date:** [June 11, 2020, 8:32am UTC](https://discuss.bluerobotics.com/t/python-interface-for-bluerov2-parameters/7522/3 "2020-06-11T08:32:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![williangalvani](https://avatars.discourse-cdn.com/v4/letter/w/6f9a4e/32.png) [@williangalvani](https://discuss.bluerobotics.com/u/williangalvani)\
**Post date:** [June 11, 2020, 3:24pm UTC](https://discuss.bluerobotics.com/t/python-interface-for-bluerov2-parameters/7522/4 "2020-06-11T15:24:53Z")

</div>

Hi @AWDRONE,

Check the [NAMED\_VALUE\_FLOAT](https://mavlink.io/en/messages/common.html#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:

```auto
< 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}

```
