IntersectionControl

Algorithm API

class IntersectionManager(intersection_id: str, environment: intersection_control.core.environment.environment.Environment)
get_height() float

Return the height of the intersection

Returns

The height of the intersection in metres

get_id() str

Returns the intersection’s id

Returns

intersection id

get_position() Tuple[float, float]

Return the position of the intersection

Returns

(x,y) the position of the intersection

get_trajectories() Dict[str, intersection_control.core.environment.intersection_handler.Trajectory]

Return all the possible trajectories through the intersection

Returns

A dictionary mapping trajectory ids to trajectories

get_width() float

Return the width of the intersection

Returns

The width of the intersection in metres

set_traffic_light_phase(phase: Tuple[Set[str], Set[str], Set[str]])

Set the traffic lights to the phase described by phase

Parameters

phase (Tuple[Set[str], Set[str], Set[str]]) – A tuple of length 3: (Green, Yellow, Red) where each of Green, Yellow and Red are sets of trajectory IDs such that all the trajectories in Red will be shown a red light, and the same for Yellow and Green

abstract step()

Called repeatedly after some time has elapsed

Can assume that the state of the environment has changed since step was last called. This is where the main behaviour of the intersection manager should be implemented

class Vehicle(vehicle_id: str, environment: intersection_control.core.environment.environment.Environment)
approaching() Optional[str]

Returns the id of the intersection the vehicle is approaching, or None if it is not approaching an intersection

Returns

Either the ID of the intersection being approached, or None

departing() Optional[str]

Returns the id of the intersection the vehicle is departing, or None if it is not departing an intersection

Returns

Either the ID of the intersection being departed, or None

destroy()

Called when the vehicle is removed from the environment

Can optionally be implemented to do some clean-up functions if needed. If this isn’t needed, this method can simply be ignored.

get_acceleration() float

Returns the current acceleration of the vehicle

Returns

The acceleration of the vehicle in m/s^2

get_direction() float

Returns the direction the given vehicle is currently facing in radians

The positive horizontal axis is taken to have a direction of 0, and the angle increases as the vehicle rotates clockwise like so:

      pi/2
       ^
       |
pi <---+---> 0
       |
       v
    -pi/2
Returns

The direction of the vehicle in radians

get_driving_distance() float

Returns the driving distance of the vehicle to the end of the current edge/road

TODO: This is not very clean - seems quite particular to the QBIM algorithm…

Worth thinking about whether there is a better, more general way of providing the information required to figure this out.

Returns

The driving distance in metres

get_id() str

Return the vehicle id

Returns

vehicle id

get_length() float

Returns the length of the vehicle

Returns

Length of the vehicle in metres

get_max_acceleration() float

Returns the maximum acceleration possibility of the vehicle

Returns

The maximum acceleration in m/s^2

get_max_deceleration() float

Returns the maximum deceleration possibility of the given vehicle

Returns

The maximum deceleration in m/s^2

get_position() Tuple[float, float]

Returns the current position of the vehicle

Returns

The (x,y) position of the vehicle

get_speed() float

Returns the current speed of the vehicle

Returns

The speed in metres/second

get_speed_limit() float

Returns the maximum speed the vehicle should be travelling at

This will usually be determined by the speed limit of the road the vehicle is currently on

Returns

The speed limit

get_trajectory() str

Returns the ID of the trajectory the vehicle is planning to take through the next intersection

TODO: Rethink this… See the TODO comment in the SUMOIntersectionHandler

class

Returns

Trajectory ID

get_width() float

Returns the width of the given vehicle

Returns

Width of the vehicle in metres

in_intersection() bool

Returns True iff the vehicle is currently inside an intersection

Returns

True iff the vehicle is currently inside an intersection

set_desired_speed(to: float)

Sets the desired speed of the given vehicle

Parameters

to – The speed (in m/s) you would like the desired speed to be set to. If set to -1, the vehicle’s speed will be controlled by the environment.

abstract step()

Called repeatedly after some time has elapsed

Can assume that the state of the environment has changed since step was last called. This is where the main behaviour of the vehicle should be implemented