8 #include <ad/map/access/Operation.hpp> 9 #include <ad/rss/state/ProperResponse.hpp> 10 #include <ad/rss/world/Velocity.hpp> 39 ": registering of the actor constellation callback has to be done before start listening. Register has " 58 if (vehicle ==
nullptr) {
64 float max_steer_angle_deg = 0.f;
65 for (
auto const &wheel : vehicle->GetPhysicsControl().GetWheels()) {
66 max_steer_angle_deg = std::max(max_steer_angle_deg, wheel.max_steer_angle);
68 auto max_steering_angle = max_steer_angle_deg *
static_cast<float>(M_PI) / 180.0f;
72 std::string
const open_drive_content = map->GetOpenDrive();
74 auto mapInitializationResult = ::ad::map::access::initFromOpenDriveContent(
76 ::ad::map::landmark::TrafficLightType::LEFT_STRAIGHT_RED_YELLOW_GREEN);
78 if (!mapInitializationResult) {
86 _rss_check = std::make_shared<::carla::rss::RssCheck>(max_steering_angle);
92 auto self = boost::static_pointer_cast<
RssSensor>(shared_from_this());
97 [ cb = std::move(callback), weak_self =
WeakPtr<RssSensor>(
self) ](
const auto &snapshot) {
98 auto self = weak_self.lock();
99 if (
self !=
nullptr) {
100 self->TickRssSensor(snapshot.GetTimestamp(), cb);
116 _rss_check->GetLogger()->info(
"RssSensor stopping");
124 _rss_check->GetLogger()->info(
"RssSensor delete checker");
128 if (map_initialization_counter_value == 0u) {
130 ::ad::map::access::cleanup();
141 if (log_level < spdlog::level::n_levels) {
142 _rss_check->SetLogLevel(spdlog::level::level_enum(log_level));
152 if (map_log_level < spdlog::level::n_levels) {
153 _rss_check->SetMapLogLevel(spdlog::level::level_enum(map_log_level));
161 return default_vehicle_dynamics;
165 log_error(
GetDisplayId(),
": Actor constellation callback registered. GetEgoVehicleDynamics has no effect.");
166 return default_vehicle_dynamics;
169 return _rss_check->GetDefaultActorConstellationCallbackEgoVehicleDynamics();
179 log_error(
GetDisplayId(),
": Actor constellation callback registered. SetEgoVehicleDynamics has no effect.");
183 _rss_check->SetDefaultActorConstellationCallbackEgoVehicleDynamics(ego_dynamics);
190 return default_vehicle_dynamics;
194 log_error(
GetDisplayId(),
": Actor constellation callback registered. GetOtherVehicleDynamics has no effect.");
195 return default_vehicle_dynamics;
198 return _rss_check->GetDefaultActorConstellationCallbackOtherVehicleDynamics();
208 log_error(
GetDisplayId(),
": Actor constellation callback registered. SetOtherVehicleDynamics has no effect.");
212 _rss_check->SetDefaultActorConstellationCallbackOtherVehicleDynamics(other_vehicle_dynamics);
219 return default_pedestrian_dynamics;
223 log_error(
GetDisplayId(),
": Actor constellation callback registered. GetPedestrianDynamics has no effect.");
224 return default_pedestrian_dynamics;
227 return _rss_check->GetDefaultActorConstellationCallbackPedestrianDynamics();
237 log_error(
GetDisplayId(),
": Actor constellation callback registered. SetPedestrianDynamics has no effect.");
241 _rss_check->SetDefaultActorConstellationCallbackPedestrianDynamics(pedestrian_dynamics);
248 return default_road_boundaries_mode;
260 _rss_check->SetRoadBoundariesMode(road_boundaries_mode);
269 _rss_check->AppendRoutingTarget(routing_target);
275 return std::vector<::carla::geom::Transform>();
311 if ( settings.synchronous_mode ) {
312 _rss_check->GetLogger()->trace(
"RssSensor[{}] sync-tick", timestamp.
frame);
317 _rss_check->GetLogger()->trace(
"RssSensor[{}] async-tick", timestamp.
frame);
322 _rss_check->GetLogger()->debug(
"RssSensor[{}] tick dropped", timestamp.
frame);
330 double const time_since_epoch_check_start_ms =
331 std::chrono::duration<double, std::milli>(std::chrono::system_clock::now().time_since_epoch()).count();
339 ::ad::rss::state::ProperResponse response;
340 ::ad::rss::state::RssStateSnapshot rss_state_snapshot;
341 ::ad::rss::situation::SituationSnapshot situation_snapshot;
342 ::ad::rss::world::WorldModel world_model;
344 auto const result =
_rss_check->CheckObjects(timestamp, actors,
GetParent(), response, rss_state_snapshot,
345 situation_snapshot, world_model, ego_dynamics_on_route);
347 double const time_since_epoch_check_end_ms =
348 std::chrono::duration<double, std::milli>(std::chrono::system_clock::now().time_since_epoch()).count();
349 auto const delta_time_ms = time_since_epoch_check_end_ms - time_since_epoch_check_start_ms;
350 _rss_check->GetLogger()->debug(
"RssSensor[{}] response: S:{}->E:{} DeltaT:{}", timestamp.
frame,
351 time_since_epoch_check_start_ms, time_since_epoch_check_end_ms,
359 agv_time += run_time;
361 agv_time /= _rss_check_timings.size();
362 _rss_check->GetLogger()->info(
"RssSensor[{}] runtime {} avg {}", timestamp.
frame, delta_time_ms, agv_time);
366 response, rss_state_snapshot, situation_snapshot, world_model,
367 ego_dynamics_on_route));
368 }
catch (
const std::exception &e) {
369 _rss_check->GetLogger()->error(
"RssSensor[{}] tick exception", timestamp.
frame);
372 _rss_check->GetLogger()->error(
"RssSensor[{}] tick exception", timestamp.
frame);
SharedPtr< ActorList > GetActors() const
Return a list with all the actors currently present in the world.
void throw_exception(const std::exception &e)
static void log_error(Args &&... args)
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
This file contains definitions of common data structures used in traffic manager. ...
std::size_t frame
Number of frames elapsed since the simulator was launched.
SharedPtr< Map > GetMap() const
Return the map that describes this world.
EpisodeProxy & GetEpisode()
static void log_debug(Args &&...)
const std::string & GetDisplayId() const
Used to initialize Actor classes.
#define DEBUG_ASSERT(predicate)
geom::Transform GetTransform() const
Return the current transform of the actor.
SharedPtr< Actor > GetParent() const
std::function< void(SharedPtr< sensor::SensorData >)> CallbackFunctionType
SharedPtrType Lock() const
Same as TryLock but never return nullptr.
boost::weak_ptr< T > WeakPtr
rpc::EpisodeSettings GetSettings() const
double elapsed_seconds
Simulated seconds elapsed since the beginning of the current episode.
geom::Transform Transform