Introduction

Goal → For this assignment you will write two independent ROS nodes.

Objective 1 →Write a node that controls the car by steering it using a PID controller.

Objective 2 → Write a node that controls the car by steering it using a Pure Pursuit Controller.

You will be provided with a zip containing simulator files. Read the setup section for more details

<aside> ❗ Do NOT modify any of these files

</aside>

Prerequisites

We will build on the concepts used in Assignment 2 and Class Activities.

Before starting, ensure you are able to visualize points and paths in rviz. You can also refer to the class activity - Visualization (Class Activity). Also ensure that you know the topics used to publish movement commands to the car.

The car uses Ackermann driving. You can drive the car by publishing AckermannDrive messages to the topic car_1/command . Use the ROS docs or rosmsg show to check the fields to be populated in the message ( you dont need to populate all the fields ).

The car publishes it’s odometry on the topic car_1/base/odom using an Odometry message (nav_msgs/odometry) . You can get the global position and orientation of the car from this message.

Also, you will be using rosparams to set the speed of your car. Ensure you are familiar with how to set rosparams in the launch file and using the set param value in your code. ( You can find more information and details from the Resources section. )

You will be implementing 2 types of controllers to make the car follow a given reference. They are fundamentally different in the way they generate commands for the car to follow. So ensure you understand how both work before implementing.

  1. PID (Proportional-Integral-Derivative) controller is a feedback control system that adjusts an output signal based on the difference between a desired setpoint and a process variable. It uses proportional, integral, and derivative terms to calculate the controller output. The proportional term responds quickly, the integral term eliminates steady-state error, and the derivative term improves stability. PID controllers are used in temperature control, robotics, and industrial automation. Proper tuning is essential for achieving accurate and stable control. ( You can find more information and details from the Resources section. )
  2. Pure Pursuit is a navigation algorithm used for steering mobile robots or vehicles towards a target point or trajectory. It calculates the closest point on the path to the vehicle's current position, determines the lookahead distance, and computes the steering angle required to steer the vehicle towards that point. It is simple and efficient, adaptable to various path types and shapes, and can handle non-linear and dynamic paths. It is widely used in autonomous vehicles and robotics and is suitable for real-time applications as it requires minimal computation and can operate in closed-loop control systems. ( You can find more information and details from the Resources section. )

<aside> 💡 As the assignment requires controlling the car, it is recommended to output various parameters being used by the controller to the screen. eg:- error, steering angle, lookahead point, reference, etc.

</aside>

Resources

<aside> ‼️ Please use rospkg to obtain the path of the package you are working in to use relative path. roslaunch will run your code in the ROS/catkin home directory which differs based on the environment and thus the relative path won’t function similar to the way it was implemented in assignment 1.

</aside>

Setup

  1. Unzip the file provided - lab3_setup.zip
  2. Copy the lab3_world.world file into ~/catkin_ws/src/audubon_gazebo/world directory
  3. Copy the lab3_world.launch file into ~/catkin_ws/src/audubon_gazebo/launch directory
  4. Create a new package lab3 in catkin src. ( This will be the package you will use in the assignment. )
  5. cd into ~/catkin_ws and build the package using catkin build
  6. Source the workspace using source ~/catkin_ws/devel/setup.bash
  7. Run the simulator using roslaunch audubon-gazebo lab3_world.launch which will launch the testing environment in gazebo

Tasks

  1. Task 1 → PID Controller (50 points)

    1. Plot the reference in RVIZ as a yellow line. (10 points)

      $$ Reference = y = f(x) = \begin{cases} 0, & \text{for } 0\leq x\leq 15\\ 2, & \text{for } 15\leq x\leq 30\\ 5, & \text{for } 30\leq x\leq 45\\ 10, & \text{for } 45\leq x\leq 60\\ 15, & \text{for } 60\leq x\leq 200\\ STOP, & \text{for } 200\le x\\ \end{cases} $$

      Marker Details:

      Scale → 0.1

      Action → ADD

      Type → LINE_STRIP

      Frame_id → odom

    2. Control the steering of the car using a PID controller. (25 points)

      Steps

      1. Get current y of the car.
      2. Calculate y error to reference, derivative of the error and integral of the error.
      3. Combine the errors calculated with the PID methodology to generate steering input with PID gains [ You will tune these gains in part d. ].
      4. Command the car using calculated steering input.
      • Car Dynamics [ Please ensure these constraints are followed. ]
        • Speed → 2 m/s [ Use rosparam to set this speed in your launch file. We should be able to change the speed to verify the response for slower and faster speeds. Parameter Name → Vmax Type → double ]
        • Steering angle → [-25 deg, 25 deg]
    3. Car should STOP at the end of the reference. (5 points)

      • This can be done by commanding speed of 0 m/s
    4. Tune PID controller to get a reasonable rise time, overshoot, settling time and steady state. (10 points)

      • In the context of this assignment, reasonable implies that the reference is followed with an error ≤ 0.5m by the end of current section and steady-state error ≤ 0.1 m [ i.e at the end of section 2 of the reference → x = 30, the y error ≤ 0.5m and at x = 200, the y error ≤ 0.1 m ].
      • You can plot the error using rqt_plot to visualize the PID parameters.
      • You can also change the speed of the car between 1 m/s and 3 m/s to tune your controller for all speeds between 1 m/s to 3 m/s. (self-study task)
      • You can calculate the performance of you controller using the MAE metric. (self-study task) [reasonable → MAE ≤ 0.6 at the end of all sections. ]
      • You can also turn the integral component on after the reference stabilizes for some time. This is how most real world PID controller work. This will improve the performance of your controller. (self-study task)
    5. Add a launch file called lab3_pid.launch in the launch directory which will launch the PID code. We will use this launch file to run your rosnode and rviz configuration.


    Deliverable → The car must be able to follow the reference with reasonable PID parameters.

    PID Demo: PID Demo

<aside> 💡 At x = 70, the car is quite far from the provided reference. But as the reference doesn't change till x = 200, the error reduces to 0. This is what is referred to as steady-state error.

</aside>

  1. Task 2 → Pure Pursuit Controller (50 points)

    1. Plot the following in RVIZ (5 points)

      • Reference lab3_track.csv as a cyan points.
      • Closest point as a purple point.
      • Lookahead point as a yellow point.

      Marker Details:

      Scale → 0.1

      Action → ADD

      Type → SPHERE

      Frame_id → odom

      It is recommended to use MarkerArray.

      <aside> 💡 Use relative path to access the lab3_track.csv file.

      </aside>

    2. Control the steering of the car using a Pure Pursuit controller. (30 points)

    3. Car should loop around the trajectory track until ROS shutdown. (5 points)

    4. Tune Pure Pursuit controller to follow the reference with reasonable accuracy. (10 points)

    5. Add a launch file called lab3_pp.launch in the launch directory which will launch the Pure Pursuit code. We will use this launch file to run your rosnode and rviz configuration.

    Deliverable → The car must be able to follow the reference is reasonable accuracy.

    PurePursuit Demo: Pure Pursuit Demo

<aside> 💡 For evaluation, the simulation environment will be running. The launch files submitted by the student will then be launched to test the functionality. The PID code will be run using roslaunch lab3 lab3_pid.launch and the Pure Pursuit code will be run using roslaunch lab3 lab3_pp.launch . Ensure you test these before submitting.

</aside>

Submission Instructions


Please use UB Learns for submission.

You will submit lab3.zip, a compressed ZIP file containing the lab3 folder. The folder must contain all the contents of your package. Submissions should be a single ZIP file. Files of other types (RAR, TAR, GZ, etc.) will not be accepted. The folder should contain CMakeLists.txt, package.xml and other related files and folders. You can use the provided template. The package should compile if we drop it into our catkin workspace and call catkin build. Please take care to follow the instructions carefully. Problems in running will result in loss of points.

<aside> 💡 Follow the folder structure conventions.

</aside>