adas package

Overview

ADAS stands for Advanced Driver Assistance System. This module takes in a command from the decision module and accordingly outputs a control signal which comprises of steering angle, gas, and brake. ADAS module has the two classes Longitudinal Control, which contains methods to output a longitudinal control (i.e. gas, brake) in different scenarios such as cruise control mode, lane change mode, turning at an intersection, stopping at a red signal etc, and LateralControl, which contains methods to output a lateral control signal (i.e. steering angle) in scenarios such as lane change, turning at an intersection, lane centering etc.

In either of the above classes, the methods use a very simple PID controller which use a reference velocity or distance (in longitudinal control) and a reference heading direction (in lateral control) for generating a control signal so that the vehicles next state closely matches the reference values used. Since the initial goal was to have a basic frame work to integrate all the modules, no sophisticated control models were developed. As this software is modular, it is fairly straightforward to improve upon the implemented control algorithms.

adas.driving_model module

class core.lib.adas.driving_model.ADAS(driver)

Provides driver assistance functions

driver

object – object that maintains driver attributes

longitudinal_control

object – object that controls longitudinal dynamics

lane_change

object – object that monitors lane_change control

lane_center

object – object that controls lane_centering

adas.intersection_model module

core.lib.adas.intersection_model.follow_traffic_signals(speed, speed_limit, distance_from_end_node, distance_from_front_car, traffic_signal_state)

Defines the behavior of a vehicle near an intersection.

Parameters:
  • speed (float) – speed of the vehicle
  • speed_limit (float) – as determined by the road, traffic rules
  • distance_from_end_node (float) – distance from entrance of an intersection
  • distance_from_front_car (float) – distance from front vehicle
  • traffic_signal_state (tuple) – traffic light color and remaining time before changing color
Returns:

(steering_angle, gas, brake)

Return type:

tuple

adas.lane_center module

class core.lib.adas.lane_center.LaneCenter

Contains two methods that keep an autonomous vehicle driving in the center of the lane.

control_steering(sensor_reading, lane_change_flag, lane_center_dy_flag, heading_control_flag, road_width, road_heading)

Controller to steer the vehicle given the input observations. Abstracts out a reference heading to follow using the given inputs and calls heading_control to get a steering output.

Note

The several flags used here determine which controller is acting on the vehicle at that instant. Only one controller acts at a time, and selects a reference heading which is maintained using heading_control.

Parameters:
  • sensor_reading (tuple) – (dy, dtheta) readings
  • lane_change_flag (bool) – True if the vehicle is changing lane
  • lane_center_dy_flag (bool) – True if vehicle is trying to control the distance from the lane center
  • heading_control_flag (bool) – True if vehicle is trying to control heading wrt road heading
  • road_width (float) – width of road
  • road_heading (float) – heading direction of the road in radians
Returns:

(steering_angle, lane_change_flag, lane_center_dy_flag, heading_control_flag)

Return type:

tuple

heading_control(car_heading, reference_heading)

Controller to provide a steering to align car_heading with a given reference_heading

Parameters:
  • car_heading (float) – angle in radians
  • reference_heading (float) – angle in radians
Returns:

steering_angle in radians

Return type:

float

adas.lane_change module

class core.lib.adas.lane_change.LaneChange

Contains methods that control an autonomous vehicle to change lane.

can_change_lane(visible_cars, direction, lane_no, max_lane_no)

Determines whether a situation is suitable for lane changing.

Parameters:
  • visible_cars (dict) – contains vehicles objects within certain distance and their spatial relation to the traget car
  • direction (str) – the direction to be examined
  • lane_on (int) – the index of a lane
  • max_lane_no (int) – the maximum index of all lanes on the road
Returns:

(str, str)

Return type:

tuple

change_lane(car, direction)

Performs the action of lane changing.

Parameters:
  • car (object) – vehicle object
  • direction (str) – the direction of the vehicle is changing toward
Returns:

(car.x, car.y)

Return type:

tuple

adas.longitudinal_contrl module

class core.lib.adas.longitudinal_contrl.LongitudinalControl(driver)

Controls the longitudinal movement of the vehicle by controlling gas and brake.

driver

object – Driver object specifies safety, aggression parameters of the driver

control(len_visible_cars, speed, speed_limit, distance_from_front_car, distance_from_end_node, traffic_signal_state, steering_angle=0, gas=0, brake=0)

Chooses which controller to use based on the inputs. Checks if there are any vehicles ahead and determines if cruise control should be used or some other control.

Parameters:
  • len_visible_cars (int) – number of vehicles in front within a certain distance
  • speed (float) – speed of the vehicle
  • speed_limit (float) – speed_limit of the road
  • distance_from_front_car (float) – distance from front vehicle
  • distance_from_end_node (float) – distance to entrance of an intersection
  • traffic_signal_state (tuple) – traffic light color and remaining time before changing color
  • steering_angle (float) – angle in radians
  • gas (float) – acceleration to give
  • brake (float) – brake to give
Returns:

(steering_angle, gas, brake)

Return type:

tuple

cruise(speed, speed_limit, distance_from_front_car, steering_angle, gas, brake)

Provides a basic cruise control assist. Maintains a safe distance from front vehicle, and if there is no front vehicle, follows a safe velocity as determined by the road limit and driver aggression/safety.

Parameters:
  • speed (float) – speed of the vehicle
  • speed_limit (float) – as determined by the road, traffic rules
  • distance_from_front_car (float) – distance from front vehicle
  • steering_angle (float) – angle in radians
  • gas (float) – acceleration
  • brake (float) – brake
Returns:

(steering_angle, gas, brake)

Return type:

tuple

follow_traffic_signals(speed, speed_limit, distance_from_end_node, distance_from_front_car, traffic_signal_state)

Determines what to do based on the traffic signal state.

Parameters:
  • speed (float) – speed of the vehicle
  • speed_limit (float) – as determined by traffic rules
  • distance_from_end_node (float) – distance from the end of the road
  • distance_from_front_car (float) – distance from the vehicle in front
  • traffic_signal_state (tuple) – (color, time remaining)
Returns:

(steering_angle, gas, brake)

Return type:

tuple

right_of_way(intersection_traffic, len_visible_cars, speed, speed_limit, distance_from_front_car, distance_from_end_node, next_turn_direction, steering_angle=0, gas=0, brake=0)

Encodes the right of way rules at an intersection. For example, a vehicle on a straight road gets preference and goes without stopping, while a vehicle that is turning onto the straight road has to wait.

Parameters:
  • intersection_traffic (dict) – with keys as 1,3,5,7 and values as list of vehicles
  • len_visible_cars (int) – number of vehicles in front within a certain distance
  • speed (float) – speed of the vehicle
  • speed_limit (float) – as determined by traffic rules
  • distance_from_front_car (float) – distance from the vehicle in front
  • distance_from_end_node (float) – distance from the end of the road
  • next_turn_direction (str) – ‘right’ or ‘left’ or ‘straight’
  • steering_angle (float) – angle in radians
  • gas (float) – acceleration to give
  • brake (float) – brake to give
Returns:

(steering_angle, gas, brake)

Return type:

tuple

adas.rules module

class core.lib.adas.rules.Rules(driver)

Implements the safety rules while a vehicle is in motion.

Note

This class is still under development.