scenario_simulator_v2 C++ API
pedestrian_entity.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__PEDESTRIAN_ENTITY_HPP_
16 #define TRAFFIC_SIMULATOR__ENTITY__PEDESTRIAN_ENTITY_HPP_
17 
18 #include <memory>
19 #include <optional>
20 #include <pluginlib/class_loader.hpp>
21 #include <pugixml.hpp>
22 #include <string>
26 #include <traffic_simulator_msgs/msg/pedestrian_parameters.hpp>
27 #include <vector>
28 
29 namespace traffic_simulator
30 {
31 namespace entity
32 {
34 {
35 public:
37  {
38  static auto behaviorTree() noexcept -> const std::string &
39  {
40  static const std::string name = "behavior_tree_plugin/PedestrianBehaviorTree";
41  return name;
42  }
43 
44  static auto contextGamma() noexcept -> const std::string &
45  {
46  static const std::string name = "context_gamma_planner/PedestrianPlugin";
47  return name;
48  }
49 
50  static auto doNothing() noexcept -> const std::string &
51  {
52  static const std::string name = "do_nothing_plugin/DoNothingPlugin";
53  return name;
54  }
55 
56  static auto defaultBehavior() noexcept -> const std::string & { return behaviorTree(); }
57  };
58 
59  explicit PedestrianEntity(
61  const std::shared_ptr<hdmap_utils::HdMapUtils> &,
62  const traffic_simulator_msgs::msg::PedestrianParameters &,
64 
65  ~PedestrianEntity() override = default;
66 
67  void appendDebugMarker(visualization_msgs::msg::MarkerArray & marker_array) override;
68 
69  auto getEntityTypename() const -> const std::string & override;
70 
71  auto onUpdate(const double current_time, const double step_time) -> void override;
72 
73  void requestAcquirePosition(const CanonicalizedLaneletPose & lanelet_pose) override;
74 
75  void requestAcquirePosition(const geometry_msgs::msg::Pose & map_pose) override;
76 
77  void requestWalkStraight() override;
78 
79  void cancelRequest() override;
80 
81  void setTrafficLights(const std::shared_ptr<traffic_simulator::TrafficLightsBase> & ptr) override;
82 
83  auto getBehaviorParameter() const -> traffic_simulator_msgs::msg::BehaviorParameter;
84 
85  auto getMaxAcceleration() const -> double override;
86 
87  auto getMaxDeceleration() const -> double override;
88 
89  void setBehaviorParameter(const traffic_simulator_msgs::msg::BehaviorParameter &);
90 
91  void setVelocityLimit(double linear_velocity) override;
92 
93  void setAccelerationLimit(double acceleration) override;
94 
95  void setAccelerationRateLimit(double acceleration_rate) override;
96 
97  void setDecelerationLimit(double deceleration) override;
98 
99  void setDecelerationRateLimit(double deceleration) override;
100 
101  void requestAssignRoute(const std::vector<CanonicalizedLaneletPose> & waypoints) override;
102 
103  void requestAssignRoute(const std::vector<geometry_msgs::msg::Pose> &) override;
104 
106  const std::shared_ptr<traffic_simulator_msgs::msg::PolylineTrajectory> &) -> void override;
107 
108  std::string getCurrentAction() const override;
109 
110  auto getDefaultDynamicConstraints() const
111  -> const traffic_simulator_msgs::msg::DynamicConstraints & override;
112 
113  auto getRouteLanelets(double horizon = 100) -> lanelet::Ids override;
114 
115  auto getObstacle() -> std::optional<traffic_simulator_msgs::msg::Obstacle> override;
116 
117  auto getGoalPoses() -> std::vector<CanonicalizedLaneletPose> override;
118 
119  auto getWaypoints() -> const traffic_simulator_msgs::msg::WaypointsArray override;
120 
121  const std::string plugin_name;
122 
123  const traffic_simulator_msgs::msg::PedestrianParameters pedestrian_parameters;
124 
125 private:
126  pluginlib::ClassLoader<entity_behavior::BehaviorPluginBase> loader_;
127  const std::shared_ptr<entity_behavior::BehaviorPluginBase> behavior_plugin_ptr_;
128  traffic_simulator::RoutePlanner route_planner_;
129 };
130 } // namespace entity
131 } // namespace traffic_simulator
132 
133 #endif // TRAFFIC_SIMULATOR__ENTITY__PEDESTRIAN_ENTITY_HPP_
Definition: route_planner.hpp:27
Definition: traffic_lights_base.hpp:39
Definition: entity_base.hpp:51
const std::string name
Definition: entity_base.hpp:255
Definition: pedestrian_entity.hpp:34
void requestWalkStraight() override
Definition: pedestrian_entity.cpp:131
auto getDefaultDynamicConstraints() const -> const traffic_simulator_msgs::msg::DynamicConstraints &override
Definition: pedestrian_entity.cpp:96
void requestAssignRoute(const std::vector< CanonicalizedLaneletPose > &waypoints) override
Definition: pedestrian_entity.cpp:54
auto getEntityTypename() const -> const std::string &override
Definition: pedestrian_entity.cpp:164
auto getMaxAcceleration() const -> double override
Definition: pedestrian_entity.cpp:189
auto getWaypoints() -> const traffic_simulator_msgs::msg::WaypointsArray override
Definition: pedestrian_entity.cpp:126
void setAccelerationRateLimit(double acceleration_rate) override
Definition: pedestrian_entity.cpp:219
auto getGoalPoses() -> std::vector< CanonicalizedLaneletPose > override
Definition: pedestrian_entity.cpp:121
auto requestFollowTrajectory(const std::shared_ptr< traffic_simulator_msgs::msg::PolylineTrajectory > &) -> void override
Definition: pedestrian_entity.cpp:84
void setDecelerationRateLimit(double deceleration) override
Definition: pedestrian_entity.cpp:239
const traffic_simulator_msgs::msg::PedestrianParameters pedestrian_parameters
Definition: pedestrian_entity.hpp:123
void setTrafficLights(const std::shared_ptr< traffic_simulator::TrafficLightsBase > &ptr) override
Definition: pedestrian_entity.cpp:170
auto getMaxDeceleration() const -> double override
Definition: pedestrian_entity.cpp:194
void setAccelerationLimit(double acceleration) override
Definition: pedestrian_entity.cpp:209
void setVelocityLimit(double linear_velocity) override
Definition: pedestrian_entity.cpp:199
std::string getCurrentAction() const override
Definition: pedestrian_entity.cpp:91
auto getObstacle() -> std::optional< traffic_simulator_msgs::msg::Obstacle > override
Definition: pedestrian_entity.cpp:116
PedestrianEntity(const std::string &name, const CanonicalizedEntityStatus &, const std::shared_ptr< hdmap_utils::HdMapUtils > &, const traffic_simulator_msgs::msg::PedestrianParameters &, const std::string &plugin_name=BuiltinBehavior::defaultBehavior())
Definition: pedestrian_entity.cpp:26
auto getBehaviorParameter() const -> traffic_simulator_msgs::msg::BehaviorParameter
Definition: pedestrian_entity.cpp:177
void appendDebugMarker(visualization_msgs::msg::MarkerArray &marker_array) override
Definition: pedestrian_entity.cpp:48
const std::string plugin_name
Definition: pedestrian_entity.hpp:121
auto onUpdate(const double current_time, const double step_time) -> void override
Definition: pedestrian_entity.cpp:249
void setBehaviorParameter(const traffic_simulator_msgs::msg::BehaviorParameter &)
Definition: pedestrian_entity.cpp:183
void requestAcquirePosition(const CanonicalizedLaneletPose &lanelet_pose) override
Definition: pedestrian_entity.cpp:136
auto getRouteLanelets(double horizon=100) -> lanelet::Ids override
Definition: pedestrian_entity.cpp:107
void cancelRequest() override
Definition: pedestrian_entity.cpp:158
void setDecelerationLimit(double deceleration) override
Definition: pedestrian_entity.cpp:229
Definition: entity_status.hpp:32
Definition: lanelet_pose.hpp:27
Definition: action_node.hpp:39
Definition: cache.hpp:27
Definition: api.hpp:49
std::string string
Definition: junit5.hpp:26
static auto behaviorTree() noexcept -> const std::string &
Definition: pedestrian_entity.hpp:38
static auto doNothing() noexcept -> const std::string &
Definition: pedestrian_entity.hpp:50
static auto defaultBehavior() noexcept -> const std::string &
Definition: pedestrian_entity.hpp:56
static auto contextGamma() noexcept -> const std::string &
Definition: pedestrian_entity.hpp:44