Coder Social home page Coder Social logo

vehiclecontrol's Introduction

Table of Contents

Introduction

This repository includes the planning algorithm based on frenet optimal polynomial and the commonly used control algorithms for vehicle motion like PID, LQR, MPC and other algorithms based on geometry model like Stanley, Pure Pursuit and Rear Wheel Feedback.

Two scenarios are tested here:

  • forward driving in curved road with differernt velocity and radius
  • reverse driving in curved road

The velocity of test trajectory is in the range from 10m/s to 20m/s, a part of result plot is post in below, all the plots can be found in the folder named result_plot.

Simulation Platform

The simulation is conducted in GAZEBO, the vehicle model and the senario are obtained from the Demo of Prius in ROS/GAZEBO(https://github.com/osrf/car_demo.git).

Prius_image Prius_image_2 senario

WorkFlow

work_flow

Planning Module

result

planning_result_git

planning_result

Planning Strategy

planning_strategy

Control Module

It is recommended to switch off the planning module to observe the performance of control module better by modifying the Activate_planning_function in src/plan/conf/planning_conf.txt to 0;

Run Example

~$ cd catkin_ws/src/multi_launch/
# forward running in an empty world with smooth, artificial trjaectory
~/catkin_ws/src/multi_launch/$ ./forward.sh
# reverse running in an empty world with smooth, artificial trjaectory
~/catkin_ws/src/multi_launch/$ ./reverse.sh
# running in an simulated environment with recored trajectory
~/catkin_ws/src/multi_launch/$ ./simulated_world.sh
# running in an simulated environment with ramp
~/catkin_ws/src/multi_launch/$ ./run_in_ramp.sh

working process

Choose Test Trajectory

~$ cd catkin_ws/src/plan/launch/
# change the trajectory in empty world
~/catkin_ws/src/plan/launch$ gedit publish_mat_trajectory.launch

Modify the value of test trajectory file path to change the test trajectories. The avaliable test trajectories can be found in the folder named "test_trajectories".

In this folder, the trajectory file starting with "mat" means that it is a artificial trajectory, and the recorded trajectories are recorded in the GAZEBO senario, which are not so smooth, but closer to the real situation.

The last num of trajectory file name means the velocity of vehicle running in curve, only for the "mat trajectories", the velocity of recorded trajectories are not constant.

Record Trajectory

Recording a trajectory is a good method to generate an availble trajectory in the city environment.

  1. find the plugin code
~$ cd catkin_ws/src/control/plugins/
~/catkin_ws/src/control/plugins$ gedit PriusHybridPlugin.cc
  1. Switch on the recording function
    correct the record_enabled into True

  2. roslaunch

~$ roslaunch control record_trajectory.launch
  1. record trajectory
    "W","A","D" are the control keys
    "S" is "reverse"
    "E" is "brake"

  2. Get recorded trajectory
    The recorded trajectory is stored in the folder (catkin_ws/src/car_demo/recorded_trajectories), you can trim it and move it to the test_trajectories folder.

Choose Controller and Adjust Their Parameters

~$ cd catkin_ws/src/control/conf/
~/catkin_ws/src/control/conf$ gedit control_conf.txt

This file includes the physical parameters of vehicle model (can not be modified) and all the parameters (can be adjusted) required by the controllers and other important objects necessary during the operation of control module.

The controller can be classified into the distributed controllers (control longitudinal and lateral motion respectively) and centralized controllers (control the vehicle motion coupled).

To active distributed controller, the CONTROLLER_NUM must be 2, the next step is to set the LONGITUDINAL_CONTROLLER and LATERAL_CONTROLLER, the options are listed below them.

To active centralized controller, the CONTROLLER_NUM must be 1, the next step is to set the CENTRALIZED_CONTROLLER.

Choose the Plot shown

Since the FPS is low if we plot more than one figures simultaneously, so now there is only one plot can be shown during the simulation (after simulation, we can get all the plots, see Other Plot), the steps to choose the plot shown is:

~$ cd catkin_ws/src/control/scripts/
~/catkin_ws/src/control/scripts$ gedit TrajectoryPlotter.py

change the TARGET_PLOT to choose which plot you want to see during simulation, now there are three options

  • trajectory comparison
  • velocity comparison with station
  • heading angle comarison with station

Controllers

Result PLot(reverse)

v=10m/s

Result PLot(forward)

Tracking Process (gif)

path tracking velocity tracking heading tracking

Pure Pursuit Controller

Pure Pursuit Controller V=10m/s Trajectory Tracking Velocity Tracking Heading Tracking Lateral Distance Error Velocity Error Heading Error Pure Pursuit Controller V=15m/s Trajectory Tracking Velocity Tracking Heading Tracking

Stanley Controller

Stanley Controller V=10m/s Trajectory Tracking Velocity Tracking Heading Tracking Lateral Distance Error Velocity Tracking Heading Error Stanley Controller V=15m/s Trajectory Tracking Velocity Tracking Heading Tracking

Rear Wheel Feedback Controller

Rear Wheel Feedback Controller V=10m/s

Trajectory Tracking Velocity Tracking Heading Tracking Lateral Distance Error Velocity Error Heading Error Rear Wheel Feedback Controller V=15m/s Trajectory Tracking Velocity Tracking Heading Tracking

LQR

LQR Controller V=10m/s

Trajectory Tracking Velocity Tracking Heading Tracking Lateral Distance Error Velocity Error Heading Erro LQR Controller V=15m/s Trajectory Tracking Velocity Tracking Heading Tracking

LQR with prediction

LQR Controller with prediction V=10m/s

Trajectory Tracking Velocity Tracking Heading Tracking Lateral Distance Error Velocity Error Heading Error LQR Controller with prediction V=15m/s Trajectory Tracking Velocity Tracking Heading Tracking

MPC

MPC Controller V=10m/s

Trajectory Tracking Velocity Tracking Heading Tracking Lateral Distance Error Velocity Error Heading Error MPC Controller V=15m/s Trajectory Tracking Velocity Tracking Heading Tracking

Error Comparison

V=10m/s Velocity Error Lateral Distance Error Heading Error V=15m/s Velocity Error Lateral Distance Error Heading Error V=20m/s Velocity Error Lateral Distance Error Heading Error

Plot

~$ cd catkin_ws/src/control/plot_py/
~/catkin_ws/src/control/plot_py$ python result_plot.py

According to the output simulatin result, the scrtipt can plot the result of path tracking, velocity tracking and heading tracking, as well as the figures of error.

Maintainers

@djh1995555

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.