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 
18 #include <concealer/autoware.hpp>
19 #include <memory>
22 #include <traffic_simulator_msgs/msg/entity_status.hpp>
23 #include <traffic_simulator_msgs/msg/polyline_trajectory.hpp>
24 #include <traffic_simulator_msgs/msg/vehicle_parameters.hpp>
25 
27 {
28 enum class VehicleModelType {
36 };
37 
39 {
40 public:
41  const std::unique_ptr<concealer::Autoware> autoware;
42 
43 private:
44  const VehicleModelType vehicle_model_type_;
45 
46  const std::shared_ptr<SimModelInterface> vehicle_model_ptr_;
47 
48  std::optional<double> previous_linear_velocity_, previous_angular_velocity_;
49 
50  geometry_msgs::msg::Pose initial_pose_;
51 
52  static auto getVehicleModelType() -> VehicleModelType;
53 
54  static auto makeSimulationModel(
55  const VehicleModelType, const double step_time,
56  const traffic_simulator_msgs::msg::VehicleParameters &)
57  -> const std::shared_ptr<SimModelInterface>;
58 
60 
61  const bool consider_acceleration_by_road_slope_;
62 
63  const bool consider_pose_by_road_slope_;
64 
65  Eigen::Vector3d world_relative_position_;
66 
67 public:
68  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils_ptr_;
69 
70  const traffic_simulator_msgs::msg::VehicleParameters vehicle_parameters;
71 
72 private:
73  auto calculateEgoPitch() const -> double;
74 
75  auto getCurrentPose(const double pitch_angle) const -> geometry_msgs::msg::Pose;
76 
77  auto getCurrentTwist() const -> geometry_msgs::msg::Twist;
78 
79  auto getCurrentAccel(const double step_time) const -> geometry_msgs::msg::Accel;
80 
81  auto getLinearJerk(double step_time) -> double;
82 
83  auto getMatchedLaneletPoseFromEntityStatus(
84  const traffic_simulator_msgs::msg::EntityStatus & status, const double entity_width) const
85  -> std::optional<traffic_simulator_msgs::msg::LaneletPose>;
86 
87  auto updatePreviousValues() -> void;
88 
89 public:
90  auto setAutowareStatus() -> void;
91 
92  explicit EgoEntitySimulation(
93  const traffic_simulator_msgs::msg::VehicleParameters &, double,
94  const std::shared_ptr<hdmap_utils::HdMapUtils> &, const rclcpp::Parameter & use_sim_time,
95  const bool consider_acceleration_by_road_slope, const bool consider_pose_by_road_slope);
96 
97  auto overwrite(
98  const traffic_simulator_msgs::msg::EntityStatus & status, double current_scenario_time,
99  double step_time, bool npc_logic_started) -> void;
100 
101  auto update(double time, double step_time, bool npc_logic_started) -> void;
102 
103  auto requestSpeedChange(double value) -> void;
104 
105  auto getStatus() const -> const traffic_simulator_msgs::msg::EntityStatus &;
106 
107  auto setInitialStatus(const traffic_simulator_msgs::msg::EntityStatus & status) -> void;
108 
109  auto setStatus(const traffic_simulator_msgs::msg::EntityStatus & status) -> void;
110 
111  auto updateStatus(double time, double step_time) -> void;
112 
113  auto fillLaneletDataAndSnapZToLanelet(traffic_simulator_msgs::msg::EntityStatus & status) -> void;
114 };
115 } // namespace vehicle_simulation
116 
117 #endif // TRAFFIC_SIMULATOR__VEHICLE_SIMULATION__EGO_ENTITY_SIMULATION_HPP_
Definition: ego_entity_simulation.hpp:39
auto getStatus() const -> const traffic_simulator_msgs::msg::EntityStatus &
Definition: ego_entity_simulation.cpp:491
const traffic_simulator_msgs::msg::VehicleParameters vehicle_parameters
Definition: ego_entity_simulation.hpp:70
auto update(double time, double step_time, bool npc_logic_started) -> void
Definition: ego_entity_simulation.cpp:284
const std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_utils_ptr_
Definition: ego_entity_simulation.hpp:68
auto fillLaneletDataAndSnapZToLanelet(traffic_simulator_msgs::msg::EntityStatus &status) -> void
Definition: ego_entity_simulation.cpp:526
auto setAutowareStatus() -> void
Definition: ego_entity_simulation.cpp:173
auto setInitialStatus(const traffic_simulator_msgs::msg::EntityStatus &status) -> void
Definition: ego_entity_simulation.cpp:503
auto requestSpeedChange(double value) -> void
Definition: ego_entity_simulation.cpp:186
auto updateStatus(double time, double step_time) -> void
Definition: ego_entity_simulation.cpp:510
auto overwrite(const traffic_simulator_msgs::msg::EntityStatus &status, double current_scenario_time, double step_time, bool npc_logic_started) -> void
Definition: ego_entity_simulation.cpp:218
const std::unique_ptr< concealer::Autoware > autoware
Definition: ego_entity_simulation.hpp:41
auto setStatus(const traffic_simulator_msgs::msg::EntityStatus &status) -> void
Definition: ego_entity_simulation.cpp:496
Definition: cache.hpp:46
Definition: cache.hpp:27
traffic_simulator_msgs::msg::LaneletPose LaneletPose
Definition: lanelet_pose.hpp:22
traffic_simulator_msgs::msg::EntityStatus EntityStatus
Definition: entity_status.hpp:24
Definition: ego_entity_simulation.hpp:27
VehicleModelType
Definition: ego_entity_simulation.hpp:28