Giter Site home page Giter Site logo

control_toolbox_pid_tutorial's Introduction

control_toolbox_pid_tutorial

I found myself with some difficulties to understand how to use the control_toolbox::pid class. After struggling to make it work, here I share my findings with a tutorial package to get you set up!

First, docs from the Pid class: http://docs.ros.org/api/control_toolbox/html/classcontrol__toolbox_1_1Pid.html

Mainly the interesting bits of this package are in src/example.cpp.

It implements a pid controller for a made up geometry_msgs/Twist cmd_vel. There is nothing to actually control for real, but you can play with the parts and find a working pid implementation with dynamic reconfigure to tune it available.

You should be able to build this package with something like:

mkdir -p pid_ws/src
cd pid_ws/src
git clone https://github.com/awesomebytes/control_toolbox_pid_tutorial
cd ..
catkin build
source devel/setup.bash

You can run the example node with:

rosrun control_toolbox_pid_tutorial pid_example

Or check it out with a launchfile setting up the PID parameters:

roslaunch control_toolbox_pid_tutorial example.launch

Dynamic reconfigure

Looks like this: dynamic_reconfigure_capture

PID state topic

If before starting the node that contains the PID you set the parameter publish_state in the param server to true, you'll get access to the PID internal state.

$ rostopic echo /my_namespace/my_pid/state
header: 
  seq: 992
  stamp: 
    secs: 1545405985
    nsecs: 449541433
  frame_id: ''
timestep: 
  secs: 0
  nsecs: 100291320
error: 0.0
error_dot: 0.0
p_error: 0.0
i_error: 0.0
d_error: 0.0
p_term: 0.0
i_term: 0.0
d_term: 0.0
i_max: 10.0
i_min: -10.0
output: 0.0
---

Debug all together

In my case, to debug what is going on I use:

  • rosrun rqt_robot_steering rqt_robot_steering (or rqt adding the plugin) to send geometry_msgs/Twist commands to a topic.
  • rosrun rqt_reconfigure rqt_reconfigure (or rqt adding the plugin) to play with the PID gains.
  • rosrun plotjuggler PlotJuggler PlotJuggler to visualize in real time the different inputs and outputs, including the PID state, in case that helps debugging (it may help to choose i_clamp values of the PID). rqt_multiplot could be used too (as rqt plugin probably).
  • Some rostopic echo of the topics that come in and out. They are useful sometimes too.
  • rosbag record and rosbag play to check in an offline fashion.

Stuff you may need installed

sudo apt-get install ros-kinetic-control-toolbox ros-kinetic-rqt-reconfigure ros-kinetic-plotjuggler ros-kinetic-rqt-robot-steering

But chances are you already have them.

control_toolbox_pid_tutorial's People

Contributors

awesomebytes avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.