opencda.core.application.platooning package¶
Submodules¶
opencda.core.application.platooning.fsm module¶
Finite State Machine
- class opencda.core.application.platooning.fsm.FSM(value)¶
Bases:
enum.Enum
The finite state machine class for platooning. These classes are used to indicate the current status of the CAV during platooning.
- SEARCHING¶
The vehicle is not in any platoon and currently searching one to join.
- Type
int
- OPEN_GAP¶
The platoon member is increasing the gap for other vehicle to merge.
- Type
int
- MOVE_TO_POINT¶
The merging vehicle is moving to the meeting points for joining.
- Type
int
- JOINING¶
The merging vehicle is operating the joining maneuver(lane change).
- Type
int
- MAINTINING¶
The platoon member is following the leader and maintain the time gap.
- Type
int
- BACK_JOINING¶
The merging vehicle is in back-join state.
- Type
int
- CUT_IN_TO_BACK¶
The merging vehicle abandons cut-in-join and switch to back join.
- Type
int
- JOINING_FINISHED¶
Indicate the joining finished and the vehicle will switch to maintaining state.
- Type
int
- LEADING_MODE¶
The vehicle is the platoon leader.
- Type
int
- ABONDON¶
Current joining is abandoned.
- DISABLE¶
V2X is not available and thus won’t join any platoon.
- ABONDON = 10¶
- BACK_JOINING = 5¶
- CUT_IN_TO_BACK = 6¶
- DISABLE = 11¶
- FRONT_JOINING = 7¶
- JOINING = 3¶
- JOINING_FINISHED = 8¶
- LEADING_MODE = 9¶
- MAINTINING = 4¶
- MOVE_TO_POINT = 2¶
- OPEN_GAP = 1¶
- SEARCHING = 0¶
opencda.core.application.platooning.platoon_behavior_agent module¶
Behavior manager for platooning specifically
- class opencda.core.application.platooning.platoon_behavior_agent.PlatooningBehaviorAgent(vehicle, vehicle_manager, v2x_manager, behavior_yaml, platoon_yaml, carla_map)¶
Bases:
opencda.core.plan.behavior_agent.BehaviorAgent
Platoon behavior agent that inherits the single vehicle behavior agent.
- Parameters
vehicle (carla.Vehicle) – The carla vehicle.
vehicle_manager (opencda object) – The vehicle manager, used when joining platoon finished.
v2x_manager (opencda object) – Used to received and deliver information.
behavior_yaml (dict) – The configuration dictionary for BehaviorAgent.
platoon_yaml (dict.) – The configuration dictionary for platoon behavior.
carla_map (carla.Map) – The HD Map used in the simulation.
- vehicle_manager¶
The weak reference of the vehicle manager, used when joining platoon finished.
- Type
opencda object
- v2x_manager¶
The weak reference of the v2x_manager
- Type
opencda object
- debug_helper¶
- A debug helper used to record the driving performance
during platooning
- Type
opencda Object
- inter_gap¶
The desired time gap between each platoon member.
- Type
float
- calculate_gap(distance)¶
Calculate the current vehicle and frontal vehicle’s time/distance gap.
- Parameters
distance (float) – Distance between the ego vehicle and frontal vehicle.
- joining_finish_manager(insert_vehicle='front')¶
Called when a joining is finish to update the platoon manager list.
- Parameters
insert_vehicle (string) – indicate use the front or rear vehicle index to update the platoon manager list.
- platooning_following_manager(inter_gap)¶
Car following behavior in platooning with gap regulation.
- Parameters
inter_gap (float) – The gap designed for platooning.
- platooning_merge_management(frontal_vehicle_vm)¶
Merge the vehicle into the platooning.
- Parameters
frontal_vehicle_vm (opencda object) – The vehivle manager of the front vehicle.
- Returns
target_speed (float) – The target speed for ego vehicle.
target_waypoint (carla.waypoint) – The target waypoint for ego vehicle.
- run_step(target_speed=None, collision_detector_enabled=True, lane_change_allowed=True)¶
Run a single step for navigation under platooning agent. Finite state machine is used to switch between different platooning states.
- Parameters
target_speed (float) – Target speed in km/h
collision_detector_enabled (bool) – Whether collision detection enabled.
lane_change_allowed (bool) – Whether lane change is allowed.
- run_step_back_joining()¶
Back-joining Algorithm.
- Returns
target_speed (float) – The target speed for ego vehicle.
target_waypoint (carla.waypoint) – The target waypoint for ego vehicle.
- run_step_cut_in_joining()¶
Check if the vehicle has been joined successfully.
- Returns
target_speed (float) – The target speed for ego vehicle.
target_waypoint (carla.waypoint) – The target waypoint for ego vehicle.
- run_step_cut_in_move2point()¶
The vehicle is trying to get to the move in point.
- Returns
target_speed (float) – The target speed for ego vehicle.
target_waypoint (carla.waypoint) – The target waypoint for ego vehicle.
- run_step_front_joining()¶
Front-joining algorithm.
- Returns
target_speed (float) – The target speed for ego vehicle.
target_waypoint (carla.waypoint) – The target waypoint for ego vehicle.
- run_step_maintaining()¶
Next step behavior planning for speed maintaining.
- Returns
target_speed (float) – The target speed for ego vehicle.
target_waypoint (carla.waypoint) – The target waypoint for ego vehicle.
- run_step_open_gap()¶
Open gap for cut-in vehicle.
- Returns
target_speed (float) – The target speed for ego vehicle.
target_waypoint (carla.waypoint) – The target waypoint for ego vehicle.
- update_information(ego_pos, ego_speed, objects)¶
Update the perception and localization information to the behavior agent.
- Parameters
ego_pos (carla.Transform) – Ego position from localization module.
ego_speed (float) – km/h, ego speed.
objects (dict) – Objects detection results from perception module.
opencda.core.application.platooning.platoon_debug_helper module¶
Analysis + visualization functions for platooning
- class opencda.core.application.platooning.platoon_debug_helper.PlatoonDebugHelper(actor_id)¶
Bases:
opencda.core.plan.planer_debug_helper.PlanDebugHelper
This class aims to save statistics for platoon behaviour
- Parameters
actor_id (int) – The actor ID of the selected vehcile.
- time_gap_list¶
The list containing intra-time-gap(s) of all time-steps.
- Type
list
- dist_gap_list¶
The list containing distance gap(s) of all time-steps.
- Type
list
- update(ego_speed, ttc, time_gap=None, dist_gap=None)¶
Update the platoon related vehicle information.
- Parameters
ego_speed (float) – Ego vehcile speed.
ttc (float) – Ego vehicle time-to-collision.
time_gap (float) – Ego vehicle time gap with the front vehicle.
dist_gap (float) – Ego vehicle distance gap with front vehicle.
opencda.core.application.platooning.platooning_manager module¶
Platooning Manager
- class opencda.core.application.platooning.platooning_manager.PlatooningManager(config_yaml, cav_world)¶
Bases:
object
Platoon manager. Used to manage all vehicle managers inside the platoon.
- Parameters
config_yaml (dict) – The configuration dictionary for platoon.
cav_world (opencda object) – CAV world that stores all CAV information.
- pmid¶
The platooning manager ID.
- Type
int
- vehicle_manager_list¶
A list of all vehciel managers within the platoon.
- Type
list
- destination¶
The destiantion of the current plan.
- Type
carla.location
- center_loc¶
The center location of the platoon.
- Type
carla.location
- leader_target_speed¶
The speed of the leader vehicle.
- Type
float
- origin_leader_target_speed¶
The original planned target speed of the platoon leader.
- Type
float
- recover_speed_counter¶
The counter that record the number of speed recovery attempts.
- Type
int
- add_member(vehicle_manager, leader=False)¶
Add memeber to the current platooning
- Parameters
leader (boolean) – Indicator of whether this cav is a leader.
vehicle_manager (opencda object) – The vehicle manager class.
- cal_center_loc()¶
Calculate and update center location of the platoon.
- destroy()¶
Destroy platoon vehicles actors inside simulation world.
- evaluate()¶
Used to save all members’ statistics.
- Returns
figure (matplotlib.figure) – The figure drawing performance curve passed back to save to the disk.
perform_txt (str) – The string that contains all evaluation results to print out.
- reset_speed()¶
After joining request accepted for certain steps, the platoon will return to the origin speed.
- response_joining_request(request_loc)¶
Identify whether to accept the joining request based on capacity.
- Parameters
request_loc (carla.Location)) – Request vehicle location.
- Returns
response (boolean)
Indicator of whether the joining request is accepted.
- run_step()¶
Run one control step for each vehicles.
- Returns
control_list – The control command list for all vehicles.
- Return type
list
- set_destination(destination)¶
Set desination of the vehicle managers in the platoon.
- set_lead(vehicle_manager)¶
Set the leader of the platooning
- Parameters
vehicle_manager (opencda object) – The vehicle manager class.
- set_member(vehicle_manager, index, lead=False)¶
Set member at specific index
- Parameters
lead (boolean) – Indicator of whether this cav is a leader.
vehicle_manager (opencda object) – The vehicle manager class.
index (int) – The platoon index of the current vehicle.
- update_information()¶
Update CAV world information for every member in the list.
- update_member_order()¶
Update the members’ front and rear vehicle. This should be called whenever new member added to the platoon list.
opencda.core.application.platooning.platooning_plugin module¶
Platooning plugin for communication and track FSM
- class opencda.core.application.platooning.platooning_plugin.PlatooningPlugin(search_range, cda_enabled)¶
Bases:
object
Platooning plugin inside the V2X manager.
- Parameters
search_range (float) – The search range of the communication equipment.
cda_enabled (boolean) – Whether connectivity is supported.
- leader¶
Boolean indicator of the platoon leader status.
- Type
boolean
- platooning_object¶
The current platoon object.
- Type
opencda object
- platooning_id¶
The current platoon ID.
- Type
int
- in_id¶
The position in the platoon.
- Type
int
- status¶
The current platooning status.
- Type
enum
- ego_pos¶
The current position (i.e., location and rotation) of the ego vehicle.
- Type
carla.transformation
- ego_spd¶
The current speed(km/h) of the ego vehicle.
- Type
float
- platooning_blacklist¶
The platoon in the black list won’t be considered again.
- Type
list
- front_vehicle¶
The front vehicle manager of the ego vehicle.
- Type
opencda object
- rear_vechile¶
The rear vehicle manager of the ego vehicle.
- Type
opencda object
- match_platoon(cav_nearby)¶
A naive way to find the best position to join a platoon
- Parameters
cav_nearby (dict) – The dictionary contains all the cavs nearby.
- Returns
matched (bool) – The boolean indicator of matching result.
min_index (int) – The minimum index inside the selected platoon.
platoon_vehicle_list (list) – The list of platoon members.
- reset()¶
Reset to the origin status.
- search_platoon(ego_loc, cav_nearby)¶
Search platoon candidate in the range
- Parameters
ego_loc (carla.Location) – Ego vehicle current position.
cav_nearby (dict) – The dictionary contains all the cavs nearby.
- Returns
pmid (int) – Platoon manager ID.
pm (opencda object) – Platoon manager ID.
- set_platoon(in_id, platooning_object=None, platooning_id=None, leader=False)¶
Set platooning status.
- Parameters
in_id (int) – Inner platoon ID of the vehicle.
platooning_object (opencda object) – The current platoon object.
platooning_id (int) – The current platoon ID.
leader (bool) – Boolean indicator of the platoon leader status.
- set_status(status)¶
Set FSM status
- Parameters
status (str) – The current platooning status.
- update_info(ego_pos, ego_spd)¶
Update the ego position and speed
- Parameters
ego_pos (carla.Transform) – Ego pose.
ego_spd (float) – Ego speed(km/h).