# Set Thrusters To Run With A Pilot Input Gain Less Than 25%

**URL:** <https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547>\
**Category:** Blue Robotics Software\
**Tags:** pymavlink\
**Created:** [September 6, 2021, 11:09pm UTC](https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547 "2021-09-06T23:09:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CBW3750](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@CBW3750](https://discuss.bluerobotics.com/u/CBW3750)\
**Post date:** [September 6, 2021, 11:09pm UTC](https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547/1 "2021-09-06T23:09:11Z")

</div>

Hi all,

I wish to control the BlueROV2 thrusters with Pymavlink with a pilot input gain less than 25%.

I’ve reference the following hyperlinks:

[https://www.ardusub.com/developers/full-parameter-list.html#jsgaindefault-default-gain-at-boot](https://www.ardusub.com/developers/full-parameter-list.html#jsgaindefault-default-gain-at-boot)

[http://www.ardusub.com/developers/pymavlink.html#read-and-write-parameters](http://www.ardusub.com/developers/pymavlink.html#read-and-write-parameters)

[http://www.ardusub.com/developers/pymavlink.html#read-all-parameters](http://www.ardusub.com/developers/pymavlink.html#read-all-parameters)

[https://mavlink.io/en/messages/common.html#PARAM\_VALUE](https://mavlink.io/en/messages/common.html#PARAM_VALUE)

[https://mavlink.io/en/messages/common.html#PARAM\_SET](https://mavlink.io/en/messages/common.html#PARAM_SET)

I tried setting the JS\_GAIN\_DEFAULT parameter to 0.1 with the following function:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/3/3f6474b73467f152f2e1987cf37b45250cc323d4.png)

But when I read all parameters with the following:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/b/b310ee0c741287190ed6122c508f0e45cf78caf5.png)

The output of the _JS\_GAIN_ parameter settings was this:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/bluerobotics/original/2X/6/6c04ca909b23f34b5e665e8b87636295c11c8b81.jpeg)

It’s not clear to me why the JS\_GAIN\_DEFAULT parameter didn’t change.

I’d appreciate the assistance.

-Cameron

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [September 7, 2021, 2:25am UTC](https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547/2 "2021-09-07T02:25:42Z")

</div>

`%d` is an integer format-specifier so it’s rounding whatever value it gets to the nearest integer. Your parameter is a float, so you want to use `%f` instead (or you can use e.g. `%.3f` if you want a float with three decimal places).

Even better, if you’re using Python 3 you can use f-strings, and if you’re using \>= Python 3.8 you can use the equals formatting that can help make things a bit clearer:

```auto
        message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        name, value = message['param_id'], message['param_value']
        print(f'{name = }\t{value = :.3f}')

```

By the way, where possible it’s preferred for code to be posted as code blocks, so it can be directly copied for testing. There are instructions for how to do that in the [Formatting a Post/Comment](https://discuss.bluerobotics.com/t/how-to-use-the-blue-robotics-forums-please-read/10521#formatting-a-postcomment-15) section of the “How to Use the Blue Robotics Forums” pinned post 🙂

EDIT: More generally, those two examples could do with an update, so I’ve raised a github issue about that here:

> <https://github.com/bluerobotics/ardusub-gitbook/issues/217>
>
> Existing docs could be updated to make use of \[\`master.param\_fetch\_\*\`\](https://g…ithub.com/ArduPilot/pymavlink/blob/master/mavutil.py#L519-L535), and \[\`master.param\_set\_send\`\](https://github.com/ArduPilot/pymavlink/blob/master/mavutil.py#L543-L552) or \[\`pymavlink.mavparm.MAVParmDict.mavset\`\](https://github.com/ArduPilot/pymavlink/blob/master/mavparm.py#L10-L71).
> 
> Would also be good to format the output values as floats, since not all parameters are integers (as brought up \[here\](https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547/2)). Likely worth changing to \`.format\` syntax (or \`f-strings\`, but since they require Python \>= 3.6 they aren't compatible with the current companion, so would only work on the surface computer or a companion with a \[more recent Python version\](https://discuss.bluerobotics.com/t/updating-python-in-companion/10398/2))

---

<div class="post-metadata">

**Author:** ![CBW3750](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@CBW3750](https://discuss.bluerobotics.com/u/CBW3750)\
**Post date:** [September 13, 2021, 12:06am UTC](https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547/3 "2021-09-13T00:06:11Z")

</div>

Hi Eliot,

I took your input and edited my code for reading out the parameters, as presented here:

```auto
import time
import sys

# Import mavutil
from pymavlink import mavutil

# Create the connection
master = mavutil.mavlink_connection('udpin:0.0.0.0:505')
master.wait_heartbeat() # Wait a heartbeat before sending commands or trying to send or recieve new data
print("Heartbeat from system (system %u component %u)" % (master.target_system, master.target_system))
# Wait a heartbeat before sending commands
master.wait_heartbeat()

# Request all parameters
master.mav.param_request_list_send(
    master.target_system, master.target_component
)

while True:
    time.sleep(0.01)
    try:
        message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        name, value = message['param_id'], message['param_value']
        print('name: %s\tvalue: %.3f' % (message['param_id'], message['param_value']))
        
    except Exception as error:
        print(error)
        sys.exit(0)

```

The read parameters from ArduSub made more sense. I couldn’t compile my code with the “python3” command. I followed the installation guide; [GitHub - ArduPilot/pymavlink: python MAVLink interface and utilities](https://github.com/ArduPilot/pymavlink) My python version is 2.7.16 and python3 version is 3.9.7. It’s clear that Pymavlink assumes the command “python” is my path.

By the way, I also read your instructions on [How to Use the Blue Robotics Forums (Please Read)](https://discuss.bluerobotics.com/t/how-to-use-the-blue-robotics-forums-please-read/10521).

Thank you!

Cameron

---

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [September 13, 2021, 12:19am UTC](https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547/4 "2021-09-13T00:19:09Z")

</div>

> [@CBW3750](#):
>
> ```auto
> message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
> name, value = message['param_id'], message['param_value']
> print('name: %s\tvalue: %.3f' % (message['param_id'], message['param_value']))
> 
> ```

This is redundant - you extract the `name` and `value` into variables, and then extract them again instead of using the variables you just defined. You can either do just

```auto
        message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        print('name: %s\tvalue: %.3f' % (message['param_id'], message['param_value']))

```

or you can use the extracted values

```auto
        message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        name, value = message['param_id'], message['param_value']
        print('name: %s\tvalue: %.3f' % (name, value))

```

> [@CBW3750](#):
>
> My python version is 2.7.16 and python3 version is 3.9.7. It’s clear that Pymavlink assumes the command “python” is my path.

Different versions of python don’t have access to the same libraries. If you want to use pymavlink with python3 and you’re not using a utility like `python-is-python3` (mentioned in the installation guide) then you can install it using the `python3` command instead of `python` (e.g. if you installed with

```auto
sudo python -m pip install --upgrade pymavlink

```

you can instead use

```auto
sudo python3 -m pip install --upgrade pymavlink

```

to install it for Python 3).

> [@CBW3750](#):
>
> By the way, I also read your instructions on [How to Use the Blue Robotics Forums (Please Read)](https://discuss.bluerobotics.com/t/how-to-use-the-blue-robotics-forums-please-read/10521).

Glad to hear it - hope that’s helpful! 🙂

---

<div class="post-metadata">

**Author:** ![CBW3750](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@CBW3750](https://discuss.bluerobotics.com/u/CBW3750)\
**Post date:** [September 15, 2021, 2:11pm UTC](https://discuss.bluerobotics.com/t/set-thrusters-to-run-with-a-pilot-input-gain-less-than-25/10547/5 "2021-09-15T14:11:29Z")

</div>

Thank you Eliot! I appreciate the extra input. I successfully installed the pymavlink with python3 using

```auto
sudo python3 -m pip install --upgrade pymavlink

```

and my code compiled with the edits you suggested when using \>= Python 3.8

```auto
  message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        name, value = message['param_id'], message['param_value']
        print(f'{name = }\t{value = :.3f}')

```

As a side note, I suggest that

```auto
sudo python3 -m pip install --upgrade pymavlink

```

be written into the installation guide.

Thank you again!

-Cameron
