10namespace traffic_manager {
12using namespace constants::VehicleLight;
13using namespace constants::WorldInfoRefresh;
16 const std::vector<ActorId> &vehicle_id_list,
21 : vehicle_id_list(vehicle_id_list),
22 buffer_map(buffer_map),
23 parameters(parameters),
25 control_frame(control_frame) {}
28 const bool any_vehicle_updates_lights = std::any_of(
31 [
this](
const ActorId actor_id) { return parameters.GetUpdateVehicleLights(actor_id); });
32 if (!any_vehicle_updates_lights) {
42 if (synchronous_mode ||
50 if (synchronous_mode ||
64 if (vls.first == actor_id) {
65 vls.second = light_state;
79 bool brake_lights =
false;
80 bool left_turn_indicator =
false;
81 bool right_turn_indicator =
false;
82 bool position =
false;
83 bool low_beam =
false;
84 bool high_beam =
false;
85 bool fog_lights =
false;
88 bool found_light_state =
false;
90 if (vls.first == actor_id) {
91 light_states = vls.second;
92 found_light_state =
true;
97 if (!found_light_state) {
112 cg::Location front_location = waypoint_buffer.front()->GetLocation();
115 if (waypoint->CheckJunction()) {
116 RoadOption target_ro = waypoint->GetRoadOption();
128 if (
auto* maybe_ctrl = std::get_if<carla::rpc::Command::ApplyVehicleControl>(&
control_frame[
cc].command)) {
130 if (ctrl.
actor == actor_id) {
172 if (left_turn_indicator)
177 if (right_turn_indicator)
203 if (new_light_states != light_states) {
215 [actor_id](
const rpc::VehicleLightStateList::value_type &light_state) {
216 return light_state.first == actor_id;
rpc::WeatherParameters GetWeather() const
Retrieve the weather parameters currently active in the world.
rpc::VehicleLightStateList GetVehiclesLightStates() const
Returns a list of pairs where the firts element is the vehicle ID and the second one is the light sta...
bool IsWeatherEnabled() const
Query if the Weather is enabled or not.
bool GetUpdateVehicleLights(const ActorId &actor_id) const
Method to get if the vehicle lights should be updates automatically.
rpc::VehicleLightStateList all_light_states
All vehicle light states.
void RemoveActor(const ActorId actor_id) override
void SetCachedLightState(const ActorId actor_id, const rpc::VehicleLightState::flag_type light_state)
bool light_states_refreshed
double last_weather_update
double last_light_states_update
Simulation time of the last refresh of each cached world query.
rpc::WeatherParameters weather
Current weather parameters.
ControlFrame & control_frame
const Parameters & parameters
const BufferMap & buffer_map
VehicleLightStage(const std::vector< ActorId > &vehicle_id_list, const BufferMap &buffer_map, const Parameters ¶meters, const cc::World &world, ControlFrame &control_frame)
std::unordered_set< ActorId > missing_from_last_refresh
Vehicles the server left out of the list it last returned.
const std::vector< ActorId > & vehicle_id_list
void UpdateWorldInfo(const double current_time, const bool synchronous_mode)
Synchronous mode refreshes every step.
void Update(const unsigned long index) override
bool is_weather_enabled
Weather enabled.
static const float SUN_ALTITUDE_DEGREES_BEFORE_DAWN
static const float MAX_DISTANCE_LIGHT_CHECK
static const float SUN_ALTITUDE_DEGREES_JUST_BEFORE_SUNSET
static const float FOG_DENSITY_THRESHOLD
static const float SUN_ALTITUDE_DEGREES_JUST_AFTER_DAWN
static const float HEAVY_PRECIPITATION_THRESHOLD
static const float SUN_ALTITUDE_DEGREES_AFTER_SUNSET
static const double VEHICLE_LIGHT_STATES_REFRESH_PERIOD
bool IsRefreshDue(const double now, const double last, const double period)
Also true when the clock jumps backwards (new episode) or on NaN, so an unusable clock refreshes rath...
static const double WEATHER_REFRESH_PERIOD
bool IsEarlyRefreshDue(const bool refreshed_this_step, const bool missing_from_the_last_refresh)
A vehicle the server already omitted from a fresh list (dormant on a large map) must not re-arm the u...
std::deque< std::shared_ptr< SimpleWaypoint > > Buffer
std::unordered_map< carla::ActorId, Buffer > BufferMap
std::vector< carla::rpc::Command > ControlFrame
std::shared_ptr< SimpleWaypoint > SimpleWaypointPtr
This file contains definitions of common data structures used in traffic manager.