scenario_simulator_v2 C++ API
ego_entity_simulation.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__VEHICLE_SIMULATION__EGO_ENTITY_SIMULATION_HPP_
16 #define TRAFFIC_SIMULATOR__VEHICLE_SIMULATION__EGO_ENTITY_SIMULATION_HPP_
17 
19 #include <memory>
24 #include <traffic_simulator_msgs/msg/entity_status.hpp>
25 #include <traffic_simulator_msgs/msg/polyline_trajectory.hpp>
26 #include <traffic_simulator_msgs/msg/vehicle_parameters.hpp>
27 
29 {
30 enum class VehicleModelType {
39 };
40 
42 {
43 public:
44  const std::unique_ptr<concealer::AutowareUniverse> autoware;
45 
46 private:
47  const VehicleModelType vehicle_model_type_;
48 
49  const double wheel_base_;
50 
51  const std::shared_ptr<SimModelInterface> vehicle_model_ptr_;
52 
53  std::optional<double> previous_linear_velocity_, previous_angular_velocity_;
54 
56 
57  const geometry_msgs::msg::Pose initial_pose_;
58 
59  const Eigen::Matrix3d initial_rotation_matrix_;
60 
61  static auto getVehicleModelType() -> VehicleModelType;
62 
63  static auto makeSimulationModel(
64  const VehicleModelType, const double step_time,
65  const traffic_simulator_msgs::msg::VehicleParameters &)
66  -> const std::shared_ptr<SimModelInterface>;
67 
68  const bool consider_acceleration_by_road_slope_;
69 
70  Eigen::Vector3d world_relative_position_;
71 
72 public:
73  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils_ptr_;
74 
75  const traffic_simulator_msgs::msg::VehicleParameters vehicle_parameters;
76 
77  auto calculateAccelerationBySlope() const -> double;
78 
79 private:
80  auto getCurrentPose(const double pitch_angle = 0.0) const -> geometry_msgs::msg::Pose;
81 
82  auto getCurrentTwist() const -> geometry_msgs::msg::Twist;
83 
84  auto getCurrentAccel(const double step_time) const -> geometry_msgs::msg::Accel;
85 
86  auto getLinearJerk(double step_time) -> double;
87 
88  auto updatePreviousValues() -> void;
89 
90 public:
91  auto setAutowareStatus() -> void;
92 
93  explicit EgoEntitySimulation(
95  const traffic_simulator_msgs::msg::VehicleParameters &, double,
96  const std::shared_ptr<hdmap_utils::HdMapUtils> &, const rclcpp::Parameter & use_sim_time,
97  const bool consider_acceleration_by_road_slope);
98 
99  auto overwrite(
100  const traffic_simulator_msgs::msg::EntityStatus & status, const double current_time,
101  const double step_time, bool is_npc_logic_started) -> void;
102 
103  auto update(const double current_time, const double step_time, const bool is_npc_logic_started)
104  -> void;
105 
106  auto requestSpeedChange(double value) -> void;
107 
108  auto getStatus() const -> const traffic_simulator_msgs::msg::EntityStatus;
109 
110  auto setStatus(const traffic_simulator_msgs::msg::EntityStatus & status) -> void;
111 
112  auto updateStatus(const double current_time, const double step_time) -> void;
113 };
114 } // namespace vehicle_simulation
115 
116 #endif // TRAFFIC_SIMULATOR__VEHICLE_SIMULATION__EGO_ENTITY_SIMULATION_HPP_
Definition: entity_status.hpp:32
Definition: ego_entity_simulation.hpp:42
auto update(const double current_time, const double step_time, const bool is_npc_logic_started) -> void
Definition: ego_entity_simulation.cpp:297
const traffic_simulator_msgs::msg::VehicleParameters vehicle_parameters
Definition: ego_entity_simulation.hpp:75
const std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils_ptr_
Definition: ego_entity_simulation.hpp:73
auto updateStatus(const double current_time, const double step_time) -> void
Definition: ego_entity_simulation.cpp:460
auto setAutowareStatus() -> void
Definition: ego_entity_simulation.cpp:173
auto overwrite(const traffic_simulator_msgs::msg::EntityStatus &status, const double current_time, const double step_time, bool is_npc_logic_started) -> void
Definition: ego_entity_simulation.cpp:222
auto calculateAccelerationBySlope() const -> double
Definition: ego_entity_simulation.cpp:362
auto requestSpeedChange(double value) -> void
Definition: ego_entity_simulation.cpp:186
auto getStatus() const -> const traffic_simulator_msgs::msg::EntityStatus
Definition: ego_entity_simulation.cpp:433
const std::unique_ptr< concealer::AutowareUniverse > autoware
Definition: ego_entity_simulation.hpp:44
auto setStatus(const traffic_simulator_msgs::msg::EntityStatus &status) -> void
Definition: ego_entity_simulation.cpp:438
Definition: cache.hpp:28
Definition: lanelet_wrapper.hpp:40
geometry_msgs::msg::Pose Pose
Definition: lanelet_wrapper.hpp:66
Definition: operators.hpp:25
Definition: ego_entity_simulation.hpp:29
VehicleModelType
Definition: ego_entity_simulation.hpp:30
traffic_simulator_msgs::EntityStatus EntityStatus
Definition: helper_functions.hpp:32