umich_sim.sim_backend.vehicle_control package#

Submodules#

umich_sim.sim_backend.vehicle_control.base_controller module#

Backend - Controller Class Created on Tue February 15, 2022

Summary: The Controller class is a static base class that implements control over the vehicles in the

Simulation. This class provides the basic interface and functions that all Controller classes can use. Ego, Intersection, and Freeway controllers are derived from this base class

class umich_sim.sim_backend.vehicle_control.base_controller.VehicleController#

Bases: object

static generate_path(current_vehicle: Vehicle, starting_point: Waypoint, ending_point: Waypoint) Tuple[List[Waypoint], List[Waypoint]]#

Calculates the shortest trajectory between the starting endpoint and ending waypoint of the Vehicle’s route.

Uses A* pathfinding algorithm to determine the shortest path between the starting waypoint and the ending waypoint. All paths will follow Carla’s autogenerated waypoints that define the valid road network. The path is guaranteed to take the shortest number of jumps between waypoints, however there is no guarantee that the path will be the shortest in terms of absolute distance.

Parameters:
  • current_vehicle – the Vehicle object that the path needs to be generated for

  • starting_point – the carla.Waypoint object that the vehicle will be starting at

  • ending_point – the carla.Waypoint object that the vehicle will be ending at

Returns:

None

static get_vehicles_current_waypoint(vehicle: Vehicle) Waypoint#

Gets an OpenDrive waypoint located at the Vehicle’s current location.

Parameters:

vehicle – the Vehicle whose current waypoint is desired

Returns:

a carla.Waypoint located at the vehicle’s current location

static steering_control(current_vehicle: Vehicle) Tuple[float, bool]#

Implements path following using the Pure Pursuit Path Tracking algorithm.

Link to a paper on the subject can be found here: https://www.ri.cmu.edu/publications/implementation-of-the-pure-pursuit-path-tracking-algorithm/ Determines what steering angle the vehicle needs to remain on the path outlined by its waypoints. Chooses a lookahead distance based on the vehicle’s current speed and identifies the waypoint that is closest to that lookahead distance. Then, calculates the curve that connects the Vehicle’s current location to that destination waypoint. The inverse tangent of the curve can then be taken to determine the steering angle needed.

Parameters:

current_vehicle – a Vehicle object representing the vehicle to be controlled

Returns:

a Tuple where the first element is a float representing the steering angle in radians (bounded between -1 and 1) and the second element is if the Vehicle has reached the end of the path

static throttle_control(current_vehicle: Vehicle) float#

Applies throttle control to the vehicle based on its current setting.

The different modes that a vehicle can operate in are a “target_location”, “target_speed”, or “target_distance”.

In target_location mode, the vehicle will accelerate maintain its target speed until it is within a certain distance of its target location. Then, it will brake to smoothly stop at that location. This mode is activated if the current_vehicle has a valid target location and the vehicle is within its pre-defined breaking distance.

In target_distance mode, the vehicle will accelerate or decelerate as necessary to maintain a target distance from the vehicle in-front of it. This mode is activated if there is a vehicle in front of the current vehicle within 1.2 times the current vehicle’s safety distance. This mode can never be activated for a lead vehicle.

In target_speed mode, the vehicle will accelerate up to its target speed and then apply the acceleration necessary to maintain that speed. This mode will be activated if neither of the other modes apply.

Parameters:

current_vehicle – the Vehicle object to calculate the throttle for

Returns:

a float representing the throttle to be applied to the vehicle (between -1 and 1)

static update_control(current_vehicle: Vehicle) None#

Abstract function that dictates how a derived Controller class should update the Vehicles control.

All derived controller classes must implement this method. The update_control method takes in a vehicle and determines what control parameters should be passed to it to update its acceleration and steering in the Carla simulation. This function will call apply_control on the current vehicle to steer the vehicle in the correct direction.

Parameters:

current_vehicle – the Vehicle object to which updated control needs to be applied

Returns:

None

world: World = None#

umich_sim.sim_backend.vehicle_control.ego_controller module#

Backend - EgoController Class Created on Tue February 15, 2022

Summary: The EgoController class inherits from the base Controller class. It implements control

specifically for the Ego vehicle. Ego vehicles must be able to be driven both autonomously and manually.

class umich_sim.sim_backend.vehicle_control.ego_controller.EgoController#

Bases: object

static update_control(current_vehicle: Vehicle, experiment_type: ExperimentType) None#

Implementation of the update_control class for the Ego Vehicle type

Applies control rules for the Ego Vehicle type. An Ego Vehicle can either be manually or automatically driven. A manual Ego Vehicle will be controlled by the user either using WASD or the arrow keys. An automatic Ego Vehicle will use either the Freeway or Intersection controller to control the Vehicle depending on the experiment type

Parameters:
  • current_vehicle – the Vehicle object to which updated control needs to be applied

  • experiment_type – the current experiment type as a string, either “freeway” or “intersection”

Returns:

None

umich_sim.sim_backend.vehicle_control.freeway_controller module#

Backend - FreewayController Class Created on Tue February 15, 2022

Summary: The FreewayController class inherits from the base Controller class. It implements control

from all the non-ego vehicles that are operating in a Freeway experiment type. These vehicles do not need to manage traffic lights, however they must manage distance to the vehicles in-front and to the side of them.

umich_sim.sim_backend.vehicle_control.freeway_controller.freeway_control(current_vehicle: Vehicle) None#

Updates the control for a vehicle that is operating in an Freeway experiment.

TODO: Update this documentation once the function is better written. TODO: Consolidate duplicate code with IntersectionController

Parameters:

current_vehicle

Returns:

umich_sim.sim_backend.vehicle_control.intersection_controller module#

Backend - IntersectionController Class Created on Tue February 15, 2022

Summary: The IntersectionController class inherits from the base Controller class. It implements control

from all the non-ego vehicles that are operating in an Intersection experiment type. These vehicles do need to manage traffic lights, and they must also manage distance to the vehicles in-front and to the side of them.

umich_sim.sim_backend.vehicle_control.intersection_controller.intersection_control(current_vehicle: Vehicle) None#

Updates the control for a vehicle that is operating in an Intersection experiment.

TODO: Update this documentation once the function is better written.

Parameters:

current_vehicle

Returns:

None

Module contents#