[ROS Q&A] 112 – How to tune a PID with ROS Control

Written by Ricardo Tellez

04/04/2018

 

We show you a manual method to tune a PID for a robot that uses ROS Control to control its joints with a position controller. This method is very artisan but it is enough for most of the cases.

We do not teach how ROS Control works in this video. We assume you already know how to configure a joint to work with the ROS controllers.

Step 1. Create a project in ROS Development Studio(ROSDS)

ROSDS helps you follow our tutorial in a fast pace without dealing without setting up an environment locally. If you haven’t had an account yet, you can create a free account here. Let’s call the testing.

Step 2. Tune PID

At first, let’s launch the rrbot simulation from Simulations->RRBot. To control the robot, we also need to launch the control with

roslaunch rrbot_control rrbot_control.launch

You will have to tune the pid value in the rrbot_contorl.yaml file in the rrbot_control package under the config.

We can also use rqt_gui to help us tune the parameter.

rosrun rqt_gui rqt_gui

Then open the Tools->graphical tool.

In the gui, let’s send command to the rrbot/joint1_position_controller/command topic to control the robot. The message type is automatically selected to std_msgs/Float64. We’ll change the frequency to 50 Hz, then click +.

Then click the + on the left to unfold the topic and change the expression to sin(i/50)*0.5. Check the box on the left side to start publishing into the topic.

You should see the robot starts to swing it’s arm now.

It’s also possible to plot the message from Plugins->Visualization->Plot

Select the correct topic /rrbot/joint1_position_controller/state/process_value/data then click +.  You should see the data sent.

How about the actual value? It’s in the topic /rrbot/joint1_position_controller/state/process_value.

You’ll see that the actual state of the robot didn’t follow the command sent to the robot. That’s the reason why we need to tune the pid value.

Let’s open another tool to help us tune the value at the same time. Go to Plugins->Configuration->Dynamic Reconfigure.

You can change all the pid value in the plugin.

To tune the pid:

  1.  We start by increasing the p value to make the controller output more to catch the command.
  2. Increase the d value a bit to make the movement smoother.

You should see the state can synchronize with the command now. You can change the command to see if the controller can follow the command nicely. Then you can save the value in the rrbot_controller.yaml file.

Remember, you have to launch the controller again to apply the new value.

 

If you need to understand better ROS Control, please take the following course for fast understanding:

* ROS Control 101 (online course with tons of practice): https://goo.gl/6hEjyw

* Learn ROS fast in this online academy: https://goo.gl/KiCfXx

* Practice with the second joint, by using the ROS Development Studio: https://goo.gl/pBk44x

 

 

Edit by: Tony Huang

Topics: ros control
Masterclass 2023 batch2 blog banner

Check Out These Related Posts

129. ros2ai

129. ros2ai

I would like to dedicate this episode to all the ROS Developers who believe that ChatGPT or...

read more

0 Comments

Submit a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This