8 #include <spdlog/sinks/stdout_color_sinks.h> 12 #include <ad/map/access/Logging.hpp> 13 #include <ad/map/access/Operation.hpp> 14 #include <ad/map/intersection/Intersection.hpp> 15 #include <ad/map/lane/Operation.hpp> 16 #include <ad/map/match/AdMapMatching.hpp> 17 #include <ad/map/match/MapMatchedOperation.hpp> 18 #include <ad/map/route/LaneIntervalOperation.hpp> 19 #include <ad/map/route/Operation.hpp> 20 #include <ad/map/route/Planning.hpp> 21 #include <ad/rss/map/Logging.hpp> 22 #include <ad/rss/map/RssObjectConversion.hpp> 23 #include <ad/rss/map/RssObjectData.hpp> 24 #include <ad/rss/map/RssSceneCreator.hpp> 25 #include <ad/rss/state/RssStateOperation.hpp> 35 #define DEBUG_TIMING 0 40 void printRoute(std::string
const &route_descr, ::ad::map::route::FullRoute
const &route) {
41 std::cout << route_descr << std::endl;
42 for (
auto road_segment : route.roadSegments) {
43 for (
auto lane_segment : road_segment.drivableLaneSegments) {
44 std::cout <<
"(" <<
static_cast<uint64_t
>(lane_segment.laneInterval.laneId) <<
" | " << std::setprecision(2)
45 <<
static_cast<double>(lane_segment.laneInterval.start) <<
":" 46 << static_cast<double>(lane_segment.laneInterval.end) <<
") ";
48 std::cout << std::endl;
53 constexpr
float to_radians =
static_cast<float>(M_PI) / 180.0f;
56 : time_since_epoch_check_start_ms(0.),
57 time_since_epoch_check_end_ms(0.),
59 min_stopping_distance(0.),
60 ego_center({0., 0., 0.}),
62 ego_heading_change(0.),
63 ego_steering_angle(0.),
64 ego_center_within_route(
false),
65 crossing_border(
false),
67 route_nominal_center({0., 0., 0.}),
73 avg_route_accel_lat(0.),
74 avg_route_accel_lon(0.) {
75 timestamp.elapsed_seconds = 0.;
79 static auto logger = spdlog::stdout_color_mt(
"RssCheck");
84 static auto logger = spdlog::stdout_color_mt(
"RssCheckTiming");
89 ::ad::rss::world::RssDynamics default_ego_vehicle_dynamics;
90 default_ego_vehicle_dynamics.alphaLon.accelMax = ::ad::physics::Acceleration(3.5);
91 default_ego_vehicle_dynamics.alphaLon.brakeMax = ::ad::physics::Acceleration(-8.);
92 default_ego_vehicle_dynamics.alphaLon.brakeMin = ::ad::physics::Acceleration(-4.);
93 default_ego_vehicle_dynamics.alphaLon.brakeMinCorrect = ::ad::physics::Acceleration(-3);
94 default_ego_vehicle_dynamics.alphaLat.accelMax = ::ad::physics::Acceleration(0.2);
95 default_ego_vehicle_dynamics.alphaLat.brakeMin = ::ad::physics::Acceleration(-0.8);
96 default_ego_vehicle_dynamics.lateralFluctuationMargin = ::ad::physics::Distance(0.1);
97 default_ego_vehicle_dynamics.responseTime = ::ad::physics::Duration(1.0);
98 default_ego_vehicle_dynamics.maxSpeedOnAcceleration = ::ad::physics::Speed(100.);
99 default_ego_vehicle_dynamics.unstructuredSettings.pedestrianTurningRadius = ad::physics::Distance(2.0);
100 default_ego_vehicle_dynamics.unstructuredSettings.driveAwayMaxAngle = ad::physics::Angle(2.4);
101 default_ego_vehicle_dynamics.unstructuredSettings.vehicleYawRateChange = ad::physics::AngularAcceleration(0.3);
102 default_ego_vehicle_dynamics.unstructuredSettings.vehicleMinRadius = ad::physics::Distance(3.5);
103 default_ego_vehicle_dynamics.unstructuredSettings.vehicleTrajectoryCalculationStep = ad::physics::Duration(0.2);
104 return default_ego_vehicle_dynamics;
108 ::ad::rss::world::RssDynamics default_pedestrian_dynamics;
109 default_pedestrian_dynamics.alphaLon.accelMax = ::ad::physics::Acceleration(2.0);
110 default_pedestrian_dynamics.alphaLon.brakeMax = ::ad::physics::Acceleration(-4.);
111 default_pedestrian_dynamics.alphaLon.brakeMin = ::ad::physics::Acceleration(-2.);
112 default_pedestrian_dynamics.alphaLon.brakeMinCorrect = ::ad::physics::Acceleration(-2.);
113 default_pedestrian_dynamics.alphaLat.accelMax = ::ad::physics::Acceleration(0.001);
114 default_pedestrian_dynamics.alphaLat.brakeMin = ::ad::physics::Acceleration(-0.001);
115 default_pedestrian_dynamics.lateralFluctuationMargin = ::ad::physics::Distance(0.1);
116 default_pedestrian_dynamics.responseTime = ::ad::physics::Duration(0.5);
117 default_pedestrian_dynamics.maxSpeedOnAcceleration = ::ad::physics::Speed(10.);
118 default_pedestrian_dynamics.unstructuredSettings.pedestrianTurningRadius = ad::physics::Distance(2.0);
119 default_pedestrian_dynamics.unstructuredSettings.driveAwayMaxAngle = ad::physics::Angle(2.4);
120 default_pedestrian_dynamics.unstructuredSettings.vehicleYawRateChange = ad::physics::AngularAcceleration(0.3);
121 default_pedestrian_dynamics.unstructuredSettings.vehicleMinRadius = ad::physics::Distance(3.5);
122 default_pedestrian_dynamics.unstructuredSettings.vehicleTrajectoryCalculationStep = ad::physics::Duration(0.2);
124 return default_pedestrian_dynamics;
150 ::ad::rss::map::RssSceneCreation::RestrictSpeedLimitMode::IncreasedSpeedLimit10;
155 if (actor_constellation_data->other_actor !=
nullptr) {
156 if (boost::dynamic_pointer_cast<carla::client::Walker>(actor_constellation_data->other_actor) !=
nullptr) {
160 }
else if (boost::dynamic_pointer_cast<carla::client::Vehicle>(actor_constellation_data->other_actor) !=
163 actor_constellation_result.
actor_object_type = ad::rss::world::ObjectType::OtherVehicle;
165 if (
GetSpeed(*actor_constellation_data->other_actor) == ::ad::physics::Speed(0.)) {
174 actor_constellation_result.
actor_dynamics.alphaLon.accelMax = ::ad::physics::Acceleration(0.);
187 auto const abs_avg_route_accel_lat = std::fabs(actor_constellation_data->ego_dynamics_on_route.avg_route_accel_lat);
188 if (abs_avg_route_accel_lat > actor_constellation_result.
ego_vehicle_dynamics.alphaLat.accelMax) {
190 std::min(ad::physics::Acceleration(20.), abs_avg_route_accel_lat);
192 return actor_constellation_result;
198 _logger->debug(
"RssCheck with default actor constellation callback created");
217 _logger->debug(
"RssCheck created");
223 spdlog::set_level(log_level);
237 const ::ad::rss::world::RssDynamics &ego_vehicle_dynamics) {
246 const ::ad::rss::world::RssDynamics &other_vehicle_dynamics) {
255 const ::ad::rss::world::RssDynamics &pedestrian_dynamics) {
269 ::ad::map::point::createENUPoint(routing_target.
location.
x, -1. * routing_target.
location.
y, 0.));
273 std::vector<::carla::geom::Transform> routing_targets;
277 routing_target.
location.
x =
static_cast<float>(target.x);
278 routing_target.
location.
y =
static_cast<float>(-target.y);
280 routing_targets.push_back(routing_target);
283 return routing_targets;
299 ::ad::rss::state::ProperResponse &output_response,
300 ::ad::rss::state::RssStateSnapshot &output_rss_state_snapshot,
301 ::ad::rss::situation::SituationSnapshot &output_situation_snapshot,
302 ::ad::rss::world::WorldModel &output_world_model,
306 double const time_since_epoch_check_start_ms =
307 std::chrono::duration<double, std::milli>(std::chrono::system_clock::now().time_since_epoch()).count();
310 auto t_start = std::chrono::high_resolution_clock::now();
311 auto t_end = std::chrono::high_resolution_clock::now();
312 std::cout <<
"-> SC " << std::chrono::duration<double, std::milli>(t_end - t_start).count() <<
" start checkObjects" 317 if (carla_ego_vehicle ==
nullptr) {
318 _logger->error(
"RSS Sensor only support vehicles as ego.");
322 t_end = std::chrono::high_resolution_clock::now();
323 std::cout <<
"-> ME " << std::chrono::duration<double, std::milli>(t_end - t_start).count()
324 <<
" before MapMatching" << std::endl;
329 auto const ego_match_object =
GetMatchObject(carla_ego_actor, ::ad::physics::Distance(2.0));
333 auto const travelled_distance = ::ad::map::point::distance(
335 if (travelled_distance > ::ad::physics::Distance(10.)) {
336 _logger->warn(
"Jump in ego vehicle position detected {} -> {}! Force reroute!",
338 ego_match_object.enuPosition.centerPoint);
348 t_end = std::chrono::high_resolution_clock::now();
349 std::cout <<
"-> ME " << std::chrono::duration<double, std::milli>(t_end - t_start).count()
350 <<
" after ego MapMatching" << std::endl;
356 t_end = std::chrono::high_resolution_clock::now();
357 std::cout <<
"-> RU " << std::chrono::duration<double, std::milli>(t_end - t_start).count()
358 <<
" after route update " << std::endl;
371 t_end = std::chrono::high_resolution_clock::now();
372 std::cout <<
"-> WM " << std::chrono::duration<double, std::milli>(t_end - t_start).count()
373 <<
" after create world model " << std::endl;
379 t_end = std::chrono::high_resolution_clock::now();
380 std::cout <<
"-> CH " << std::chrono::duration<double, std::milli>(t_end - t_start).count() <<
" end RSS check" 387 t_end = std::chrono::high_resolution_clock::now();
388 std::cout <<
"-> AN " << std::chrono::duration<double, std::milli>(t_end - t_start).count()
389 <<
" end analyze results" << std::endl;
393 std::chrono::duration<double, std::milli>(std::chrono::system_clock::now().time_since_epoch()).count();
402 _logger->debug(
"===== ROUTE NOT SAFE =====");
404 _logger->debug(
"===== ROUTE SAFE =====");
408 t_end = std::chrono::high_resolution_clock::now();
409 std::cout <<
"-> EC " << std::chrono::duration<double, std::milli>(t_end - t_start).count() <<
" end check objects" 413 _logger->error(
"Exception -> Check failed");
419 ::ad::physics::Distance
const &sampling_distance)
const {
420 ::ad::map::match::Object match_object;
422 auto const vehicle_transform = actor->GetTransform();
423 match_object.enuPosition.centerPoint.x = ::ad::map::point::ENUCoordinate(vehicle_transform.location.x);
424 match_object.enuPosition.centerPoint.y = ::ad::map::point::ENUCoordinate(-1. * vehicle_transform.location.y);
425 match_object.enuPosition.centerPoint.z = ::ad::map::point::ENUCoordinate(0.);
426 match_object.enuPosition.heading =
427 ::ad::map::point::createENUHeading(-1 * vehicle_transform.rotation.yaw * to_radians);
431 if (vehicle !=
nullptr) {
433 match_object.enuPosition.dimension.length = ::ad::physics::Distance(2 * bounding_box.extent.x);
434 match_object.enuPosition.dimension.width = ::ad::physics::Distance(2 * bounding_box.extent.y);
435 match_object.enuPosition.dimension.height = ::ad::physics::Distance(2 * bounding_box.extent.z);
436 }
else if (walker !=
nullptr) {
437 const auto &bounding_box = walker->GetBoundingBox();
438 match_object.enuPosition.dimension.length = ::ad::physics::Distance(2 * bounding_box.extent.x);
439 match_object.enuPosition.dimension.width = ::ad::physics::Distance(2 * bounding_box.extent.y);
440 match_object.enuPosition.dimension.height = ::ad::physics::Distance(2 * bounding_box.extent.z);
442 _logger->error(
"Could not get bounding box of actor {}", actor->GetId());
444 match_object.enuPosition.enuReferencePoint = ::ad::map::access::getENUReferencePoint();
446 ::ad::map::match::AdMapMatching map_matching;
447 match_object.mapMatchedBoundingBox =
448 map_matching.getMapMatchedBoundingBox(match_object.enuPosition, sampling_distance);
458 ::ad::physics::Speed speed(std::sqrt(velocity.x * velocity.x + velocity.y * velocity.y));
459 if (velocity.x < 0.) {
468 ::ad::physics::AngularVelocity heading_change(-1. * angular_velocity.z * to_radians);
469 return heading_change;
475 return steering_angle;
485 ::ad::map::point::ParaPointList all_lane_matches;
486 for (
auto reference_point :
487 {::ad::map::match::ObjectReferencePoints::RearRight, ::ad::map::match::ObjectReferencePoints::RearLeft}) {
488 auto const &reference_position =
489 carla_rss_state.
ego_match_object.mapMatchedBoundingBox.referencePointPositions[size_t(reference_point)];
490 auto const para_points = ::ad::map::match::getParaPoints(reference_position);
491 all_lane_matches.insert(all_lane_matches.end(), para_points.begin(), para_points.end());
494 auto shorten_route_result = ::ad::map::route::shortenRoute(
495 all_lane_matches, carla_rss_state.
ego_route,
496 ::ad::map::route::ShortenRouteMode::DontCutIntersectionAndPrependIfSucceededBeforeRoute);
497 if (shorten_route_result == ::ad::map::route::ShortenRouteResult::SucceededIntersectionNotCut) {
498 shorten_route_result = ::ad::map::route::ShortenRouteResult::Succeeded;
501 bool routing_target_check_finished =
false;
504 auto const &distance_to_next_target =
505 ::ad::map::point::distance(next_target, carla_rss_state.
ego_match_object.enuPosition.centerPoint);
506 if (distance_to_next_target < ::ad::physics::Distance(3.)) {
510 routing_target_check_finished =
true;
514 bool reroute_required =
false;
516 reroute_required =
true;
524 ::ad::physics::Distance
const route_target_length(50.);
526 if ((!reroute_required) && (shorten_route_result == ::ad::map::route::ShortenRouteResult::Succeeded)) {
527 std::vector<::ad::map::route::FullRoute> additional_routes;
528 auto const route_valid =
529 ::ad::map::route::extendRouteToDistance(carla_rss_state.
ego_route, route_target_length, additional_routes);
532 if (additional_routes.size() > 0u) {
534 std::size_t route_index =
static_cast<std::size_t
>(std::rand()) % (additional_routes.size() + 1);
535 if (route_index < additional_routes.size()) {
537 _logger->debug(
"Additional Routes: {}->{}", additional_routes.size(), route_index);
538 carla_rss_state.
ego_route = additional_routes[route_index];
541 _logger->debug(
"Additional Routes: expand current");
545 reroute_required =
true;
549 reroute_required =
true;
553 if (reroute_required) {
555 std::vector<::ad::map::route::FullRoute> all_new_routes;
556 for (
const auto &position :
558 .referencePointPositions[int32_t(::ad::map::match::ObjectReferencePoints::Center)]) {
559 auto start_point = position.lanePoint.paraPoint;
560 auto projected_start_point = start_point;
561 if (!::ad::map::lane::isHeadingInLaneDirection(start_point,
563 _logger->debug(
"EgoVehicle heading in opposite lane direction");
564 if (::ad::map::lane::projectPositionToLaneInHeadingDirection(
565 start_point, carla_rss_state.
ego_match_object.enuPosition.heading, projected_start_point)) {
566 _logger->debug(
"Projected to lane {}", projected_start_point.laneId);
569 _logger->debug(
"Route start_point: {}, projected_start_point: {}", start_point, projected_start_point);
570 auto routing_start_point = ::ad::map::route::planning::createRoutingPoint(
571 projected_start_point, carla_rss_state.
ego_match_object.enuPosition.heading);
573 auto new_route = ::ad::map::route::planning::planRoute(routing_start_point,
_routing_targets,
574 ::ad::map::route::RouteCreationMode::AllRoutableLanes);
575 all_new_routes.push_back(new_route);
577 auto new_routes = ::ad::map::route::planning::predictRoutesOnDistance(
578 routing_start_point, route_target_length, ::ad::map::route::RouteCreationMode::AllRoutableLanes);
580 for (
const auto &new_route : new_routes) {
582 all_new_routes.push_back(new_route);
587 _logger->debug(
"New routes: {}", all_new_routes.size());
589 if (!all_new_routes.empty()) {
591 std::size_t route_index =
static_cast<std::size_t
>(std::rand()) % (all_new_routes.size());
592 carla_rss_state.
ego_route = all_new_routes[route_index];
602 ::ad::map::route::FullRoute
const &route, ::ad::rss::world::RssDynamics
const &default_ego_vehicle_dynamics,
605 new_dynamics.
timestamp = current_timestamp;
608 new_dynamics.
ego_center = match_object.enuPosition.centerPoint;
609 new_dynamics.
ego_heading = match_object.enuPosition.heading;
614 ::ad::map::route::getRouteSection(match_object, route, ::ad::map::route::RouteSectionCreationMode::AllRouteLanes);
615 auto border = ::ad::map::route::getENUBorderOfRoute(object_route);
616 new_dynamics.
route_heading = ::ad::map::lane::getENUHeading(border, match_object.enuPosition.centerPoint);
618 auto const object_center = ::ad::map::route::findCenterWaypoint(match_object, object_route);
619 if (object_center.isValid()) {
620 auto lane_center_point = object_center.queryPosition;
621 auto lane_center_point_enu = ::ad::map::lane::getENULanePoint(lane_center_point);
622 if (std::fabs(new_dynamics.
route_heading) > ::ad::map::point::ENUHeading(M_PI)) {
625 new_dynamics.
route_heading = ::ad::map::lane::getENUHeading(border, lane_center_point_enu);
628 if (object_center.laneSegmentIterator->laneInterval.wrongWay) {
631 ::ad::map::lane::projectPositionToLaneInHeadingDirection(lane_center_point, new_dynamics.
route_heading,
633 lane_center_point_enu = ::ad::map::lane::getENULanePoint(lane_center_point);
650 bool keep_last_acceleration =
true;
652 ::ad::physics::Duration
const delta_time(current_timestamp.
elapsed_seconds -
654 if (delta_time > ::ad::physics::Duration(0.0001)) {
671 keep_last_acceleration =
false;
677 if (keep_last_acceleration) {
686 ::ad::map::point::ParaPointList in_lane_matches;
687 for (
auto &match_position : match_object.mapMatchedBoundingBox
688 .referencePointPositions[int32_t(::ad::map::match::ObjectReferencePoints::Center)]) {
689 if (match_position.type == ::ad::map::match::MapMatchedPositionType::LANE_IN) {
690 in_lane_matches.push_back(match_position.lanePoint.paraPoint);
693 auto const object_in_lane_center = ::ad::map::route::findNearestWaypoint(in_lane_matches, route);
700 ::ad::rss::map::RssObjectData ego_object_data;
701 ego_object_data.id = ::ad::rss::world::ObjectId(0u);
702 ego_object_data.type = ::ad::rss::world::ObjectType::EgoVehicle;
703 ego_object_data.matchObject = match_object;
704 ego_object_data.speed = new_dynamics.
ego_speed;
707 ego_object_data.rssDynamics = default_ego_vehicle_dynamics;
709 ad::rss::map::RssObjectConversion object_conversion(ego_object_data);
712 "CalculateEgoDynamicsOnRoute: calculation of min stopping distance " 713 "failed. Setting to 100. ({} {} {} {})",
715 default_ego_vehicle_dynamics);
719 _logger->trace(
"CalculateEgoDynamicsOnRoute: route-section {} -> dynamics: {}", object_route, new_dynamics);
724 ::ad::map::match::Object other_match_object;
734 ::ad::map::route::FullRoute
const &route)
const {
735 ::ad::map::landmark::LandmarkIdSet green_traffic_lights;
737 auto next_intersection = ::ad::map::intersection::Intersection::getNextIntersectionOnRoute(route);
738 if (next_intersection &&
744 auto incoming_lanes = next_intersection->incomingLanesOnRoute();
747 auto incoming_lanes_iter = incoming_lanes.begin();
748 while (incoming_lanes_iter != incoming_lanes.end()) {
749 auto find_waypoint = ::ad::map::route::findWaypoint(*incoming_lanes_iter, route);
750 if (find_waypoint.isValid() && find_waypoint.laneSegmentIterator->laneInterval.wrongWay) {
751 incoming_lanes_iter = incoming_lanes.erase(incoming_lanes_iter);
753 incoming_lanes_iter++;
757 ::ad::map::match::AdMapMatching traffic_light_map_matching;
758 bool found_relevant_traffic_light =
false;
759 for (
const auto &traffic_light : traffic_lights) {
760 auto traffic_light_state = traffic_light->GetState();
763 auto traffic_light_transform = traffic_light->GetTransform();
764 auto trigger_box_location = trigger_bounding_box.
location;
765 traffic_light_transform.TransformPoint(trigger_box_location);
767 ::ad::map::point::ENUPoint trigger_box_position;
768 trigger_box_position.
x = ::ad::map::point::ENUCoordinate(trigger_box_location.x);
769 trigger_box_position.y = ::ad::map::point::ENUCoordinate(-1 * trigger_box_location.y);
770 trigger_box_position.z = ::ad::map::point::ENUCoordinate(0.);
772 _logger->trace(
"traffic light[{}] Position: {}", traffic_light->GetId(), trigger_box_position);
773 auto traffic_light_map_matched_positions = traffic_light_map_matching.getMapMatchedPositions(
774 trigger_box_position, ::ad::physics::Distance(0.25), ::ad::physics::Probability(0.1));
776 _logger->trace(
"traffic light[{}] Map Matched Position: {}", traffic_light->GetId(),
777 traffic_light_map_matched_positions);
779 for (
auto matched_position : traffic_light_map_matched_positions) {
780 if (incoming_lanes.find(matched_position.lanePoint.paraPoint.laneId) != incoming_lanes.end()) {
781 if (found_relevant_traffic_light &&
783 _logger->warn(
"found another relevant traffic light on lane {}; {} state {}",
784 matched_position.lanePoint.paraPoint.laneId, traffic_light->GetId(),
787 _logger->debug(
"found relevant traffic light on lane {}; {} state {}",
788 matched_position.lanePoint.paraPoint.laneId, traffic_light->GetId(),
792 found_relevant_traffic_light =
true;
798 green_traffic_lights.insert(::ad::map::landmark::LandmarkId::getMax());
801 green_traffic_lights.clear();
808 return green_traffic_lights;
812 ::ad::rss::map::RssSceneCreation &scene_creation,
815 ::ad::map::landmark::LandmarkIdSet
const &green_traffic_lights)
816 : _rss_check(rss_check),
817 _scene_creation(scene_creation),
818 _carla_ego_vehicle(carla_ego_vehicle),
820 _green_traffic_lights(green_traffic_lights) {}
827 _rss_check.
_logger->trace(
"OtherVehicleMapMatching: {} {}", other_traffic_participant->GetId(),
828 other_match_object.mapMatchedBoundingBox);
832 other_match_object, other_traffic_participant}};
837 auto other_steering_angle = ::ad::physics::Angle(0.);
839 ::ad::rss::map::RssObjectData ego_object_data;
841 ego_object_data.type = ::ad::rss::world::ObjectType::EgoVehicle;
846 ego_object_data.rssDynamics = actor_constellation_result.ego_vehicle_dynamics;
848 ::ad::rss::map::RssObjectData other_object_data;
849 other_object_data.id = ::ad::rss::world::ObjectId(other_traffic_participant->GetId());
850 other_object_data.type = actor_constellation_result.actor_object_type;
851 other_object_data.matchObject = other_match_object;
852 other_object_data.speed = other_speed;
853 other_object_data.yawRate = other_heading_change;
854 other_object_data.steeringAngle = other_steering_angle;
855 other_object_data.rssDynamics = actor_constellation_result.actor_dynamics;
859 actor_constellation_result.rss_calculation_mode);
862 _rss_check.
_logger->error(
"Exception processing other traffic participant {} -> Ignoring it",
863 other_traffic_participant->GetId());
870 std::vector<SharedPtr<carla::client::TrafficLight>> traffic_lights;
871 std::vector<SharedPtr<carla::client::Actor>> other_traffic_participants;
872 for (
const auto &actor : actors) {
874 if (traffic_light !=
nullptr) {
875 traffic_lights.push_back(traffic_light);
879 if ((boost::dynamic_pointer_cast<carla::client::Vehicle>(actor) !=
nullptr) ||
880 (boost::dynamic_pointer_cast<carla::client::Walker>(actor) !=
nullptr)) {
881 if (actor->GetId() == carla_ego_vehicle.
GetId()) {
884 auto const relevant_distance =
886 if (actor->GetTransform().location.Distance(carla_ego_vehicle.
GetTransform().
location) < relevant_distance) {
887 other_traffic_participants.push_back(actor);
892 ::ad::map::landmark::LandmarkIdSet green_traffic_lights =
898 tbb::parallel_for_each(
899 other_traffic_participants.begin(), other_traffic_participants.end(),
900 RssObjectChecker(*
this, scene_creation, carla_ego_vehicle, carla_rss_state, green_traffic_lights));
902 for (
auto const traffic_participant : other_traffic_participants) {
903 auto checker =
RssObjectChecker(*
this, scene_creation, carla_ego_vehicle, carla_rss_state, green_traffic_lights);
904 checker(traffic_participant);
912 ego_vehicle_dynamics.alphaLat.accelMax = ::ad::physics::Acceleration(0.);
914 ::ad::rss::map::RssObjectData ego_object_data;
915 ego_object_data.id = carla_ego_vehicle.
GetId();
916 ego_object_data.type = ::ad::rss::world::ObjectType::EgoVehicle;
921 ego_object_data.rssDynamics = ego_vehicle_dynamics;
922 scene_creation.appendRoadBoundaries(ego_object_data, carla_rss_state.
ego_route,
925 ::ad::rss::map::RssSceneCreation::AppendRoadBoundariesMode::RouteOnly);
928 carla_rss_state.
world_model = scene_creation.getWorldModel();
932 bool result = carla_rss_state.
rss_check.calculateProperResponse(
937 _logger->warn(
"calculateProperResponse failed!");
949 bool left_border_is_dangerous =
false;
950 bool right_border_is_dangerous =
false;
951 bool vehicle_triggered_left_response =
false;
952 bool vehicle_triggered_right_response =
false;
953 bool vehicle_triggered_longitudinal_response =
false;
955 if (::ad::rss::state::isDangerous(state)) {
957 _logger->trace(
"DangerousState: {}", state);
958 auto dangerous_sitation_iter = std::find_if(carla_rss_state.
situation_snapshot.situations.begin(),
960 [&state](::ad::rss::situation::Situation
const &situation) {
961 return situation.situationId == state.situationId;
964 _logger->trace(
"Situation: {}", *dangerous_sitation_iter);
965 if (dangerous_sitation_iter->objectId == ::ad::rss::map::RssSceneCreator::getRightBorderObjectId()) {
966 right_border_is_dangerous =
true;
967 }
else if (dangerous_sitation_iter->objectId == ::ad::rss::map::RssSceneCreator::getLeftBorderObjectId()) {
968 left_border_is_dangerous =
true;
971 if (state.longitudinalState.response != ::ad::rss::state::LongitudinalResponse::None) {
972 vehicle_triggered_longitudinal_response =
true;
974 if (state.lateralStateLeft.response != ::ad::rss::state::LateralResponse::None) {
975 vehicle_triggered_left_response =
true;
977 if (state.lateralStateRight.response != ::ad::rss::state::LateralResponse::None) {
978 vehicle_triggered_right_response =
true;
981 if (dangerous_sitation_iter->situationType == ::ad::rss::situation::SituationType::OppositeDirection) {
989 if (!vehicle_triggered_longitudinal_response &&
990 (carla_rss_state.
proper_response.longitudinalResponse != ::ad::rss::state::LongitudinalResponse::None)) {
991 _logger->debug(
"!! longitudinalResponse only triggered by borders: ignore !!");
992 carla_rss_state.
proper_response.longitudinalResponse = ::ad::rss::state::LongitudinalResponse::None;
993 carla_rss_state.
proper_response.accelerationRestrictions.longitudinalRange.maximum =
996 if (!vehicle_triggered_left_response && !left_border_is_dangerous &&
997 (carla_rss_state.
proper_response.lateralResponseLeft != ::ad::rss::state::LateralResponse::None)) {
998 _logger->debug(
"!! lateralResponseLeft only triggered by right border: ignore !!");
999 carla_rss_state.
proper_response.lateralResponseLeft = ::ad::rss::state::LateralResponse::None;
1000 carla_rss_state.
proper_response.accelerationRestrictions.lateralLeftRange.maximum =
1004 if (!vehicle_triggered_right_response && !right_border_is_dangerous &&
1005 (carla_rss_state.
proper_response.lateralResponseRight != ::ad::rss::state::LateralResponse::None)) {
1006 _logger->debug(
"!! lateralResponseRight only triggered by left border: ignore !!");
1007 carla_rss_state.
proper_response.lateralResponseRight = ::ad::rss::state::LateralResponse::None;
1008 carla_rss_state.
proper_response.accelerationRestrictions.lateralRightRange.maximum =
void InverseRotateVector(Vector3D &in_point) const
Location location
Center of the BoundingBox in local space.
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.
Control GetControl() const
Return the control last applied to this vehicle.
const geom::BoundingBox & GetBoundingBox() const
double min(double v1, double v2)
geom::Vector3D GetAngularVelocity() const
Return the current 3D angular velocity of the actor.
geom::Transform GetTransform() const
Return the current transform of the actor.
Represents an actor in the simulation.
geom::Vector3D GetVelocity() const
Return the current 3D velocity of the actor.
double elapsed_seconds
Simulated seconds elapsed since the beginning of the current episode.