scenario_simulator_v2 C++ API
ego_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__EGO_ENTITY_HPP_
16 #define TRAFFIC_SIMULATOR__ENTITY__EGO_ENTITY_HPP_
17 
18 #include <algorithm>
19 #include <autoware_auto_system_msgs/msg/emergency_state.hpp>
20 #include <boost/filesystem.hpp>
21 #include <concealer/autoware.hpp>
23 #include <memory>
24 #include <optional>
25 #include <string>
29 #include <traffic_simulator_msgs/msg/entity_type.hpp>
30 #include <vector>
31 
32 namespace traffic_simulator
33 {
34 namespace entity
35 {
36 class EgoEntity : public VehicleEntity
37 {
38  const std::unique_ptr<concealer::FieldOperatorApplication> field_operator_application;
39 
40  static auto makeFieldOperatorApplication(
41  const Configuration &, const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &)
42  -> std::unique_ptr<concealer::FieldOperatorApplication>;
43 
44  bool is_controlled_by_simulator_{false};
45  std::optional<double> target_speed_;
46  traffic_simulator_msgs::msg::BehaviorParameter behavior_parameter_;
47  std::shared_ptr<traffic_simulator_msgs::msg::PolylineTrajectory> polyline_trajectory_;
48 
49 public:
50  explicit EgoEntity() = delete;
51 
52  explicit EgoEntity(
54  const std::shared_ptr<hdmap_utils::HdMapUtils> &,
55  const traffic_simulator_msgs::msg::VehicleParameters &, const Configuration &,
56  const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &);
57 
58  explicit EgoEntity(EgoEntity &&) = delete;
59 
60  explicit EgoEntity(const EgoEntity &) = delete;
61 
62  ~EgoEntity() override = default;
63 
64  auto operator=(EgoEntity &&) -> EgoEntity & = delete;
65 
66  auto operator=(const EgoEntity &) -> EgoEntity & = delete;
67 
68  auto asFieldOperatorApplication() const -> concealer::FieldOperatorApplication & override;
69 
70  auto getCurrentAction() const -> std::string override;
71 
72  auto getCurrentPose() const -> geometry_msgs::msg::Pose;
73 
74  auto getDefaultDynamicConstraints() const
75  -> const traffic_simulator_msgs::msg::DynamicConstraints & override;
76 
77  auto getBehaviorParameter() const -> traffic_simulator_msgs::msg::BehaviorParameter override;
78 
79  auto getEntityStatus(const double, const double) const -> const CanonicalizedEntityStatus;
80 
81  auto getEntityType() const -> const traffic_simulator_msgs::msg::EntityType & override;
82 
83  auto getEntityTypename() const -> const std::string & override;
84 
85  auto getObstacle() -> std::optional<traffic_simulator_msgs::msg::Obstacle> override;
86 
87  auto getRouteLanelets(double horizon = 100) -> lanelet::Ids override;
88 
89  auto getWaypoints() -> const traffic_simulator_msgs::msg::WaypointsArray override;
90 
91  void onUpdate(double current_time, double step_time) override;
92 
93  void requestAcquirePosition(const CanonicalizedLaneletPose &) override;
94 
95  void requestAcquirePosition(const geometry_msgs::msg::Pose & map_pose) override;
96 
97  void requestAssignRoute(const std::vector<CanonicalizedLaneletPose> &) override;
98 
99  void requestAssignRoute(const std::vector<geometry_msgs::msg::Pose> &) override;
100 
102  const std::shared_ptr<traffic_simulator_msgs::msg::PolylineTrajectory> &) -> void override;
103 
104  void requestLaneChange(const lanelet::Id) override;
105 
106  auto requestLaneChange(const traffic_simulator::lane_change::Parameter &) -> void override;
107 
108  auto requestSpeedChange(
109  const double, const speed_change::Transition, const speed_change::Constraint,
110  const bool continuous) -> void override;
111 
112  auto requestSpeedChange(
113  const speed_change::RelativeTargetSpeed &, const speed_change::Transition,
114  const speed_change::Constraint, const bool continuous) -> void override;
115 
116  void requestClearRoute() override;
117 
118  auto isControlledBySimulator() const -> bool override;
119 
120  auto setControlledBySimulator(bool state) -> void override
121  {
122  is_controlled_by_simulator_ = state;
123  }
124 
125  auto setBehaviorParameter(const traffic_simulator_msgs::msg::BehaviorParameter &)
126  -> void override;
127 
128  void requestSpeedChange(double, bool continuous) override;
129 
130  void requestSpeedChange(
131  const speed_change::RelativeTargetSpeed & target_speed, bool continuous) override;
132 
133  auto setVelocityLimit(double) -> void override;
134 
135  auto setMapPose(const geometry_msgs::msg::Pose & map_pose) -> void override;
136 
137  auto fillLaneletPose(CanonicalizedEntityStatus & status) -> void override;
138 };
139 } // namespace entity
140 } // namespace traffic_simulator
141 
142 #endif // TRAFFIC_SIMULATOR__ENTITY__EGO_ENTITY_HPP_
Definition: ego_entity.hpp:37
auto getObstacle() -> std::optional< traffic_simulator_msgs::msg::Obstacle > override
Definition: ego_entity.cpp:112
auto setMapPose(const geometry_msgs::msg::Pose &map_pose) -> void override
Definition: ego_entity.cpp:289
void requestAssignRoute(const std::vector< CanonicalizedLaneletPose > &) override
Definition: ego_entity.cpp:176
void requestLaneChange(const lanelet::Id) override
Definition: ego_entity.cpp:221
void requestAcquirePosition(const CanonicalizedLaneletPose &) override
Definition: ego_entity.cpp:166
auto getWaypoints() -> const traffic_simulator_msgs::msg::WaypointsArray override
Definition: ego_entity.cpp:135
auto getEntityStatus(const double, const double) const -> const CanonicalizedEntityStatus
auto getDefaultDynamicConstraints() const -> const traffic_simulator_msgs::msg::DynamicConstraints &override
Definition: ego_entity.cpp:255
auto asFieldOperatorApplication() const -> concealer::FieldOperatorApplication &override
Definition: ego_entity.cpp:79
auto getCurrentPose() const -> geometry_msgs::msg::Pose
Definition: ego_entity.cpp:133
void requestClearRoute() override
Definition: ego_entity.cpp:253
void onUpdate(double current_time, double step_time) override
Definition: ego_entity.cpp:140
auto setControlledBySimulator(bool state) -> void override
Definition: ego_entity.hpp:120
auto fillLaneletPose(CanonicalizedEntityStatus &status) -> void override
Definition: ego_entity.cpp:284
auto getEntityTypename() const -> const std::string &override
Definition: ego_entity.cpp:99
auto requestFollowTrajectory(const std::shared_ptr< traffic_simulator_msgs::msg::PolylineTrajectory > &) -> void override
Definition: ego_entity.cpp:213
auto setVelocityLimit(double) -> void override
Definition: ego_entity.cpp:278
auto operator=(EgoEntity &&) -> EgoEntity &=delete
auto getCurrentAction() const -> std::string override
Definition: ego_entity.cpp:85
auto operator=(const EgoEntity &) -> EgoEntity &=delete
auto getRouteLanelets(double horizon=100) -> lanelet::Ids override
Definition: ego_entity.cpp:117
EgoEntity(const EgoEntity &)=delete
auto setBehaviorParameter(const traffic_simulator_msgs::msg::BehaviorParameter &) -> void override
Definition: ego_entity.cpp:261
auto getEntityType() const -> const traffic_simulator_msgs::msg::EntityType &override
Definition: ego_entity.cpp:105
auto getBehaviorParameter() const -> traffic_simulator_msgs::msg::BehaviorParameter override
Definition: ego_entity.cpp:91
auto requestSpeedChange(const double, const speed_change::Transition, const speed_change::Constraint, const bool continuous) -> void override
Definition: ego_entity.cpp:237
auto isControlledBySimulator() const -> bool override
Definition: ego_entity.cpp:211
const std::string name
Definition: entity_base.hpp:242
Definition: vehicle_entity.hpp:37
Definition: entity_status.hpp:29
Definition: lanelet_pose.hpp:27
Definition: autoware.hpp:30
Definition: cache.hpp:27
Transition
Definition: speed_change.hpp:26
Definition: api.hpp:48
std::string string
Definition: junit5.hpp:26
Definition: configuration.hpp:30