scenario_simulator_v2 C++ API
behavior_plugin_base.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__BEHAVIOR__BEHAVIOR_PLUGIN_BASE_HPP_
16 #define TRAFFIC_SIMULATOR__BEHAVIOR__BEHAVIOR_PLUGIN_BASE_HPP_
17 
19 #include <optional>
20 #include <string>
26 #include <traffic_simulator_msgs/msg/behavior_parameter.hpp>
27 #include <traffic_simulator_msgs/msg/entity_type.hpp>
28 #include <traffic_simulator_msgs/msg/obstacle.hpp>
29 #include <traffic_simulator_msgs/msg/pedestrian_parameters.hpp>
30 #include <traffic_simulator_msgs/msg/vehicle_parameters.hpp>
31 #include <traffic_simulator_msgs/msg/waypoints_array.hpp>
32 #include <unordered_map>
33 #include <visualization_msgs/msg/marker_array.hpp>
34 
35 namespace entity_behavior
36 {
38  std::unordered_map<std::string, traffic_simulator::CanonicalizedEntityStatus>;
39 
40 using EuclideanDistancesMap = std::unordered_map<std::pair<std::string, std::string>, double>;
41 
43 {
44 public:
45  virtual ~BehaviorPluginBase() = default;
46  virtual auto configure(const rclcpp::Logger & logger) -> void = 0;
47  virtual auto update(const double current_time, const double step_time) -> void = 0;
48  virtual auto getCurrentAction() const -> const std::string & = 0;
49 
50  // clang-format off
51 #define DEFINE_GETTER_SETTER(NAME, KEY, TYPE) \
52  virtual auto get##NAME() -> TYPE = 0; \
53  virtual auto set##NAME(const TYPE & value) -> void = 0; \
54  /* */ auto get##NAME##Key() const -> const std::string & \
55  { \
56  static const std::string key = KEY; \
57  return key; \
58  }
59 
60  DEFINE_GETTER_SETTER(BehaviorParameter, "behavior_parameter", traffic_simulator_msgs::msg::BehaviorParameter)
61  DEFINE_GETTER_SETTER(CanonicalizedEntityStatus, "canonicalized_entity_status", std::shared_ptr<traffic_simulator::CanonicalizedEntityStatus>)
62  DEFINE_GETTER_SETTER(CurrentTime, "current_time", double)
63  DEFINE_GETTER_SETTER(DebugMarker, "debug_marker", std::vector<visualization_msgs::msg::Marker>)
64  DEFINE_GETTER_SETTER(DefaultMatchingDistanceForLaneletPoseCalculation, "matching_distance_for_lanelet_pose_calculation", double)
65  DEFINE_GETTER_SETTER(EuclideanDistancesMap, "euclidean_distances_map", std::shared_ptr<EuclideanDistancesMap>)
66  DEFINE_GETTER_SETTER(GoalPoses, "goal_poses", std::vector<geometry_msgs::msg::Pose>)
67  DEFINE_GETTER_SETTER(LaneChangeParameters, "lane_change_parameters", traffic_simulator::lane_change::Parameter)
68  DEFINE_GETTER_SETTER(LateralCollisionThreshold, "lateral_collision_threshold", std::optional<double>)
69  DEFINE_GETTER_SETTER(Obstacle, "obstacle", std::optional<traffic_simulator_msgs::msg::Obstacle>)
70  DEFINE_GETTER_SETTER(OtherEntityStatus, "other_entity_status", EntityStatusDict)
71  DEFINE_GETTER_SETTER(PedestrianParameters, "pedestrian_parameters", traffic_simulator_msgs::msg::PedestrianParameters)
72  DEFINE_GETTER_SETTER(PolylineTrajectory, "polyline_trajectory", std::shared_ptr<traffic_simulator_msgs::msg::PolylineTrajectory>)
73  DEFINE_GETTER_SETTER(ReferenceTrajectory, "reference_trajectory", std::shared_ptr<math::geometry::CatmullRomSpline>)
75  DEFINE_GETTER_SETTER(RouteLanelets, "route_lanelets", lanelet::Ids)
76  DEFINE_GETTER_SETTER(StepTime, "step_time", double)
77  DEFINE_GETTER_SETTER(TargetSpeed, "target_speed", std::optional<double>)
78  DEFINE_GETTER_SETTER(TrafficLights, "traffic_lights", std::shared_ptr<traffic_simulator::TrafficLightsBase>)
79  DEFINE_GETTER_SETTER(VehicleParameters, "vehicle_parameters", traffic_simulator_msgs::msg::VehicleParameters)
80  DEFINE_GETTER_SETTER(Waypoints, "waypoints", traffic_simulator_msgs::msg::WaypointsArray)
81  // clang-format on
82 #undef DEFINE_GETTER_SETTER
83 };
84 } // namespace entity_behavior
85 
86 #endif // TRAFFIC_SIMULATOR__BEHAVIOR__BEHAVIOR_PLUGIN_BASE_HPP_
#define DEFINE_GETTER_SETTER(NAME, KEY, TYPE)
Definition: behavior_plugin_base.hpp:51
Definition: behavior_plugin_base.hpp:43
virtual auto configure(const rclcpp::Logger &logger) -> void=0
virtual auto getCurrentAction() const -> const std::string &=0
virtual auto update(const double current_time, const double step_time) -> void=0
Definition: action_node.hpp:41
std::unordered_map< std::string, traffic_simulator::CanonicalizedEntityStatus > EntityStatusDict
Definition: behavior_plugin_base.hpp:38
std::unordered_map< std::pair< std::string, std::string >, double > EuclideanDistancesMap
Definition: behavior_plugin_base.hpp:40
Definition: bounding_box.hpp:32
Definition: lanelet_wrapper.hpp:43
Request
Definition: behavior.hpp:25
traffic_simulator::lane_change::Parameter Parameter
Definition: lane_change.hpp:27
geometry_msgs::msg::Pose Pose
Definition: lanelet_wrapper.hpp:70
Definition: operators.hpp:25
Definition: api.hpp:33