Skip to content

ABD-01/ros_pid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PID implementation Turtlesim

Goal to Goal

Task

Model the motion from initial pose ( ) to goal pose ( ) in the following 3 parts as shown in figure and use PID controllers separately on the 3 parts:

  1. Turn by
  2. Move straight for
  3. Turn by
turtlesim_pid3.mp4

Usage

Clone this repository in catkin source directory

cd ~/catkin_ws/src
git clone https://github.com/ABD-01/ros_pid.git

Build the package in catkin workspace

cd ~/catkin_ws && catkin_make

To start ROS Master

roscore

To start a turtlesim simulator

rosrun turtlesim turtlesim_node

Run the PID simulator with command line arguments for final pose.

rosrun ros_pid turtlesim_pid.py [-h] -x X -y Y -t THETA

Input final pose

optional arguments:
  -h, --help            show this help message and exit
  -x X, --x X           Final x position
  -y Y, --y Y           Final y position
  -t THETA, --theta THETA
                        Final angle (in degrees)

For eg:

rosrun ros_pid turtlesim_pid.py -x 1 -y 1 -t 120

Start the rqt graph for visualization

rqt_plot /plot/error/data[0] /plot/error/data[1]

results

Tuning coefficients Kp, Ki, Kd

Custom coefficient values and loop rate can be passed while creating the PID class instance.

  pid = PID(
      final_pose,
      Krot1=K(4, 0, 2),
      Ktrans=K(0.5, 0.001, 0.02),
      Krot2=K(1, 0.0, 0.01),
      loop_rate=10
  )

Path Planning

Task

Same as above but to be done in single step rather than 3 individual steps.

Method

Used Hermite curve to generate a trajectory for the turtle given the initial and final conditions.

image image

Usage

Run the PID simulator with command line arguments for final pose.

rosrun ros_pid turtlesim_cubic.py [-h] -x X -y Y -t THETA

Input final pose

optional arguments:
  -h, --help            show this help message and exit
  -x X, --x X           Final x position
  -y Y, --y Y           Final y position
  -t THETA, --theta THETA
                        Final angle (in degrees)

For eg:

rosrun ros_pid turtlesim_cubic.py -x 1 -y 1 -t 120
Trajectory_hermite.mp4

About

Learning basics of ROS and PID controller

Resources

Stars

Watchers

Forks