CARLA
SimulationState.cpp
Go to the documentation of this file.
1 
3 
4 namespace carla {
5 namespace traffic_manager {
6 
8 
10  KinematicState kinematic_state,
11  StaticAttributes attributes,
12  TrafficLightState tl_state) {
13  actor_set.insert(actor_id);
14  kinematic_state_map.insert({actor_id, kinematic_state});
15  static_attribute_map.insert({actor_id, attributes});
16  tl_state_map.insert({actor_id, tl_state});
17 }
18 
20  return actor_set.find(actor_id) != actor_set.end();
21 }
22 
24  actor_set.erase(actor_id);
25  kinematic_state_map.erase(actor_id);
26  static_attribute_map.erase(actor_id);
27  tl_state_map.erase(actor_id);
28 }
29 
31  actor_set.clear();
32  kinematic_state_map.clear();
33  static_attribute_map.clear();
34  tl_state_map.clear();
35 }
36 
38  kinematic_state_map.at(actor_id) = state;
39 }
40 
42  kinematic_state_map.at(actor_id).hybrid_end_location = location;
43 }
44 
46  // The green-yellow state transition is not notified to the vehicle. This is done to avoid
47  // having vehicles stopped very near the intersection when only the rear part of the vehicle
48  // is colliding with the trigger volume of the traffic light.
49  auto previous_tl_state = GetTLS(actor_id);
50  if (previous_tl_state.at_traffic_light && previous_tl_state.tl_state == TLS::Green) {
51  state.tl_state = TLS::Green;
52  }
53 
54  tl_state_map.at(actor_id) = state;
55 }
56 
58  return kinematic_state_map.at(actor_id).location;
59 }
60 
62  return kinematic_state_map.at(actor_id).hybrid_end_location;
63 }
64 
66  return kinematic_state_map.at(actor_id).rotation;
67 }
68 
70  return kinematic_state_map.at(actor_id).rotation.GetForwardVector();
71 }
72 
74  return kinematic_state_map.at(actor_id).velocity;
75 }
76 
77 float SimulationState::GetSpeedLimit(ActorId actor_id) const {
78  return kinematic_state_map.at(actor_id).speed_limit;
79 }
80 
82  return kinematic_state_map.at(actor_id).physics_enabled;
83 }
84 
85 bool SimulationState::IsDormant(ActorId actor_id) const {
86  return kinematic_state_map.at(actor_id).is_dormant;
87 }
88 
90  return tl_state_map.at(actor_id);
91 }
92 
94  return static_attribute_map.at(actor_id).actor_type;
95 }
96 
98  const StaticAttributes &attributes = static_attribute_map.at(actor_id);
99  return cg::Vector3D(attributes.half_length, attributes.half_width, attributes.half_height);
100 }
101 
102 } // namespace traffic_manager
103 } // namespace carla
void UpdateTrafficLightState(ActorId actor_id, TrafficLightState state)
TrafficLightState GetTLS(const ActorId actor_id) const
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
cg::Vector3D GetDimensions(const ActorId actor_id) const
ActorType GetType(const ActorId actor_id) const
void UpdateKinematicState(ActorId actor_id, KinematicState state)
std::unordered_set< ActorId > actor_set
cg::Location GetLocation(const ActorId actor_id) const
geom::Vector3D Vector3D
Definition: rpc/Vector3D.h:14
bool IsDormant(const ActorId actor_id) const
cg::Rotation GetRotation(const ActorId actor_id) const
float GetSpeedLimit(const ActorId actor_id) const
carla::ActorId ActorId
cg::Location GetHybridEndLocation(const ActorId actor_id) const
bool ContainsActor(ActorId actor_id) const
cg::Vector3D GetHeading(const ActorId actor_id) const
bool IsPhysicsEnabled(const ActorId actor_id) const
void AddActor(ActorId actor_id, KinematicState kinematic_state, StaticAttributes attributes, TrafficLightState tl_state)
void UpdateKinematicHybridEndLocation(ActorId actor_id, cg::Location location)
cg::Vector3D GetVelocity(const ActorId actor_id) const