# PID Calibration

**URL:** <https://forum.ubiquityrobotics.com/t/pid-calibration/668>\
**Category:** Uncategorized\
**Created:** [November 20, 2020, 2:11am UTC](https://forum.ubiquityrobotics.com/t/pid-calibration/668 "2020-11-20T02:11:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![boarderkris](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/b/8797f3/32.png) [@boarderkris](https://forum.ubiquityrobotics.com/u/boarderkris)\
**Post date:** [November 20, 2020, 2:11am UTC](https://forum.ubiquityrobotics.com/t/pid-calibration/668/1 "2020-11-20T02:11:30Z")

</div>

Hi folks,

I’m new to this forum, but have a pretty neat custom setup with my magni, including an RPLidar on board.

The RPLidar is working quite well, but the magni is having a real tough time keeping a straight line, and a lot of odd noise is coming from the motors when it comes to a complete stop.

I believe the issue is the PID controller. Are there any instructions on calibrating the PID controller? Can anyone post there sample PID values from rqt\_reconfigure?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![MoffKalast](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/moffkalast/32/214_2.png) [@MoffKalast](https://forum.ubiquityrobotics.com/u/MoffKalast)\
**Post date:** [November 20, 2020, 3:00pm UTC](https://forum.ubiquityrobotics.com/t/pid-calibration/668/2 "2020-11-20T15:00:35Z")

</div>

Hey yeah, it’s definitely the motor PID parameters that’s causing that. Can you check the /diagnostics topic for the params and the firmware version?

After you have those @mjstn2011 should be able to give you some notes on fixing it.

---

<div class="post-metadata">

**Author:** ![boarderkris](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/b/8797f3/32.png) [@boarderkris](https://forum.ubiquityrobotics.com/u/boarderkris)\
**Post date:** [November 20, 2020, 3:28pm UTC](https://forum.ubiquityrobotics.com/t/pid-calibration/668/3 "2020-11-20T15:28:51Z")

</div>

Hi @MoffKalast,

Thank you for the quick response. Here is a cut of the motor info from the /diagnostics topic:

## – header: seq: 51545 stamp: secs: 1605885717 nsecs: 901518325 frame\_id: ‘’ status:

```
level: 0
name: "motor_node: Firmware"
message: "Firmware version is OK"
hardware_id: "Motor Controller"
values:
  -
    key: "Firmware Version"
    value: "35"

```

- level: 1  
name: “motor\_node: Limits”  
message: " left integral,; right integral,"  
hardware\_id: “Motor Controller”  
values: []
- 
## level: 0 name: “motor\_node: Battery” message: “Battery OK” hardware\_id: “Motor Controller” values:

```
key: "Battery Voltage"
value: "29.4872"

```

- 

## level: 2 name: “motor\_node: MotorPower” message: “Motor power on” hardware\_id: “Motor Controller” values: - key: “Motor Power” value: “True”

```
level: 0
name: "motor_node: FirmwareOptions"
message: "High resolution encoders, Standard wheels"
hardware_id: "Motor Controller"
values:
  -
    key: "Firmware Options"
    value: "1"

```

- 
## level: 0 name: “motor\_node: FirmwareDate” message: “Firmware daycode format is YYYYMMDD” hardware\_id: “Motor Controller” values:

```
key: "Firmware Date"
value: "20190815"

```

* * *

---

<div class="post-metadata">

**Author:** ![mjstn2011](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/mjstn2011/32/30_2.png) [@mjstn2011](https://forum.ubiquityrobotics.com/u/mjstn2011)\
**Post date:** [November 21, 2020, 6:02am UTC](https://forum.ubiquityrobotics.com/t/pid-calibration/668/4 "2020-11-21T06:02:33Z")

</div>

Hello, Mark here.

We are way behind on getting a true production release to update v35, sorry about that.  
A great many firmware bug fixes as well as better PID parameters have been coming along since v35. These changes require both updated firmware as well as updated host code to take advantage of new firmware abilities. We are actively trying to get out a new image and once this is out we will be then ready to put out firmware so the two work together.

As far as PID parameters Vid mentioned how we show the PID parameters in the /diagnostics topic of ROS but that is only true on rather recent hostside software (on raspberry Pi linux).

The PID parameters can be seen and directly edited for new values in base.yaml file.  
Edit base.yaml: sudo vi /opt/ros/kinetic/share/magni\_bringup/param/base.yaml

Try the values I show below which are less aggressive and lower the amount of ‘chatter’ which is what we call what you are discussing. Edit the above file, change to these.  
pid\_proportional: 5100  
pid\_integral: 2  
pid\_derivative: -111  
Dont change other things. Save the file and reboot and the new parameter will be active.

If you want to live ‘closer to the edge’ you can request beta firmware from me and try that out as well. Look at this page for how to do firmware updates.

> **[Upgrading Motor Controller Firmware](https://learn.ubiquityrobotics.com/firmware-upgrade)**
>
> Tutorials for Magni

If it will not let you get the v38 beta from the web (don’t recall if that is setup for request yet) I can send it to you and you would use the --file option. let me know.  
There were other v38 beta dates so verify your firmware comes up in /diagnostics with the 0909 version (sept 2020).

---

<div class="post-metadata">

**Author:** ![boarderkris](https://forum.ubiquityrobotics.com/letter_avatar_proxy/v4/letter/b/8797f3/32.png) [@boarderkris](https://forum.ubiquityrobotics.com/u/boarderkris)\
**Post date:** [November 21, 2020, 3:49pm UTC](https://forum.ubiquityrobotics.com/t/pid-calibration/668/5 "2020-11-21T15:49:39Z")

</div>

Hi Mark,

Thank you for your response. Is there any chance the PID parameters are being over written on magni-base start somewhere other than the base.yaml file? When I check the values in rqt\_reconfigure, they never match watch is in the base.yaml.

For refrence, here were the PID values, the first time I opened rqt\_reconfigure:  
PID\_P: 5000  
PID\_I: 7  
PID\_D:-30  
PID\_C: 1000  
PID\_W: 100  
PID\_V:0  
MAX\_PWM: 100

Can you confirm the values other than the Proportional, Integral and Derivative are correct?

Would be happy to try out the beta version 38 as well.

Cheers,  
Kris

---

<div class="post-metadata">

**Author:** ![mjstn2011](https://forum.ubiquityrobotics.com/user_avatar/forum.ubiquityrobotics.com/mjstn2011/32/30_2.png) [@mjstn2011](https://forum.ubiquityrobotics.com/u/mjstn2011)\
**Post date:** [November 24, 2020, 11:04am UTC](https://forum.ubiquityrobotics.com/t/pid-calibration/668/6 "2020-11-24T11:04:36Z")

</div>

If you have current ubiquity\_motor repository then you will see the actual parameters in use in topic /diagnostics. I don’t fully understand rqt\_reconfigure completely but what I was surprised to find is it does not seem to automagically start with the default Ubiquity Motor pid parameters and instead has it’s own defaults. If you have the most recent ubiquity\_motor you would not need rqt\_reconfigure to know the pid parameters as I show them now in /diagnostics topic. Normally our images do not have ubiquity\_motor in the catkin\_ws/src folder. You would have to be in ~/catkin\_ws/src then use the clone like this: git clone [https://github.com/UbiquityRobotics/ubiquity\_motor](https://github.com/UbiquityRobotics/ubiquity_motor) After that go to ~/catkin\_ws and use ‘catkin\_make’ Next reboot you would have parameters show up in /diagnostics topic.
