CARLA
LocalizationStage.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <memory>
5 
14 
15 namespace carla {
16 namespace traffic_manager {
17 
18 namespace cc = carla::client;
19 
20 using LocalMapPtr = std::shared_ptr<InMemoryMap>;
21 using LaneChangeSWptMap = std::unordered_map<ActorId, SimpleWaypointPtr>;
23 using Action = std::pair<RoadOption, WaypointPtr>;
24 using ActionBuffer = std::vector<Action>;
25 using Path = std::vector<cg::Location>;
26 using Route = std::vector<uint8_t>;
27 
28 /// This class has functionality to maintain a horizon of waypoints ahead
29 /// of the vehicle for it to follow.
30 /// The class is also responsible for managing lane change decisions and
31 /// modify the waypoint trajectory appropriately.
33 private:
34  const std::vector<ActorId> &vehicle_id_list;
40  // Array of vehicles marked by stages for removal.
41  std::vector<ActorId>& marked_for_removal;
45  using SimpleWaypointPair = std::pair<SimpleWaypointPtr, SimpleWaypointPtr>;
46  std::unordered_map<ActorId, SimpleWaypointPair> vehicles_at_junction_entrance;
48 
50  const cg::Location vehicle_location,
51  const float vehicle_speed,
52  bool force, bool direction);
53 
54  void ExtendAndFindSafeSpace(const ActorId actor_id,
55  const bool is_at_junction_entrance,
56  Buffer &waypoint_buffer);
57 
58  void ImportPath(Path &imported_path,
59  Buffer &waypoint_buffer,
60  const ActorId actor_id,
61  const float horizon_square);
62 
63  void ImportRoute(Route &imported_actions,
64  Buffer &waypoint_buffer,
65  const ActorId actor_id,
66  const float horizon_square);
67 
68 public:
69  LocalizationStage(const std::vector<ActorId> &vehicle_id_list,
70  BufferMap &buffer_map,
71  const SimulationState &simulation_state,
72  TrackTraffic &track_traffic,
73  const LocalMapPtr &local_map,
74  Parameters &parameters,
75  std::vector<ActorId>& marked_for_removal,
76  LocalizationFrame &output_array,
77  RandomGenerator &random_device);
78 
79  void Update(const unsigned long index) override;
80 
81  void RemoveActor(const ActorId actor_id) override;
82 
83  void Reset() override;
84 
85  Action ComputeNextAction(const ActorId &actor_id);
86 
87  ActionBuffer ComputeActionBuffer(const ActorId& actor_id);
88 
89 };
90 
91 } // namespace traffic_manager
92 } // namespace carla
Action ComputeNextAction(const ActorId &actor_id)
std::unordered_map< ActorId, SimpleWaypointPair > vehicles_at_junction_entrance
std::vector< cg::Location > Path
void ExtendAndFindSafeSpace(const ActorId actor_id, const bool is_at_junction_entrance, Buffer &waypoint_buffer)
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition: Memory.h:20
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::unordered_set< ActorId > ActorIdSet
std::unordered_map< ActorId, SimpleWaypointPtr > LaneChangeSWptMap
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
const std::vector< ActorId > & vehicle_id_list
SimpleWaypointPtr AssignLaneChange(const ActorId actor_id, const cg::Location vehicle_location, const float vehicle_speed, bool force, bool direction)
std::unordered_map< carla::ActorId, Buffer > BufferMap
void ImportPath(Path &imported_path, Buffer &waypoint_buffer, const ActorId actor_id, const float horizon_square)
std::pair< RoadOption, WaypointPtr > Action
carla::ActorId ActorId
carla::SharedPtr< cc::Waypoint > WaypointPtr
Definition: InMemoryMap.h:45
std::vector< uint8_t > Route
void RemoveActor(const ActorId actor_id) override
void Update(const unsigned long index) override
Stage type interface.
Definition: Stage.h:12
std::vector< LocalizationData > LocalizationFrame
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
void ImportRoute(Route &imported_actions, Buffer &waypoint_buffer, const ActorId actor_id, const float horizon_square)
std::pair< SimpleWaypointPtr, SimpleWaypointPtr > SimpleWaypointPair
LocalizationStage(const std::vector< ActorId > &vehicle_id_list, BufferMap &buffer_map, const SimulationState &simulation_state, TrackTraffic &track_traffic, const LocalMapPtr &local_map, Parameters &parameters, std::vector< ActorId > &marked_for_removal, LocalizationFrame &output_array, RandomGenerator &random_device)
This class has functionality to maintain a horizon of waypoints ahead of the vehicle for it to follow...
std::vector< Action > ActionBuffer
ActionBuffer ComputeActionBuffer(const ActorId &actor_id)