scenario_simulator_v2 C++ API
entity_manager.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 TRAFFIC_SIMULATOR__ENTITY__ENTITY_MANAGER_HPP_
16 #define TRAFFIC_SIMULATOR__ENTITY__ENTITY_MANAGER_HPP_
17 
18 #include <tf2/LinearMath/Quaternion.h>
19 #include <tf2_ros/static_transform_broadcaster.h>
20 #include <tf2_ros/transform_broadcaster.h>
21 
22 #include <autoware_perception_msgs/msg/traffic_signal_array.hpp>
23 #include <memory>
24 #include <optional>
25 #include <rclcpp/node_interfaces/get_node_topics_interface.hpp>
26 #include <rclcpp/node_interfaces/node_topics_interface.hpp>
27 #include <rclcpp/rclcpp.hpp>
29 #include <stdexcept>
30 #include <string>
31 #include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
46 #include <traffic_simulator_msgs/msg/behavior_parameter.hpp>
47 #include <traffic_simulator_msgs/msg/bounding_box.hpp>
48 #include <traffic_simulator_msgs/msg/entity_status_with_trajectory_array.hpp>
49 #include <traffic_simulator_msgs/msg/traffic_light_array_v1.hpp>
50 #include <traffic_simulator_msgs/msg/vehicle_parameters.hpp>
51 #include <type_traits>
52 #include <unordered_map>
53 #include <utility>
54 #include <vector>
55 #include <visualization_msgs/msg/marker_array.hpp>
56 
57 namespace traffic_simulator
58 {
59 namespace entity
60 {
61 class LaneletMarkerQoS : public rclcpp::QoS
62 {
63 public:
64  explicit LaneletMarkerQoS(std::size_t depth = 1) : rclcpp::QoS(depth) { transient_local(); }
65 };
66 
67 class EntityMarkerQoS : public rclcpp::QoS
68 {
69 public:
70  explicit EntityMarkerQoS(std::size_t depth = 100) : rclcpp::QoS(depth) {}
71 };
72 
74 {
75  Configuration configuration;
76 
77  std::shared_ptr<rclcpp::node_interfaces::NodeTopicsInterface> node_topics_interface;
78  const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr node_parameters_;
79 
80  tf2_ros::StaticTransformBroadcaster broadcaster_;
81  tf2_ros::TransformBroadcaster base_link_broadcaster_;
82 
83  const rclcpp::Clock::SharedPtr clock_ptr_;
84 
85  std::unordered_map<std::string, std::shared_ptr<traffic_simulator::entity::EntityBase>> entities_;
86 
87  double step_time_;
88 
89  double current_time_;
90 
91  bool npc_logic_started_;
92 
93  using EntityStatusWithTrajectoryArray =
94  traffic_simulator_msgs::msg::EntityStatusWithTrajectoryArray;
95  const rclcpp::Publisher<EntityStatusWithTrajectoryArray>::SharedPtr entity_status_array_pub_ptr_;
96 
97  using MarkerArray = visualization_msgs::msg::MarkerArray;
98  const rclcpp::Publisher<MarkerArray>::SharedPtr lanelet_marker_pub_ptr_;
99 
100  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils_ptr_;
101 
102  MarkerArray markers_raw_;
103 
104  const std::shared_ptr<TrafficLightManager> conventional_traffic_light_manager_ptr_;
105  const std::shared_ptr<TrafficLightMarkerPublisher>
106  conventional_traffic_light_marker_publisher_ptr_;
107  const std::shared_ptr<TrafficLightPublisherBase>
108  conventional_backward_compatible_traffic_light_publisher_ptr_;
109  const std::shared_ptr<TrafficLightManager> v2i_traffic_light_manager_ptr_;
110  const std::shared_ptr<TrafficLightMarkerPublisher> v2i_traffic_light_marker_publisher_ptr_;
111  const std::shared_ptr<TrafficLightPublisherBase> v2i_traffic_light_legacy_topic_publisher_ptr_;
112  const std::shared_ptr<TrafficLightPublisherBase> v2i_traffic_light_publisher_ptr_;
113  ConfigurableRateUpdater v2i_traffic_light_updater_, conventional_traffic_light_updater_;
114 
115 public:
116  template <typename Node>
117  auto getOrigin(Node & node) const
118  {
119  geographic_msgs::msg::GeoPoint origin;
120  {
121  if (!node.has_parameter("origin_latitude")) {
122  node.declare_parameter("origin_latitude", 0.0);
123  }
124  if (!node.has_parameter("origin_longitude")) {
125  node.declare_parameter("origin_longitude", 0.0);
126  }
127  node.get_parameter("origin_latitude", origin.latitude);
128  node.get_parameter("origin_longitude", origin.longitude);
129  }
130 
131  return origin;
132  }
133 
134  template <typename... Ts>
135  auto makeV2ITrafficLightPublisher(Ts &&... xs) -> std::shared_ptr<TrafficLightPublisherBase>
136  {
137  if (const auto architecture_type =
138  getParameter<std::string>(node_parameters_, "architecture_type", "awf/universe");
139  architecture_type.find("awf/universe") != std::string::npos) {
140  return std::make_shared<
142  std::forward<decltype(xs)>(xs)...);
143  } else {
144  throw common::SemanticError(
145  "Unexpected architecture_type ", std::quoted(architecture_type),
146  " given for V2I traffic lights simulation.");
147  }
148  }
149 
150  template <class NodeT, class AllocatorT = std::allocator<void>>
151  explicit EntityManager(
152  NodeT && node, const Configuration & configuration,
153  const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node_parameters)
154  : configuration(configuration),
155  node_topics_interface(rclcpp::node_interfaces::get_node_topics_interface(node)),
156  node_parameters_(node_parameters),
157  broadcaster_(node),
158  base_link_broadcaster_(node),
159  clock_ptr_(node->get_clock()),
160  current_time_(std::numeric_limits<double>::quiet_NaN()),
161  npc_logic_started_(false),
162  entity_status_array_pub_ptr_(rclcpp::create_publisher<EntityStatusWithTrajectoryArray>(
163  node, "entity/status", EntityMarkerQoS(),
164  rclcpp::PublisherOptionsWithAllocator<AllocatorT>())),
165  lanelet_marker_pub_ptr_(rclcpp::create_publisher<MarkerArray>(
166  node, "lanelet/marker", LaneletMarkerQoS(),
167  rclcpp::PublisherOptionsWithAllocator<AllocatorT>())),
168  hdmap_utils_ptr_(std::make_shared<hdmap_utils::HdMapUtils>(
169  configuration.lanelet2_map_path(), getOrigin(*node))),
170  markers_raw_(hdmap_utils_ptr_->generateMarker()),
171  conventional_traffic_light_manager_ptr_(
172  std::make_shared<TrafficLightManager>(hdmap_utils_ptr_)),
173  conventional_traffic_light_marker_publisher_ptr_(
174  std::make_shared<TrafficLightMarkerPublisher>(conventional_traffic_light_manager_ptr_, node)),
175  conventional_backward_compatible_traffic_light_publisher_ptr_(
176  std::make_shared<TrafficLightPublisher<traffic_simulator_msgs::msg::TrafficLightArrayV1>>(
177  "/simulation/traffic_lights", node, hdmap_utils_ptr_)),
178  v2i_traffic_light_manager_ptr_(std::make_shared<TrafficLightManager>(hdmap_utils_ptr_)),
179  v2i_traffic_light_marker_publisher_ptr_(
180  std::make_shared<TrafficLightMarkerPublisher>(v2i_traffic_light_manager_ptr_, node)),
181  v2i_traffic_light_legacy_topic_publisher_ptr_(
182  makeV2ITrafficLightPublisher("/v2x/traffic_signals", node, hdmap_utils_ptr_)),
183  v2i_traffic_light_publisher_ptr_(makeV2ITrafficLightPublisher(
184  "/perception/traffic_light_recognition/external/traffic_signals", node, hdmap_utils_ptr_)),
185  v2i_traffic_light_updater_(
186  node,
187  [this]() {
188  v2i_traffic_light_marker_publisher_ptr_->publish();
189  v2i_traffic_light_publisher_ptr_->publish(
190  clock_ptr_->now(), v2i_traffic_light_manager_ptr_->generateUpdateTrafficLightsRequest());
191  v2i_traffic_light_legacy_topic_publisher_ptr_->publish(
192  clock_ptr_->now(), v2i_traffic_light_manager_ptr_->generateUpdateTrafficLightsRequest());
193  }),
194  conventional_traffic_light_updater_(node, [this]() {
195  conventional_traffic_light_marker_publisher_ptr_->publish();
196  conventional_backward_compatible_traffic_light_publisher_ptr_->publish(
197  clock_ptr_->now(),
198  conventional_traffic_light_manager_ptr_->generateUpdateTrafficLightsRequest());
199  })
200  {
202  }
203 
204  ~EntityManager() = default;
205 
206 public:
207 #define FORWARD_GETTER_TO_TRAFFIC_LIGHT_MANAGER(NAME) \
208  template <typename... Ts> \
209  decltype(auto) getConventional##NAME(Ts &&... xs) const \
210  { \
211  return conventional_traffic_light_manager_ptr_->get##NAME(xs...); \
212  } \
213  static_assert(true, ""); \
214  template <typename... Ts> \
215  decltype(auto) getV2I##NAME(Ts &&... xs) const \
216  { \
217  return v2i_traffic_light_manager_ptr_->get##NAME(xs...); \
218  } \
219  static_assert(true, "")
220 
223 
224 #undef FORWARD_GETTER_TO_TRAFFIC_LIGHT_MANAGER
225 
227  {
228  return conventional_traffic_light_manager_ptr_->generateUpdateTrafficLightsRequest();
229  }
230 
232  {
233  conventional_traffic_light_updater_.resetUpdateRate(rate);
234  }
235 
236  auto resetV2ITrafficLightPublishRate(double rate) -> void
237  {
238  v2i_traffic_light_updater_.resetUpdateRate(rate);
239  }
240 
241  auto setConventionalTrafficLightConfidence(lanelet::Id id, double confidence) -> void
242  {
243  for (auto & traffic_light : conventional_traffic_light_manager_ptr_->getTrafficLights(id)) {
244  traffic_light.get().confidence = confidence;
245  }
246  }
247 
248  // clang-format off
249 #define FORWARD_TO_HDMAP_UTILS(NAME) \
250  \
255  template <typename... Ts> \
256  decltype(auto) NAME(Ts &&... xs) const \
257  { \
258  return hdmap_utils_ptr_->NAME(std::forward<decltype(xs)>(xs)...); \
259  } \
260  static_assert(true, "")
261  // clang-format on
262 
265  // FORWARD_TO_HDMAP_UTILS(toMapPose);
266 
267 #undef FORWARD_TO_HDMAP_UTILS
268 
269  // clang-format off
270 #define FORWARD_TO_ENTITY(IDENTIFIER, ...) \
271  \
276  template <typename... Ts> \
277  decltype(auto) IDENTIFIER(const std::string & name, Ts &&... xs) __VA_ARGS__ \
278  try { \
279  return entities_.at(name)->IDENTIFIER(std::forward<decltype(xs)>(xs)...); \
280  } catch (const std::out_of_range &) { \
281  THROW_SEMANTIC_ERROR("entity : ", name, "does not exist"); \
282  } \
283  static_assert(true, "")
284  // clang-format on
285 
329 
330 #undef FORWARD_TO_ENTITY
331 
332  visualization_msgs::msg::MarkerArray makeDebugMarker() const;
333 
334  bool trafficLightsChanged();
335 
336  void requestSpeedChange(const std::string & name, double target_speed, bool continuous);
337 
338  void requestSpeedChange(
339  const std::string & name, const double target_speed, const speed_change::Transition transition,
340  const speed_change::Constraint constraint, const bool continuous);
341 
342  void requestSpeedChange(
343  const std::string & name, const speed_change::RelativeTargetSpeed & target_speed,
344  bool continuous);
345 
346  void requestSpeedChange(
347  const std::string & name, const speed_change::RelativeTargetSpeed & target_speed,
348  const speed_change::Transition transition, const speed_change::Constraint constraint,
349  const bool continuous);
350 
351  auto updateNpcLogic(const std::string & name) -> const CanonicalizedEntityStatus &;
352 
354 
355  void broadcastTransform(
356  const geometry_msgs::msg::PoseStamped & pose, const bool static_transform = true);
357 
358  bool checkCollision(const std::string & name0, const std::string & name1);
359 
360  bool despawnEntity(const std::string & name);
361 
362  bool entityExists(const std::string & name);
363 
364  auto getCurrentTime() const noexcept -> double;
365 
366  auto getEntityNames() const -> const std::vector<std::string>;
367 
368  auto getEntity(const std::string & name) const
369  -> std::shared_ptr<traffic_simulator::entity::EntityBase>;
370 
371  auto getEntityStatus(const std::string & name) const -> CanonicalizedEntityStatus;
372 
373  auto getHdmapUtils() -> const std::shared_ptr<hdmap_utils::HdMapUtils> &;
374 
375  auto getNumberOfEgo() const -> std::size_t;
376 
377  auto getObstacle(const std::string & name)
378  -> std::optional<traffic_simulator_msgs::msg::Obstacle>;
379 
380  auto getPedestrianParameters(const std::string & name) const
381  -> const traffic_simulator_msgs::msg::PedestrianParameters &;
382 
383  auto getStepTime() const noexcept -> double;
384 
385  auto getVehicleParameters(const std::string & name) const
386  -> const traffic_simulator_msgs::msg::VehicleParameters &;
387 
388  auto getWaypoints(const std::string & name) -> traffic_simulator_msgs::msg::WaypointsArray;
389 
390  template <typename T>
391  auto getGoalPoses(const std::string & name) -> std::vector<T>
392  {
393  if constexpr (std::is_same_v<std::decay_t<T>, CanonicalizedLaneletPose>) {
394  if (not npc_logic_started_) {
395  return {};
396  } else {
397  return entities_.at(name)->getGoalPoses();
398  }
399  } else {
400  if (not npc_logic_started_) {
401  return {};
402  } else {
403  std::vector<geometry_msgs::msg::Pose> poses;
404  for (const auto & lanelet_pose : getGoalPoses<CanonicalizedLaneletPose>(name)) {
405  poses.push_back(toMapPose(lanelet_pose));
406  }
407  return poses;
408  }
409  }
410  }
411 
412  template <typename EntityType>
413  bool is(const std::string & name) const
414  {
415  return dynamic_cast<EntityType const *>(entities_.at(name).get()) != nullptr;
416  }
417 
418  bool isEgoSpawned() const;
419 
420  const std::string getEgoName() const;
421 
422  bool isInLanelet(const std::string & name, const lanelet::Id lanelet_id, const double tolerance);
423 
424  bool isStopping(const std::string & name) const;
425 
426  void requestLaneChange(
427  const std::string & name, const traffic_simulator::lane_change::Direction & direction);
428 
437  void resetBehaviorPlugin(const std::string & name, const std::string & behavior_plugin_name);
438 
439  auto setEntityStatus(const std::string & name, const CanonicalizedEntityStatus &) -> void;
440 
441  void setVerbose(const bool verbose);
442 
443  template <typename Entity, typename Pose, typename Parameters, typename... Ts>
444  auto spawnEntity(
445  const std::string & name, const Pose & pose, const Parameters & parameters, Ts &&... xs)
446  {
447  auto makeEntityStatus = [&]() {
448  EntityStatus entity_status;
449 
450  if constexpr (std::is_same_v<std::decay_t<Entity>, EgoEntity>) {
451  if (auto iter = std::find_if(
452  std::begin(entities_), std::end(entities_),
453  [this](auto && each) { return is<EgoEntity>(each.first); });
454  iter != std::end(entities_)) {
455  THROW_SEMANTIC_ERROR("multi ego simulation does not support yet");
456  } else {
457  entity_status.type.type = traffic_simulator_msgs::msg::EntityType::EGO;
458  }
459  } else if constexpr (std::is_same_v<std::decay_t<Entity>, VehicleEntity>) {
460  entity_status.type.type = traffic_simulator_msgs::msg::EntityType::VEHICLE;
461  } else if constexpr (std::is_same_v<std::decay_t<Entity>, PedestrianEntity>) {
462  entity_status.type.type = traffic_simulator_msgs::msg::EntityType::PEDESTRIAN;
463  } else {
464  entity_status.type.type = traffic_simulator_msgs::msg::EntityType::MISC_OBJECT;
465  }
466 
467  entity_status.subtype = parameters.subtype;
468 
469  entity_status.time = getCurrentTime();
470 
471  entity_status.name = name;
472 
473  entity_status.bounding_box = parameters.bounding_box;
474 
475  entity_status.action_status = traffic_simulator_msgs::msg::ActionStatus();
476  entity_status.action_status.current_action = "waiting for initialize";
477 
478  if constexpr (std::is_same_v<std::decay_t<Pose>, CanonicalizedLaneletPose>) {
479  entity_status.pose = toMapPose(pose);
480  entity_status.lanelet_pose = static_cast<LaneletPose>(pose);
481  entity_status.lanelet_pose_valid = true;
482  } else {
484  if (const auto lanelet_pose = toLaneletPose(
485  pose, parameters.bounding_box,
486  entity_status.type.type == traffic_simulator_msgs::msg::EntityType::PEDESTRIAN ||
487  entity_status.type.type == traffic_simulator_msgs::msg::EntityType::MISC_OBJECT,
488  [](const auto & parameters) {
489  if constexpr (std::is_same_v<
490  std::decay_t<Parameters>,
491  traffic_simulator_msgs::msg::VehicleParameters>) {
492  return std::max(
493  parameters.axles.front_axle.track_width,
494  parameters.axles.rear_axle.track_width) *
495  0.5 +
496  1.0;
497  } else {
498  return parameters.bounding_box.dimensions.y * 0.5 + 1.0;
499  }
500  }(parameters));
501  lanelet_pose) {
502  entity_status.lanelet_pose = *lanelet_pose;
503  entity_status.lanelet_pose_valid = true;
505  if (getParameter<bool>(node_parameters_, "consider_pose_by_road_slope", false)) {
506  entity_status.pose = hdmap_utils_ptr_->toMapPose(*lanelet_pose).pose;
507  } else {
508  entity_status.pose = pose;
509  }
510  } else {
511  entity_status.lanelet_pose_valid = false;
512  entity_status.pose = pose;
513  }
514  }
515 
516  return CanonicalizedEntityStatus(entity_status, hdmap_utils_ptr_);
517  };
518 
519  if (const auto [iter, success] = entities_.emplace(
520  name, std::make_unique<Entity>(
521  name, makeEntityStatus(), hdmap_utils_ptr_, parameters,
522  std::forward<decltype(xs)>(xs)...));
523  success) {
524  // FIXME: this ignores V2I traffic lights
525  iter->second->setTrafficLightManager(conventional_traffic_light_manager_ptr_);
526  if (npc_logic_started_ && not is<EgoEntity>(name)) {
527  iter->second->startNpcLogic(getCurrentTime());
528  }
529  return success;
530  } else {
531  THROW_SEMANTIC_ERROR("Entity ", std::quoted(name), " is already exists.");
532  }
533  }
534 
535  auto toMapPose(const CanonicalizedLaneletPose &) const -> const geometry_msgs::msg::Pose;
536 
537  template <typename MessageT, typename... Args>
538  auto createPublisher(Args &&... args)
539  {
540  return rclcpp::create_publisher<MessageT>(node_topics_interface, std::forward<Args>(args)...);
541  }
542 
543  template <typename MessageT, typename... Args>
544  auto createSubscription(Args &&... args)
545  {
546  return rclcpp::create_subscription<MessageT>(
547  node_topics_interface, std::forward<Args>(args)...);
548  }
549 
550  void update(const double current_time, const double step_time);
551 
552  void updateHdmapMarker();
553 
554  void startNpcLogic(const double current_time);
555 
556  auto isNpcLogicStarted() const { return npc_logic_started_; }
557 };
558 } // namespace entity
559 } // namespace traffic_simulator
560 
561 #endif // TRAFFIC_SIMULATOR__ENTITY__ENTITY_MANAGER_HPP_
Definition: configurable_rate_updater.hpp:24
auto resetUpdateRate(double update_rate) -> void
Definition: configurable_rate_updater.cpp:30
Definition: traffic_light_manager.hpp:34
Definition: traffic_light_marker_publisher.hpp:23
Definition: traffic_light_publisher.hpp:36
Definition: entity_base.hpp:51
Definition: entity_manager.hpp:74
auto getGoalPoses(const std::string &name) -> std::vector< T >
Definition: entity_manager.hpp:383
void resetBehaviorPlugin(const std::string &name, const std::string &behavior_plugin_name)
Reset behavior plugin of the target entity. The internal behavior is to take over the various paramet...
Definition: entity_manager.cpp:302
bool is(const std::string &name) const
Definition: entity_manager.hpp:405
decltype(auto) requestLaneChange(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: requestLaneChange function.
Definition: entity_manager.hpp:305
auto generateUpdateRequestForConventionalTrafficLights()
Definition: entity_manager.hpp:226
decltype(auto) getLaneletLength(Ts &&... xs) const
Forward to arguments to the HDMapUtils:: getLaneletLength function.
Definition: entity_manager.hpp:259
void updateHdmapMarker()
Definition: entity_manager.cpp:464
decltype(auto) getEntityTypename(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getEntityTypename function.
Definition: entity_manager.hpp:290
void broadcastEntityTransform()
Definition: entity_manager.cpp:40
decltype(auto) reachPosition(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: reachPosition function.
Definition: entity_manager.hpp:289
auto getStepTime() const noexcept -> double
Definition: entity_manager.cpp:228
decltype(auto) getBoundingBox(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getBoundingBox function.
Definition: entity_manager.hpp:282
auto resetV2ITrafficLightPublishRate(double rate) -> void
Definition: entity_manager.hpp:236
decltype(auto) requestAssignRoute(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: requestAssignRoute function.
Definition: entity_manager.hpp:303
decltype(auto) getCurrentAction(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getCurrentAction function.
Definition: entity_manager.hpp:284
decltype(auto) getDefaultMatchingDistanceForLaneletPoseCalculation(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getDefaultMatchingDistanceForLaneletPoseCalculation function...
Definition: entity_manager.hpp:286
decltype(auto) getEntityType(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getEntityType function.
Definition: entity_manager.hpp:288
decltype(auto) getTraveledDistance(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getTraveledDistance function.
Definition: entity_manager.hpp:297
decltype(auto) setLinearVelocity(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setLinearVelocity function.
Definition: entity_manager.hpp:317
bool despawnEntity(const std::string &name)
Definition: entity_manager.cpp:132
decltype(auto) getStandStillDuration(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getStandStillDuration function.
Definition: entity_manager.hpp:296
decltype(auto) getMapPoseFromRelativePose(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getMapPoseFromRelativePose function.
Definition: entity_manager.hpp:294
auto getEntityNames() const -> const std::vector< std::string >
Definition: entity_manager.cpp:144
auto toMapPose(const CanonicalizedLaneletPose &) const -> const geometry_msgs::msg::Pose
Definition: entity_manager.cpp:397
const std::string getEgoName() const
Definition: entity_manager.cpp:195
decltype(auto) setDecelerationLimit(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setDecelerationLimit function.
Definition: entity_manager.hpp:314
decltype(auto) setAccelerationRateLimit(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setAccelerationRateLimit function.
Definition: entity_manager.hpp:311
decltype(auto) requestFollowTrajectory(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: requestFollowTrajectory function.
Definition: entity_manager.hpp:304
decltype(auto) fillLaneletPose(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: fillLaneletPose function.
Definition: entity_manager.hpp:279
auto updateNpcLogic(const std::string &name) -> const CanonicalizedEntityStatus &
Definition: entity_manager.cpp:403
decltype(auto) getCurrentAccel(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getCurrentAccel function.
Definition: entity_manager.hpp:283
decltype(auto) requestAcquirePosition(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: requestAcquirePosition function.
Definition: entity_manager.hpp:302
void setVerbose(const bool verbose)
Definition: entity_manager.cpp:389
auto spawnEntity(const std::string &name, const Pose &pose, const Parameters &parameters, Ts &&... xs)
Definition: entity_manager.hpp:436
decltype(auto) activateOutOfRangeJob(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: activateOutOfRangeJob function.
Definition: entity_manager.hpp:299
decltype(auto) setDecelerationRateLimit(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setDecelerationRateLimit function.
Definition: entity_manager.hpp:315
bool checkCollision(const std::string &name0, const std::string &name1)
Definition: entity_manager.cpp:116
bool isEgoSpawned() const
Definition: entity_manager.cpp:250
decltype(auto) toLaneletPose(Ts &&... xs) const
Forward to arguments to the HDMapUtils:: toLaneletPose function.
Definition: entity_manager.hpp:260
auto getCurrentTime() const noexcept -> double
Definition: entity_manager.cpp:142
decltype(auto) getEntityStatusBeforeUpdate(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getEntityStatusBeforeUpdate function.
Definition: entity_manager.hpp:287
decltype(auto) isControlledBySimulator(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: isControlledBySimulator function.
Definition: entity_manager.hpp:301
decltype(auto) getLaneletPose(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getLaneletPose function.
Definition: entity_manager.hpp:291
decltype(auto) getLinearJerk(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getLinearJerk function.
Definition: entity_manager.hpp:292
decltype(auto) setAcceleration(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setAcceleration function.
Definition: entity_manager.hpp:309
decltype(auto) requestClearRoute(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: requestClearRoute function.
Definition: entity_manager.hpp:308
bool entityExists(const std::string &name)
Definition: entity_manager.cpp:137
auto getWaypoints(const std::string &name) -> traffic_simulator_msgs::msg::WaypointsArray
Definition: entity_manager.cpp:241
decltype(auto) getBehaviorParameter(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getBehaviorParameter function.
Definition: entity_manager.hpp:281
auto getEntityStatus(const std::string &name) const -> CanonicalizedEntityStatus
Definition: entity_manager.cpp:170
bool trafficLightsChanged()
Definition: entity_manager.cpp:332
decltype(auto) getRouteLanelets(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getRouteLanelets function.
Definition: entity_manager.hpp:295
decltype(auto) setMapPose(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setMapPose function.
Definition: entity_manager.hpp:318
decltype(auto) get2DPolygon(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: get2DPolygon function.
Definition: entity_manager.hpp:280
decltype(auto) requestWalkStraight(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: requestWalkStraight function.
Definition: entity_manager.hpp:307
decltype(auto) setLinearJerk(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setLinearJerk function.
Definition: entity_manager.hpp:316
decltype(auto) getMapPose(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getMapPose function.
Definition: entity_manager.hpp:293
auto setEntityStatus(const std::string &name, const CanonicalizedEntityStatus &) -> void
Definition: entity_manager.cpp:377
decltype(auto) requestSynchronize(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: requestSynchronize function.
Definition: entity_manager.hpp:306
decltype(auto) setAccelerationLimit(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setAccelerationLimit function.
Definition: entity_manager.hpp:310
EntityManager(NodeT &&node, const Configuration &configuration, const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &node_parameters)
Definition: entity_manager.hpp:151
auto getHdmapUtils() -> const std::shared_ptr< hdmap_utils::HdMapUtils > &
Definition: entity_manager.cpp:183
auto getPedestrianParameters(const std::string &name) const -> const traffic_simulator_msgs::msg::PedestrianParameters &
Definition: entity_manager.cpp:217
auto getOrigin(Node &node) const
Definition: entity_manager.hpp:117
bool isInLanelet(const std::string &name, const lanelet::Id lanelet_id, const double tolerance)
Definition: entity_manager.cpp:260
decltype(auto) setBehaviorParameter(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setBehaviorParameter function.
Definition: entity_manager.hpp:312
void broadcastTransform(const geometry_msgs::msg::PoseStamped &pose, const bool static_transform=true)
Definition: entity_manager.cpp:95
auto getEntity(const std::string &name) const -> std::shared_ptr< traffic_simulator::entity::EntityBase >
Definition: entity_manager.cpp:153
visualization_msgs::msg::MarkerArray makeDebugMarker() const
Definition: entity_manager.cpp:123
auto getVehicleParameters(const std::string &name) const -> const traffic_simulator_msgs::msg::VehicleParameters &
Definition: entity_manager.cpp:230
auto setConventionalTrafficLightConfidence(lanelet::Id id, double confidence) -> void
Definition: entity_manager.hpp:241
auto resetConventionalTrafficLightPublishRate(double rate) -> void
Definition: entity_manager.hpp:231
decltype(auto) laneMatchingSucceed(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: laneMatchingSucceed function.
Definition: entity_manager.hpp:298
void requestSpeedChange(const std::string &name, double target_speed, bool continuous)
Definition: entity_manager.cpp:338
decltype(auto) getCurrentTwist(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: getCurrentTwist function.
Definition: entity_manager.hpp:285
decltype(auto) setVelocityLimit(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setVelocityLimit function.
Definition: entity_manager.hpp:320
auto getObstacle(const std::string &name) -> std::optional< traffic_simulator_msgs::msg::Obstacle >
Definition: entity_manager.cpp:208
decltype(auto) setControlledBySimulator(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setControlledBySimulator function.
Definition: entity_manager.hpp:313
auto makeV2ITrafficLightPublisher(Ts &&... xs) -> std::shared_ptr< TrafficLightPublisherBase >
Definition: entity_manager.hpp:135
decltype(auto) asFieldOperatorApplication(const std::string &name, Ts &&... xs) const
Forward to arguments to the EntityBase:: asFieldOperatorApplication function.
Definition: entity_manager.hpp:278
auto getNumberOfEgo() const -> std::size_t
Definition: entity_manager.cpp:188
decltype(auto) setTwist(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: setTwist function.
Definition: entity_manager.hpp:319
decltype(auto) cancelRequest(const std::string &name, Ts &&... xs)
Forward to arguments to the EntityBase:: cancelRequest function.
Definition: entity_manager.hpp:300
bool isStopping(const std::string &name) const
Definition: entity_manager.cpp:285
Definition: entity_manager.hpp:68
EntityMarkerQoS(std::size_t depth=100)
Definition: entity_manager.hpp:70
Definition: entity_manager.hpp:62
LaneletMarkerQoS(std::size_t depth=1)
Definition: entity_manager.hpp:64
Definition: entity_status.hpp:29
Definition: lanelet_pose.hpp:27
#define THROW_SEMANTIC_ERROR(...)
Definition: exception.hpp:59
#define FORWARD_TO_ENTITY(IDENTIFIER,...)
Definition: entity_manager.hpp:266
#define FORWARD_GETTER_TO_TRAFFIC_LIGHT_MANAGER(NAME)
Definition: entity_manager.hpp:207
#define FORWARD_TO_HDMAP_UTILS(NAME)
Definition: entity_manager.hpp:249
auto makeEntityStatus(std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils, traffic_simulator::lanelet_pose::CanonicalizedLaneletPose pose, traffic_simulator_msgs::msg::BoundingBox bbox, const double speed=0.0, const std::string name="default_entity_name", const uint8_t type=traffic_simulator_msgs::msg::EntityType::VEHICLE) -> traffic_simulator::EntityStatus
Definition: helper_functions.hpp:82
Definition: cache.hpp:46
Definition: cache.hpp:27
Direction
Definition: lane_change.hpp:29
auto toMapPose(const CanonicalizedLaneletPose &lanelet_pose) -> const geometry_msgs::msg::Pose
Definition: pose.cpp:53
Transition
Definition: speed_change.hpp:26
Definition: api.hpp:48
traffic_simulator_msgs::msg::LaneletPose LaneletPose
Definition: lanelet_pose.hpp:22
traffic_simulator_msgs::msg::EntityStatus EntityStatus
Definition: entity_status.hpp:24
Definition: junit5.hpp:25
std::string string
Definition: junit5.hpp:26
Although there were no syntactic errors in the description of the scenario, differences in meaning an...
Definition: exception.hpp:44
Definition: configuration.hpp:30
Definition: traffic_light.hpp:40
Definition: speed_change.hpp:35
class definition of the traffic sink