The goals of this lab are to gain experience working with PID controllers and the ROS parameter server.
src
folder of your workspace directory. There
should now be two projects in that directory:
robot@turtlebot-07 ~/cs354_ws/src $ ls CMakeLists.txt labs pid_chase
pid_chase.py
in the
scripts directory, and the file pid_chase.launch
in the
launch directory. Make sure you understand the contents of those
files.
pid_chase.launch
. Point the robot toward
a wall and run pid_chase.py
. The robot should reach the
target distance, but the process isn't very pretty.
pid_chase.py
so that it reads the PID gain
parameters from the parameter server and uses the PID controller to
set the velocity.
Experiment with different values for your gain parameters until you
find settings that work well. You want the Turtlebot to smoothly
approach the target distance then stop at the appropriate point
without excessive oscillations. The p_error
term
should be driven to a value that is very close to 0.
The pid_chase.py
node publishes all three error terms. You
can echo them to a terminal:
rostopic echo /p_erroror you can visualize them using rqt_plot:
rosrun rqt_plot rqt_plot /p_error/data /i_error/data
pid_chase.launch
to set the parameters
appropriately. Test the new launch file. Once everything is
working, check in your final results with the log message One weakness of the current version of the project is that the robot makes very fast velocity changes when the distance changes: for example, when someone steps in front of the depth sensor. This results in jerky motions that are hard on the robot's motors.
We can force the velocity to change smoothly by taking a weighted average between the previous velocity and the desired velocity:
new_velocity = α × desired_velocity + (1 - α) × previous_velocityValues of α near 1 will lead to fast velocity changes, while values of α near 0 will lead to slow changes in velocity.
pid_chase.py
to implement velocity smoothing.
(You may need to re-tune your PID gain terms. In effect, smoothing
the velocity changes the dynamics of the system that the PID
controller is trying to control.)