scenario_simulator_v2 C++ API
simulator_core.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef OPENSCENARIO_INTERPRETER__SIMULATOR_CORE_HPP_
16 #define OPENSCENARIO_INTERPRETER__SIMULATOR_CORE_HPP_
17 
28 
30 {
31 using NativeWorldPosition = geometry_msgs::msg::Pose;
32 
34 
36 
38 
40 {
41  static inline std::unique_ptr<traffic_simulator::API> core = nullptr;
42 
43 public:
44  template <typename Node, typename... Ts>
45  static auto activate(
46  const Node & node, const traffic_simulator::Configuration & configuration, Ts &&... xs) -> void
47  {
48  if (not active()) {
49  core = std::make_unique<traffic_simulator::API>(
50  node, configuration, std::forward<decltype(xs)>(xs)...);
51  } else {
52  throw Error("The simulator core has already been instantiated.");
53  }
54  }
55 
56  static auto active() { return static_cast<bool>(core); }
57 
58  static auto deactivate() -> void
59  {
60  if (active()) {
61  core->despawnEntities();
62  core->closeZMQConnection();
63  core.reset();
64  }
65  }
66 
67  static auto update() -> void { core->updateFrame(); }
68 
70  {
71  protected:
72  static auto canonicalize(const traffic_simulator::LaneletPose & non_canonicalized)
74  {
75  return NativeLanePosition(non_canonicalized, core->getHdmapUtils());
76  }
77 
78  template <typename T, typename std::enable_if_t<std::is_same_v<T, NativeLanePosition>, int> = 0>
79  static auto convert(const NativeWorldPosition & pose) -> NativeLanePosition
80  {
81  constexpr bool include_crosswalk{false};
82  if (
84  pose, include_crosswalk, core->getHdmapUtils())) {
85  return result.value();
86  } else {
87  throw Error(
88  "The specified WorldPosition = [", pose.position.x, ", ", pose.position.y, ", ",
89  pose.position.z,
90  "] could not be approximated to the proper Lane. Perhaps the "
91  "WorldPosition points to a location where multiple lanes overlap, and "
92  "there are at least two or more candidates for a LanePosition that "
93  "can be approximated to that WorldPosition. This issue can be "
94  "resolved by strictly specifying the location using LanePosition "
95  "instead of WorldPosition");
96  }
97  }
98 
99  template <
100  typename T, typename std::enable_if_t<std::is_same_v<T, NativeWorldPosition>, int> = 0>
101  static auto convert(const NativeLanePosition & native_lane_position) -> NativeWorldPosition
102  {
103  return traffic_simulator::pose::toMapPose(native_lane_position);
104  }
105 
107  const std::string & from_entity_name, const std::string & to_entity_name)
108  {
109  if (const auto from_entity = core->getEntity(from_entity_name)) {
110  if (const auto to_entity = core->getEntity(to_entity_name)) {
111  if (
112  const auto relative_pose = traffic_simulator::pose::relativePose(
113  from_entity->getMapPose(), to_entity->getMapPose()))
114  return relative_pose.value();
115  }
116  }
118  }
119 
121  const std::string & from_entity_name, const NativeWorldPosition & to_map_pose)
122  {
123  if (const auto from_entity = core->getEntity(from_entity_name)) {
124  if (
125  const auto relative_pose =
126  traffic_simulator::pose::relativePose(from_entity->getMapPose(), to_map_pose)) {
127  return relative_pose.value();
128  }
129  }
131  }
132 
134  const NativeWorldPosition & from_map_pose, const std::string & to_entity_name)
135  {
136  if (const auto to_entity = core->getEntity(to_entity_name)) {
137  if (
138  const auto relative_pose =
139  traffic_simulator::pose::relativePose(from_map_pose, to_entity->getMapPose())) {
140  return relative_pose.value();
141  }
142  }
144  }
145 
147  const std::string & from_entity_name, const std::string & to_entity_name,
148  const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined)
150  {
151  if (const auto to_entity = core->getEntity(to_entity_name)) {
152  if (const auto to_lanelet_pose = to_entity->getCanonicalizedLaneletPose()) {
154  from_entity_name, to_lanelet_pose.value(), routing_algorithm);
155  }
156  }
158  }
159 
161  const std::string & from_entity_name, const NativeLanePosition & to_lanelet_pose,
162  const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined)
164  {
165  if (const auto from_entity = core->getEntity(from_entity_name)) {
166  if (const auto from_lanelet_pose = from_entity->getCanonicalizedLaneletPose()) {
168  from_lanelet_pose.value(), to_lanelet_pose, routing_algorithm);
169  }
170  }
172  }
173 
175  const NativeLanePosition & from_lanelet_pose, const NativeLanePosition & to_lanelet_pose,
176  const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined)
178  {
179  const bool allow_lane_change = (routing_algorithm == RoutingAlgorithm::value_type::shortest);
181  from_lanelet_pose, to_lanelet_pose, allow_lane_change, core->getHdmapUtils());
182  }
183 
185  const std::string & from_entity_name, const std::string & to_entity_name,
186  const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined)
187  {
188  if (const auto from_entity = core->getEntity(from_entity_name)) {
189  if (const auto to_entity = core->getEntity(to_entity_name)) {
190  if (const auto from_lanelet_pose = from_entity->getCanonicalizedLaneletPose()) {
191  if (const auto to_lanelet_pose = to_entity->getCanonicalizedLaneletPose()) {
193  from_lanelet_pose.value(), from_entity->getBoundingBox(), to_lanelet_pose.value(),
194  to_entity->getBoundingBox(), routing_algorithm);
195  }
196  }
197  }
198  }
200  }
201 
203  const std::string & from_entity_name, const NativeLanePosition & to_lanelet_pose,
204  const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined)
205  {
206  if (const auto from_entity = core->getEntity(from_entity_name)) {
207  if (const auto from_lanelet_pose = from_entity->getCanonicalizedLaneletPose()) {
209  from_lanelet_pose.value(), from_entity->getBoundingBox(), to_lanelet_pose,
210  traffic_simulator_msgs::msg::BoundingBox(), routing_algorithm);
211  }
212  }
214  }
215 
217  const NativeLanePosition & from_lanelet_pose,
218  const traffic_simulator_msgs::msg::BoundingBox & from_bounding_box,
219  const NativeLanePosition & to_lanelet_pose,
220  const traffic_simulator_msgs::msg::BoundingBox & to_bounding_box,
221  const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined)
223  {
224  const bool allow_lane_change = (routing_algorithm == RoutingAlgorithm::value_type::shortest);
226  from_lanelet_pose, from_bounding_box, to_lanelet_pose, to_bounding_box, allow_lane_change,
227  core->getHdmapUtils());
228  }
229 
231  const std::string & from_entity_name, const std::string & to_entity_name)
232  {
233  if (const auto from_entity = core->getEntity(from_entity_name)) {
234  if (const auto to_entity = core->getEntity(to_entity_name)) {
235  if (
236  const auto relative_pose = traffic_simulator::pose::boundingBoxRelativePose(
237  from_entity->getMapPose(), from_entity->getBoundingBox(), to_entity->getMapPose(),
238  to_entity->getBoundingBox())) {
239  return relative_pose.value();
240  }
241  }
242  }
244  }
245 
247  const std::string & from_entity_name, const NativeWorldPosition & to_map_pose)
248  {
249  if (const auto from_entity = core->getEntity(from_entity_name)) {
250  if (
251  const auto relative_pose = traffic_simulator::pose::boundingBoxRelativePose(
252  from_entity->getMapPose(), from_entity->getBoundingBox(), to_map_pose,
253  traffic_simulator_msgs::msg::BoundingBox())) {
254  return relative_pose.value();
255  }
256  }
258  }
259 
261  const std::string & from_entity_name, const std::string & to_entity_name,
262  const RoutingAlgorithm::value_type routing_algorithm = RoutingAlgorithm::undefined) -> int
263  {
264  if (const auto from_entity = core->getEntity(from_entity_name)) {
265  if (const auto to_entity = core->getEntity(to_entity_name)) {
266  const bool allow_lane_change =
267  (routing_algorithm == RoutingAlgorithm::value_type::shortest);
268  if (
270  from_entity->getCanonicalizedLaneletPose().value(),
271  to_entity->getCanonicalizedLaneletPose().value(), allow_lane_change,
272  core->getHdmapUtils())) {
273  return lane_changes.value().first - lane_changes.value().second;
274  }
275  }
276  }
277  throw common::Error(
278  "Failed to evaluate lateral relative lanes between ", from_entity_name, " and ",
279  to_entity_name);
280  }
281  };
282 
283  class ActionApplication // OpenSCENARIO 1.1.1 Section 3.1.5
284  {
285  protected:
286  template <typename... Ts>
287  static auto applyAcquirePositionAction(const std::string & entity_ref, Ts &&... xs)
288  {
289  core->requestClearRoute(entity_ref);
290  return core->requestAcquirePosition(entity_ref, std::forward<decltype(xs)>(xs)...);
291  }
292 
293  template <typename... Ts>
294  static auto applyAddEntityAction(Ts &&... xs)
295  {
296  return core->spawn(std::forward<decltype(xs)>(xs)...);
297  }
298 
299  template <typename EntityRef, typename DynamicConstraints>
300  static auto applyProfileAction(
301  const EntityRef & entity_ref, const DynamicConstraints & dynamic_constraints) -> void
302  {
303  return core->setBehaviorParameter(entity_ref, [&]() {
304  auto behavior_parameter = core->getBehaviorParameter(entity_ref);
305 
306  if (not std::isinf(dynamic_constraints.max_speed)) {
307  behavior_parameter.dynamic_constraints.max_speed = dynamic_constraints.max_speed;
308  }
309 
310  if (not std::isinf(dynamic_constraints.max_acceleration)) {
311  behavior_parameter.dynamic_constraints.max_acceleration =
312  dynamic_constraints.max_acceleration;
313  }
314 
315  if (not std::isinf(dynamic_constraints.max_acceleration_rate)) {
316  behavior_parameter.dynamic_constraints.max_acceleration_rate =
317  dynamic_constraints.max_acceleration_rate;
318  }
319 
320  if (not std::isinf(dynamic_constraints.max_deceleration)) {
321  behavior_parameter.dynamic_constraints.max_deceleration =
322  dynamic_constraints.max_deceleration;
323  }
324 
325  if (not std::isinf(dynamic_constraints.max_deceleration_rate)) {
326  behavior_parameter.dynamic_constraints.max_deceleration_rate =
327  dynamic_constraints.max_deceleration_rate;
328  }
329 
330  return behavior_parameter;
331  }());
332  }
333 
334  template <typename Controller>
336  const std::string & entity_ref, Controller && controller) -> void
337  {
338  core->setVelocityLimit(
339  entity_ref, controller.properties.template get<Double>(
340  "maxSpeed", std::numeric_limits<Double::value_type>::max()));
341 
342  core->setBehaviorParameter(entity_ref, [&]() {
343  auto message = core->getBehaviorParameter(entity_ref);
344  message.see_around = not controller.properties.template get<Boolean>("isBlind");
346  message.dynamic_constraints.max_acceleration =
347  controller.properties.template get<Double>("maxAcceleration", 10.0);
348  message.dynamic_constraints.max_acceleration_rate =
349  controller.properties.template get<Double>("maxAccelerationRate", 3.0);
350  message.dynamic_constraints.max_deceleration =
351  controller.properties.template get<Double>("maxDeceleration", 10.0);
352  message.dynamic_constraints.max_deceleration_rate =
353  controller.properties.template get<Double>("maxDecelerationRate", 3.0);
354  message.dynamic_constraints.max_speed =
355  controller.properties.template get<Double>("maxSpeed", 50.0);
356  return message;
357  }());
358 
359  if (controller.isAutoware()) {
360  core->attachImuSensor(entity_ref, [&]() {
361  simulation_api_schema::ImuSensorConfiguration configuration;
362  configuration.set_entity(entity_ref);
363  configuration.set_frame_id("base_link");
364  configuration.set_add_gravity(true);
365  configuration.set_use_seed(true);
366  configuration.set_seed(0);
367  configuration.set_noise_standard_deviation_orientation(0.01);
368  configuration.set_noise_standard_deviation_twist(0.01);
369  configuration.set_noise_standard_deviation_acceleration(0.01);
370  return configuration;
371  }());
372 
373  core->attachLidarSensor([&]() {
374  simulation_api_schema::LidarConfiguration configuration;
375 
376  auto degree_to_radian = [](auto degree) {
377  return degree / 180.0 * boost::math::constants::pi<double>();
378  };
379 
380  // clang-format off
381  configuration.set_architecture_type(core->getROS2Parameter<std::string>("architecture_type", "awf/universe"));
382  configuration.set_entity(entity_ref);
383  configuration.set_horizontal_resolution(degree_to_radian(controller.properties.template get<Double>("pointcloudHorizontalResolution", 1.0)));
384  configuration.set_lidar_sensor_delay(controller.properties.template get<Double>("pointcloudPublishingDelay"));
385  configuration.set_scan_duration(0.1);
386  // clang-format on
387 
388  const auto vertical_field_of_view = degree_to_radian(
389  controller.properties.template get<Double>("pointcloudVerticalFieldOfView", 30.0));
390 
391  const auto channels =
392  controller.properties.template get<UnsignedInteger>("pointcloudChannels", 16);
393 
394  for (std::size_t i = 0; i < channels; ++i) {
395  configuration.add_vertical_angles(
396  vertical_field_of_view / 2 - vertical_field_of_view / channels * i);
397  }
398 
399  return configuration;
400  }());
401 
402  core->attachDetectionSensor([&]() {
403  simulation_api_schema::DetectionSensorConfiguration configuration;
404  // clang-format off
405  configuration.set_architecture_type(core->getROS2Parameter<std::string>("architecture_type", "awf/universe"));
406  configuration.set_entity(entity_ref);
407  configuration.set_detect_all_objects_in_range(controller.properties.template get<Boolean>("isClairvoyant"));
408  configuration.set_object_recognition_delay(controller.properties.template get<Double>("detectedObjectPublishingDelay"));
409  configuration.set_pos_noise_stddev(controller.properties.template get<Double>("detectedObjectPositionStandardDeviation"));
410  configuration.set_probability_of_lost(controller.properties.template get<Double>("detectedObjectMissingProbability"));
411  configuration.set_random_seed(controller.properties.template get<UnsignedInteger>("randomSeed"));
412  configuration.set_range(controller.properties.template get<Double>("detectionSensorRange",300.0));
413  configuration.set_object_recognition_ground_truth_delay(controller.properties.template get<Double>("detectedObjectGroundTruthPublishingDelay"));
414  configuration.set_update_duration(0.1);
415  // clang-format on
416  return configuration;
417  }());
418 
419  core->attachOccupancyGridSensor([&]() {
420  simulation_api_schema::OccupancyGridSensorConfiguration configuration;
421  // clang-format off
422  configuration.set_architecture_type(core->getROS2Parameter<std::string>("architecture_type", "awf/universe"));
423  configuration.set_entity(entity_ref);
424  configuration.set_filter_by_range(controller.properties.template get<Boolean>("isClairvoyant"));
425  configuration.set_height(200);
426  configuration.set_range(300);
427  configuration.set_resolution(0.5);
428  configuration.set_update_duration(0.1);
429  configuration.set_width(200);
430  // clang-format on
431  return configuration;
432  }());
433 
434  core->attachPseudoTrafficLightDetector([&]() {
435  simulation_api_schema::PseudoTrafficLightDetectorConfiguration configuration;
436  configuration.set_architecture_type(
437  core->getROS2Parameter<std::string>("architecture_type", "awf/universe"));
438  return configuration;
439  }());
440 
441  core->asFieldOperatorApplication(entity_ref)
442  .declare_parameter<bool>(
443  "allow_goal_modification",
444  controller.properties.template get<Boolean>("allowGoalModification"));
445 
446  for (const auto & module :
447  [](std::string manual_modules_string) {
448  manual_modules_string.erase(
449  std::remove_if(
450  manual_modules_string.begin(), manual_modules_string.end(),
451  [](const auto & c) { return std::isspace(c); }),
452  manual_modules_string.end());
453 
454  std::vector<std::string> modules;
455  std::string buffer;
456  std::istringstream modules_stream(manual_modules_string);
457  while (std::getline(modules_stream, buffer, ',')) {
458  modules.push_back(buffer);
459  }
460  return modules;
461  }(controller.properties.template get<String>(
462  "featureIdentifiersRequiringExternalPermissionForAutonomousDecisions"))) {
463  try {
464  core->asFieldOperatorApplication(entity_ref)
465  .requestAutoModeForCooperation(module, false);
466  } catch (const Error & error) {
467  throw Error(
468  "featureIdentifiersRequiringExternalPermissionForAutonomousDecisions is not "
469  "supported in this environment: ",
470  error.what());
471  }
472  }
473  }
474  }
475 
476  template <typename... Ts>
477  static auto applyAssignRouteAction(Ts &&... xs)
478  {
479  return core->requestAssignRoute(std::forward<decltype(xs)>(xs)...);
480  }
481 
482  template <typename... Ts>
483  static auto applyDeleteEntityAction(Ts &&... xs)
484  {
485  return core->despawn(std::forward<decltype(xs)>(xs)...);
486  }
487 
488  template <typename... Ts>
489  static auto applyFollowTrajectoryAction(Ts &&... xs)
490  {
491  return core->requestFollowTrajectory(std::forward<decltype(xs)>(xs)...);
492  }
493 
494  template <typename... Ts>
495  static auto applyLaneChangeAction(Ts &&... xs)
496  {
497  return core->requestLaneChange(std::forward<decltype(xs)>(xs)...);
498  }
499 
500  template <typename... Ts>
501  static auto applySpeedAction(Ts &&... xs)
502  {
503  return core->requestSpeedChange(std::forward<decltype(xs)>(xs)...);
504  }
505 
506  template <typename... Ts>
507  static auto applyTeleportAction(Ts &&... xs)
508  {
509  return core->setEntityStatus(std::forward<decltype(xs)>(xs)...);
510  }
511 
512  template <typename... Ts>
513  static auto applyWalkStraightAction(Ts &&... xs)
514  {
515  return core->requestWalkStraight(std::forward<decltype(xs)>(xs)...);
516  }
517  };
518 
519  // OpenSCENARIO 1.1.1 Section 3.1.5
521  {
522  protected:
523  template <typename... Ts>
524  static auto evaluateAcceleration(Ts &&... xs)
525  {
526  return core->getCurrentAccel(std::forward<decltype(xs)>(xs)...).linear.x;
527  }
528 
529  template <typename... Ts>
530  static auto evaluateCollisionCondition(Ts &&... xs) -> bool
531  {
532  return core->checkCollision(std::forward<decltype(xs)>(xs)...);
533  }
534 
535  template <typename... Ts>
537  const std::string & from_entity_name,
538  const std::string & to_entity_name) // for RelativeDistanceCondition
539  {
540  if (const auto from_entity = core->getEntity(from_entity_name)) {
541  if (const auto to_entity = core->getEntity(to_entity_name)) {
542  if (
544  from_entity->getMapPose(), from_entity->getBoundingBox(), to_entity->getMapPose(),
545  to_entity->getBoundingBox())) {
546  return distance.value();
547  }
548  }
549  }
550  return std::numeric_limits<double>::quiet_NaN();
551  }
552 
553  template <typename... Ts>
554  static auto evaluateSimulationTime(Ts &&... xs) -> double
555  {
556  if (SimulatorCore::active()) {
557  return core->getCurrentTime(std::forward<decltype(xs)>(xs)...);
558  } else {
559  return std::numeric_limits<double>::quiet_NaN();
560  }
561  }
562 
563  template <typename... Ts>
564  static auto evaluateSpeed(Ts &&... xs)
565  {
566  return core->getCurrentTwist(std::forward<decltype(xs)>(xs)...).linear.x;
567  }
568 
569  template <typename... Ts>
570  static auto evaluateStandStill(Ts &&... xs)
571  {
572  return core->getStandStillDuration(std::forward<decltype(xs)>(xs)...);
573  }
574 
575  template <typename... Ts>
576  static auto evaluateTimeHeadway(Ts &&... xs)
577  {
578  if (const auto result = core->getTimeHeadway(std::forward<decltype(xs)>(xs)...); result) {
579  return result.value();
580  } else {
581  using value_type = typename std::decay<decltype(result)>::type::value_type;
582  return std::numeric_limits<value_type>::quiet_NaN();
583  }
584  }
585  };
586 
588  {
589  protected:
590  template <typename Performance, typename Properties>
592  const std::string & entity_ref, const Performance & performance,
593  const Properties & properties)
594  {
595  core->activateOutOfRangeJob(
596  entity_ref, -performance.max_speed, +performance.max_speed, -performance.max_deceleration,
597  +performance.max_acceleration, properties.template get<Double>("minJerk", Double::lowest()),
598  properties.template get<Double>("maxJerk", Double::max()));
599  }
600 
601  template <typename... Ts>
602  static auto asFieldOperatorApplication(Ts &&... xs) -> decltype(auto)
603  {
604  return core->asFieldOperatorApplication(std::forward<decltype(xs)>(xs)...);
605  }
606 
607  static auto activateNonUserDefinedControllers() -> decltype(auto)
608  {
609  return core->startNpcLogic();
610  }
611 
612  template <typename... Ts>
613  static auto evaluateCurrentState(Ts &&... xs) -> decltype(auto)
614  {
615  return core->getCurrentAction(std::forward<decltype(xs)>(xs)...);
616  }
617 
618  template <typename EntityRef, typename OSCLanePosition>
620  const EntityRef & entity_ref, const OSCLanePosition & osc_lane_position)
621  {
622  if (const auto entity = core->getEntity(entity_ref)) {
623  const auto from_map_pose = entity->getMapPose();
624  const auto to_map_pose = static_cast<NativeWorldPosition>(osc_lane_position);
625  if (
626  const auto relative_pose =
627  traffic_simulator::pose::relativePose(from_map_pose, to_map_pose)) {
628  return static_cast<Double>(std::abs(
629  math::geometry::convertQuaternionToEulerAngle(relative_pose.value().orientation).z));
630  }
631  }
632  return Double::nan();
633  }
634 
635  template <typename EntityRef>
636  static auto evaluateRelativeHeading(const EntityRef & entity_ref)
637  {
638  if (const auto entity = core->getEntity(entity_ref)) {
639  if (const auto canonicalized_lanelet_pose = entity->getCanonicalizedLaneletPose()) {
640  return static_cast<Double>(std::abs(
641  static_cast<traffic_simulator::LaneletPose>(canonicalized_lanelet_pose.value()).rpy.z));
642  }
643  }
644  return Double::nan();
645  }
646 
647  template <typename... Ts>
648  static auto sendCooperateCommand(Ts &&... xs) -> decltype(auto)
649  {
650  return asFieldOperatorApplication(core->getEgoName())
651  .sendCooperateCommand(std::forward<decltype(xs)>(xs)...);
652  }
653 
654  // TrafficLights - Conventional and V2I
655  template <typename... Ts>
656  static auto setConventionalTrafficLightsState(Ts &&... xs) -> decltype(auto)
657  {
658  return core->getConventionalTrafficLights()->setTrafficLightsState(
659  std::forward<decltype(xs)>(xs)...);
660  }
661 
662  template <typename... Ts>
663  static auto setConventionalTrafficLightConfidence(Ts &&... xs) -> decltype(auto)
664  {
665  return core->getConventionalTrafficLights()->setTrafficLightsConfidence(
666  std::forward<decltype(xs)>(xs)...);
667  }
668 
669  template <typename... Ts>
670  static auto getConventionalTrafficLightsComposedState(Ts &&... xs) -> decltype(auto)
671  {
672  return core->getConventionalTrafficLights()->getTrafficLightsComposedState(
673  std::forward<decltype(xs)>(xs)...);
674  }
675 
676  template <typename... Ts>
677  static auto compareConventionalTrafficLightsState(Ts &&... xs) -> decltype(auto)
678  {
679  return core->getConventionalTrafficLights()->compareTrafficLightsState(
680  std::forward<decltype(xs)>(xs)...);
681  }
682 
683  template <typename... Ts>
684  static auto resetConventionalTrafficLightPublishRate(Ts &&... xs) -> decltype(auto)
685  {
686  return core->getConventionalTrafficLights()->resetUpdate(std::forward<decltype(xs)>(xs)...);
687  }
688 
689  template <typename... Ts>
690  static auto setV2ITrafficLightsState(Ts &&... xs) -> decltype(auto)
691  {
692  return core->getV2ITrafficLights()->setTrafficLightsState(std::forward<decltype(xs)>(xs)...);
693  }
694 
695  template <typename... Ts>
696  static auto resetV2ITrafficLightPublishRate(Ts &&... xs) -> decltype(auto)
697  {
698  return core->getV2ITrafficLights()->resetUpdate(std::forward<decltype(xs)>(xs)...);
699  }
700  };
701 };
702 } // namespace openscenario_interpreter
703 
704 #endif // OPENSCENARIO_INTERPRETER__SIMULATOR_CORE_HPP_
static auto applyWalkStraightAction(Ts &&... xs)
Definition: simulator_core.hpp:513
static auto applyFollowTrajectoryAction(Ts &&... xs)
Definition: simulator_core.hpp:489
static auto applyAssignRouteAction(Ts &&... xs)
Definition: simulator_core.hpp:477
static auto applySpeedAction(Ts &&... xs)
Definition: simulator_core.hpp:501
static auto applyAcquirePositionAction(const std::string &entity_ref, Ts &&... xs)
Definition: simulator_core.hpp:287
static auto applyAssignControllerAction(const std::string &entity_ref, Controller &&controller) -> void
Definition: simulator_core.hpp:335
static auto applyProfileAction(const EntityRef &entity_ref, const DynamicConstraints &dynamic_constraints) -> void
Definition: simulator_core.hpp:300
static auto applyTeleportAction(Ts &&... xs)
Definition: simulator_core.hpp:507
static auto applyDeleteEntityAction(Ts &&... xs)
Definition: simulator_core.hpp:483
static auto applyLaneChangeAction(Ts &&... xs)
Definition: simulator_core.hpp:495
static auto applyAddEntityAction(Ts &&... xs)
Definition: simulator_core.hpp:294
static auto evaluateBoundingBoxEuclideanDistance(const std::string &from_entity_name, const std::string &to_entity_name)
Definition: simulator_core.hpp:536
static auto evaluateTimeHeadway(Ts &&... xs)
Definition: simulator_core.hpp:576
static auto evaluateCollisionCondition(Ts &&... xs) -> bool
Definition: simulator_core.hpp:530
static auto evaluateSimulationTime(Ts &&... xs) -> double
Definition: simulator_core.hpp:554
static auto evaluateStandStill(Ts &&... xs)
Definition: simulator_core.hpp:570
static auto evaluateSpeed(Ts &&... xs)
Definition: simulator_core.hpp:564
static auto evaluateAcceleration(Ts &&... xs)
Definition: simulator_core.hpp:524
static auto makeNativeRelativeWorldPosition(const std::string &from_entity_name, const std::string &to_entity_name)
Definition: simulator_core.hpp:106
static auto makeNativeBoundingBoxRelativeWorldPosition(const std::string &from_entity_name, const std::string &to_entity_name)
Definition: simulator_core.hpp:230
static auto makeNativeRelativeLanePosition(const std::string &from_entity_name, const NativeLanePosition &to_lanelet_pose, const RoutingAlgorithm::value_type routing_algorithm=RoutingAlgorithm::undefined) -> traffic_simulator::LaneletPose
Definition: simulator_core.hpp:160
static auto makeNativeBoundingBoxRelativeLanePosition(const std::string &from_entity_name, const std::string &to_entity_name, const RoutingAlgorithm::value_type routing_algorithm=RoutingAlgorithm::undefined)
Definition: simulator_core.hpp:184
static auto makeNativeBoundingBoxRelativeLanePosition(const NativeLanePosition &from_lanelet_pose, const traffic_simulator_msgs::msg::BoundingBox &from_bounding_box, const NativeLanePosition &to_lanelet_pose, const traffic_simulator_msgs::msg::BoundingBox &to_bounding_box, const RoutingAlgorithm::value_type routing_algorithm=RoutingAlgorithm::undefined) -> traffic_simulator::LaneletPose
Definition: simulator_core.hpp:216
static auto convert(const NativeLanePosition &native_lane_position) -> NativeWorldPosition
Definition: simulator_core.hpp:101
static auto convert(const NativeWorldPosition &pose) -> NativeLanePosition
Definition: simulator_core.hpp:79
static auto evaluateLateralRelativeLanes(const std::string &from_entity_name, const std::string &to_entity_name, const RoutingAlgorithm::value_type routing_algorithm=RoutingAlgorithm::undefined) -> int
Definition: simulator_core.hpp:260
static auto makeNativeRelativeLanePosition(const NativeLanePosition &from_lanelet_pose, const NativeLanePosition &to_lanelet_pose, const RoutingAlgorithm::value_type routing_algorithm=RoutingAlgorithm::undefined) -> traffic_simulator::LaneletPose
Definition: simulator_core.hpp:174
static auto makeNativeBoundingBoxRelativeWorldPosition(const std::string &from_entity_name, const NativeWorldPosition &to_map_pose)
Definition: simulator_core.hpp:246
static auto makeNativeRelativeLanePosition(const std::string &from_entity_name, const std::string &to_entity_name, const RoutingAlgorithm::value_type routing_algorithm=RoutingAlgorithm::undefined) -> traffic_simulator::LaneletPose
Definition: simulator_core.hpp:146
static auto canonicalize(const traffic_simulator::LaneletPose &non_canonicalized) -> NativeLanePosition
Definition: simulator_core.hpp:72
static auto makeNativeRelativeWorldPosition(const std::string &from_entity_name, const NativeWorldPosition &to_map_pose)
Definition: simulator_core.hpp:120
static auto makeNativeRelativeWorldPosition(const NativeWorldPosition &from_map_pose, const std::string &to_entity_name)
Definition: simulator_core.hpp:133
static auto makeNativeBoundingBoxRelativeLanePosition(const std::string &from_entity_name, const NativeLanePosition &to_lanelet_pose, const RoutingAlgorithm::value_type routing_algorithm=RoutingAlgorithm::undefined)
Definition: simulator_core.hpp:202
static auto evaluateCurrentState(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:613
static auto evaluateRelativeHeading(const EntityRef &entity_ref)
Definition: simulator_core.hpp:636
static auto setV2ITrafficLightsState(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:690
static auto resetV2ITrafficLightPublishRate(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:696
static auto setConventionalTrafficLightsState(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:656
static auto compareConventionalTrafficLightsState(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:677
static auto resetConventionalTrafficLightPublishRate(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:684
static auto evaluateRelativeHeading(const EntityRef &entity_ref, const OSCLanePosition &osc_lane_position)
Definition: simulator_core.hpp:619
static auto getConventionalTrafficLightsComposedState(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:670
static auto sendCooperateCommand(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:648
static auto activatePerformanceAssertion(const std::string &entity_ref, const Performance &performance, const Properties &properties)
Definition: simulator_core.hpp:591
static auto asFieldOperatorApplication(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:602
static auto setConventionalTrafficLightConfidence(Ts &&... xs) -> decltype(auto)
Definition: simulator_core.hpp:663
static auto activateNonUserDefinedControllers() -> decltype(auto)
Definition: simulator_core.hpp:607
Definition: simulator_core.hpp:40
static auto deactivate() -> void
Definition: simulator_core.hpp:58
static auto active()
Definition: simulator_core.hpp:56
static auto activate(const Node &node, const traffic_simulator::Configuration &configuration, Ts &&... xs) -> void
Definition: simulator_core.hpp:45
static auto update() -> void
Definition: simulator_core.hpp:67
Definition: lanelet_pose.hpp:27
auto convertQuaternionToEulerAngle(const T &q)
Definition: quaternion_to_euler.hpp:30
Definition: escape_sequence.hpp:22
traffic_simulator::CanonicalizedLaneletPose NativeLanePosition
Definition: simulator_core.hpp:35
geometry_msgs::msg::Pose NativeWorldPosition
Definition: simulator_core.hpp:31
traffic_simulator::LaneletPose NativeRelativeLanePosition
Definition: simulator_core.hpp:37
NativeWorldPosition NativeRelativeWorldPosition
Definition: simulator_core.hpp:33
auto distance(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2)
Definition: detection_sensor.cpp:34
auto countLaneChanges(const CanonicalizedLaneletPose &from, const CanonicalizedLaneletPose &to, bool allow_lane_change, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils_ptr) -> std::optional< std::pair< int, int >>
Definition: distance.cpp:48
auto boundingBoxDistance(const geometry_msgs::msg::Pose &from, const traffic_simulator_msgs::msg::BoundingBox &from_bounding_box, const geometry_msgs::msg::Pose &to, const traffic_simulator_msgs::msg::BoundingBox &to_bounding_box) -> std::optional< double >
Definition: distance.cpp:131
auto boundingBoxRelativeLaneletPose(const CanonicalizedLaneletPose &from, const traffic_simulator_msgs::msg::BoundingBox &from_bounding_box, const CanonicalizedLaneletPose &to, const traffic_simulator_msgs::msg::BoundingBox &to_bounding_box, const bool allow_lane_change, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils_ptr) -> LaneletPose
Definition: pose.cpp:201
auto quietNaNPose() -> geometry_msgs::msg::Pose
Definition: pose.cpp:25
auto quietNaNLaneletPose() -> LaneletPose
Definition: pose.cpp:35
auto relativeLaneletPose(const CanonicalizedLaneletPose &from, const CanonicalizedLaneletPose &to, const bool allow_lane_change, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils_ptr) -> LaneletPose
Definition: pose.cpp:178
auto boundingBoxRelativePose(const geometry_msgs::msg::Pose &from, const traffic_simulator_msgs::msg::BoundingBox &from_bounding_box, const geometry_msgs::msg::Pose &to, const traffic_simulator_msgs::msg::BoundingBox &to_bounding_box) -> std::optional< geometry_msgs::msg::Pose >
Definition: pose.cpp:158
auto relativePose(const geometry_msgs::msg::Pose &from, const geometry_msgs::msg::Pose &to) -> std::optional< geometry_msgs::msg::Pose >
Definition: pose.cpp:136
auto toCanonicalizedLaneletPose(const geometry_msgs::msg::Pose &map_pose, const bool include_crosswalk, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils_ptr) -> std::optional< CanonicalizedLaneletPose >
Definition: pose.cpp:73
auto toMapPose(const CanonicalizedLaneletPose &lanelet_pose) -> geometry_msgs::msg::Pose
Definition: pose.cpp:59
traffic_simulator_msgs::msg::LaneletPose LaneletPose
Definition: lanelet_pose.hpp:22
Definition: junit5.hpp:25
std::string string
Definition: junit5.hpp:26
Definition: exception.hpp:27
Definition: controller.hpp:46
Definition: double.hpp:25
Definition: dynamic_constraints.hpp:44
Definition: entity_ref.hpp:35
Definition: performance.hpp:39
const Double max_deceleration
Definition: performance.hpp:44
const Double max_acceleration
Definition: performance.hpp:40
const Double max_speed
Definition: performance.hpp:48
Definition: properties.hpp:42
Definition: configuration.hpp:29
traffic_simulator::lanelet_pose::CanonicalizedLaneletPose CanonicalizedLaneletPose
Definition: test_lanelet_pose.cpp:21