CARLA
MotionPlanStage.h
Go to the documentation of this file.
1 
2 /// This file has functionality for motion planning based on information
3 /// from localization, collision avoidance and traffic light response.
4 
5 #pragma once
6 
15 
16 namespace carla {
17 namespace traffic_manager {
18 
19 using LocalMapPtr = std::shared_ptr<InMemoryMap>;
20 using TLMap = std::unordered_map<std::string, SharedPtr<client::Actor>>;
21 
23 private:
24  const std::vector<ActorId> &vehicle_id_list;
29  // PID paramenters for various road conditions.
30  const std::vector<float> urban_longitudinal_parameters;
31  const std::vector<float> highway_longitudinal_parameters;
32  const std::vector<float> urban_lateral_parameters;
33  const std::vector<float> highway_lateral_parameters;
36  const TLFrame &tl_frame;
37  const cc::World &world;
38  // Structure holding the controller state for registered vehicles.
39  std::unordered_map<ActorId, StateEntry> pid_state_map;
40  // Structure to keep track of duration between teleportation
41  // in hybrid physics mode.
42  std::unordered_map<ActorId, cc::Timestamp> teleportation_instance;
47 
48  std::pair<bool, float> CollisionHandling(const CollisionHazardData &collision_hazard,
49  const bool tl_hazard,
50  const cg::Vector3D ego_velocity,
51  const cg::Vector3D ego_heading,
52  const float max_target_velocity);
53 
54  bool SafeAfterJunction(const LocalizationData &localization,
55  const bool tl_hazard,
56  const bool collision_emergency_stop);
57 
58  float GetLandmarkTargetVelocity(const SimpleWaypoint& waypoint,
59  const cg::Location vehicle_location,
60  const ActorId actor_id,
61  float max_target_velocity);
62 
63  float GetTurnTargetVelocity(const Buffer &waypoint_buffer,
64  float max_target_velocity);
65 
66  float GetThreePointCircleRadius(cg::Location first_location,
67  cg::Location middle_location,
68  cg::Location last_location);
69 
70 public:
71  MotionPlanStage(const std::vector<ActorId> &vehicle_id_list,
72  SimulationState &simulation_state,
73  const Parameters &parameters,
74  const BufferMap &buffer_map,
75  TrackTraffic &track_traffic,
76  const std::vector<float> &urban_longitudinal_parameters,
77  const std::vector<float> &highway_longitudinal_parameters,
78  const std::vector<float> &urban_lateral_parameters,
79  const std::vector<float> &highway_lateral_parameters,
80  const LocalizationFrame &localization_frame,
81  const CollisionFrame &collision_frame,
82  const TLFrame &tl_frame,
83  const cc::World &world,
84  ControlFrame &output_array,
85  RandomGenerator &random_device,
86  const LocalMapPtr &local_map);
87 
88  void Update(const unsigned long index);
89 
90  void RemoveActor(const ActorId actor_id);
91 
92  void Reset();
93 };
94 
95 } // namespace traffic_manager
96 } // namespace carla
std::vector< carla::rpc::Command > ControlFrame
const std::vector< float > highway_longitudinal_parameters
void Update(const unsigned long index)
const std::vector< ActorId > & vehicle_id_list
std::vector< bool > TLFrame
float GetLandmarkTargetVelocity(const SimpleWaypoint &waypoint, const cg::Location vehicle_location, const ActorId actor_id, float max_target_velocity)
std::shared_ptr< InMemoryMap > LocalMapPtr
Definition: ALSM.h:36
This class holds the state of all the vehicles in the simlation.
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
void RemoveActor(const ActorId actor_id)
std::unordered_map< ActorId, cc::Timestamp > teleportation_instance
std::unordered_map< carla::ActorId, Buffer > BufferMap
std::unordered_map< ActorId, StateEntry > pid_state_map
float GetTurnTargetVelocity(const Buffer &waypoint_buffer, float max_target_velocity)
This is a simple wrapper class on Carla&#39;s waypoint object.
carla::ActorId ActorId
float GetThreePointCircleRadius(cg::Location first_location, cg::Location middle_location, cg::Location last_location)
const std::vector< float > highway_lateral_parameters
const LocalizationFrame & localization_frame
const std::vector< float > urban_longitudinal_parameters
bool SafeAfterJunction(const LocalizationData &localization, const bool tl_hazard, const bool collision_emergency_stop)
Stage type interface.
Definition: Stage.h:12
std::vector< LocalizationData > LocalizationFrame
std::pair< bool, float > CollisionHandling(const CollisionHazardData &collision_hazard, const bool tl_hazard, const cg::Vector3D ego_velocity, const cg::Vector3D ego_heading, const float max_target_velocity)
const std::vector< float > urban_lateral_parameters
MotionPlanStage(const std::vector< ActorId > &vehicle_id_list, SimulationState &simulation_state, const Parameters &parameters, const BufferMap &buffer_map, TrackTraffic &track_traffic, const std::vector< float > &urban_longitudinal_parameters, const std::vector< float > &highway_longitudinal_parameters, const std::vector< float > &urban_lateral_parameters, const std::vector< float > &highway_lateral_parameters, const LocalizationFrame &localization_frame, const CollisionFrame &collision_frame, const TLFrame &tl_frame, const cc::World &world, ControlFrame &output_array, RandomGenerator &random_device, const LocalMapPtr &local_map)
std::unordered_map< std::string, SharedPtr< client::Actor > > TLMap
std::vector< CollisionHazardData > CollisionFrame