Skip to content

JagtapSagar/Vehicle-Control

Repository files navigation

Vehicle Control

Longitudinal Control//Lateral Control//Running Carla Simulator//Simulation

This repository includes files from the final project of the Introduction to Self-Driving Cars course by University of Toronto. This project involves implementation of vehicle controllers for self-driving cars in CARLA simulator in python 3.6.

To implement a fully functional controller module for autonomous car the following controls were implemented:

  • Longitudinal Control
  • Lateral Control

The table below shows the output variables of the controller module and their respective ranges.

Description Variable Name Limits
Throttle throttle_output 0 to 1 (in percentage)
Steering steer_output -1.22 to 1.22 (in radians, from left to right)
Brake brake_output 0 to 1 (in percentage)

Longitudinal Control

A Proportional-Integral-Derivative (PID) controller was used for longitudinal control. The controller takes in the difference between the desired and the actual vehicle speeds as inputs and outputs throttle and/or brake positions needed to minimize that difference. Since the requirement here is of a simple speed controller, a PID based control design would suffice. This controller calculates the necessary throttle and brake positions needed to achieve desired speed.

The schematic diagram below is the illustration of the PID control loop used.

This design can be broken down into a high level and a low level controller. The formulation of the high level PID controller is as follows:

Were,

  • u(t) - Controller effort (Acceleration output)
  • e(t) - Error value
  • Kp - Proportional gain
  • Ki - Integral gain
  • Kd - Derivative gain

A low-level controller converts the acceleration output to throttle and brake commands. In this case, for simplicity positive acceleration will be throttle and negative outputs will correspond to brake.

Lateral Control

A lateral controller is used by the vehicle to track the vehicles desired path. The two main goals of this controller are:

  • Heading path alignment.
  • Elimination of offset to path.

In this project a Stanley Controller was implemented, which is a geometric control design ,i.e., it relies on the geometry and coordinates of the desired path and the kinematic model of the vehicle.

The kinematic model of the vehicle is based on the Bicycle kinematic model which is illustrated below.

The reference positions given here are waypoint positions, therefore heading and crosstrack errors need to be calculated.

  • Crosstrack error (e) - Calculated as the perpendicular distance from the line connecting the previous and next waypoints and the front axle of the vehicle.

  • Crosstrack steering (δcrosstrack) - Contribution of crosstrack error to the steering input.

    Were,

    • k - Gain (determined experimentally)
    • v - Current velocity
  • Heading error (Ψ): Calculated as the difference between the trajectory line angle and the vehicle yaw.

Combining the above gives the output steering angle (δ) calculated as shown below.

Combining the longitudinal and lateral controller completes the vehicle control module.

Running Carla Simulator

To run this project:

  1. Install Carla Simulator
  2. Download this directory with all its files into a folder in the PythonClient directory within the Carla simulator directory.
  3. Execute following command in the simulator directory to open the simulator.
    • For Ubuntu: ./CarlaUE4.sh /Game/Maps/RaceTrack -windowed -carla-server -benchmark -fps=30
    • For Windows: CarlaUE4.exe /Game/Maps/RaceTrack -windowed -carla-server -benchmark -fps=30
  4. Execute module_7.py from project directory.
    • For Ubuntu: python3 module_7.py
    • For Windows: python module_7.py

NOTE:

  • CARLA requires python version 3.5 or 3.6
  • matplotlib version 3.0.0 was used for this project. Newer version might cause errors with the use of deprecated matplotlib.backends.tkagg import.

Simulation

The simulation begins with the self-driving car being placed at the start line of a preconfigured racetrack in the CARLA simulator. The controller is feed the list of way points and a velocity profile to follow. PID longitudinal controller outputs the throttle and brake commands to execute given velocity profile. And the Stanley lateral controller outputs steering angles to ensure the vehicle follows the desired path which consists of the given waypoint. The control feedback plots also can be seen on the left of the illustration below.

The reference and the actual trajectory profile of the simulation is also illustrated in the gif below. The path in green is defined by the waypoints given. The path in yellow is the trajectory the vehicle has traced.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages