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;
48 
49  std::pair<bool, float> CollisionHandling(const CollisionHazardData &collision_hazard,
50  const bool tl_hazard,
51  const cg::Vector3D ego_velocity,
52  const cg::Vector3D ego_heading,
53  const float max_target_velocity);
54 
55  bool SafeAfterJunction(const LocalizationData &localization,
56  const bool tl_hazard,
57  const bool collision_emergency_stop);
58 
59  float GetLandmarkTargetVelocity(const SimpleWaypoint& waypoint,
60  const cg::Location vehicle_location,
61  const ActorId actor_id,
62  float max_target_velocity);
63 
64  float GetTurnTargetVelocity(const Buffer &waypoint_buffer,
65  float max_target_velocity);
66 
67  float GetThreePointCircleRadius(cg::Location first_location,
68  cg::Location middle_location,
69  cg::Location last_location);
70 
71 public:
72  MotionPlanStage(const std::vector<ActorId> &vehicle_id_list,
73  const SimulationState &simulation_state,
74  const Parameters &parameters,
75  const BufferMap &buffer_map,
76  TrackTraffic &track_traffic,
77  const std::vector<float> &urban_longitudinal_parameters,
78  const std::vector<float> &highway_longitudinal_parameters,
79  const std::vector<float> &urban_lateral_parameters,
80  const std::vector<float> &highway_lateral_parameters,
81  const LocalizationFrame &localization_frame,
82  const CollisionFrame &collision_frame,
83  const TLFrame &tl_frame,
84  const cc::World &world,
85  ControlFrame &output_array,
86  RandomGeneratorMap &random_devices,
87  const LocalMapPtr &local_map);
88 
89  void Update(const unsigned long index);
90 
91  void RemoveActor(const ActorId actor_id);
92 
93  void Reset();
94 };
95 
96 } // namespace traffic_manager
97 } // 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)
MotionPlanStage(const std::vector< ActorId > &vehicle_id_list, const 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, RandomGeneratorMap &random_devices, const LocalMapPtr &local_map)
std::shared_ptr< InMemoryMap > LocalMapPtr
Definition: ALSM.h:35
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::unordered_map< carla::rpc::ActorId, RandomGenerator > RandomGeneratorMap
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
const SimulationState & simulation_state
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
std::unordered_map< std::string, SharedPtr< client::Actor > > TLMap
std::vector< CollisionHazardData > CollisionFrame