scenario_simulator_v2 C++ API
autoware_universe.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 CONCEALER__AUTOWARE_UNIVERSE_HPP_
16 #define CONCEALER__AUTOWARE_UNIVERSE_HPP_
17 
18 #include <atomic>
19 #include <autoware_control_msgs/msg/control.hpp>
20 #include <autoware_vehicle_msgs/msg/control_mode_report.hpp>
21 #include <autoware_vehicle_msgs/msg/gear_command.hpp>
22 #include <autoware_vehicle_msgs/msg/gear_report.hpp>
23 #include <autoware_vehicle_msgs/msg/steering_report.hpp>
24 #include <autoware_vehicle_msgs/msg/turn_indicators_command.hpp>
25 #include <autoware_vehicle_msgs/msg/turn_indicators_report.hpp>
26 #include <autoware_vehicle_msgs/msg/velocity_report.hpp>
27 #include <autoware_vehicle_msgs/srv/control_mode_command.hpp>
30 #include <concealer/publisher.hpp>
31 #include <concealer/subscriber.hpp>
32 #include <concealer/visibility.hpp>
33 #include <geometry_msgs/msg/accel_with_covariance_stamped.hpp>
34 #include <geometry_msgs/msg/pose.hpp>
35 #include <geometry_msgs/msg/twist_stamped.hpp>
36 #include <nav_msgs/msg/odometry.hpp>
37 #include <rclcpp/rclcpp.hpp>
38 
39 namespace concealer
40 {
41 class AutowareUniverse : public rclcpp::Node,
42  public ContinuousTransformBroadcaster<AutowareUniverse>
43 {
44 public:
45  // clang-format off
46  using AccelWithCovarianceStamped = geometry_msgs::msg::AccelWithCovarianceStamped;
47  using Control = autoware_control_msgs::msg::Control;
48  using ControlModeCommand = autoware_vehicle_msgs::srv::ControlModeCommand;
49  using ControlModeReport = autoware_vehicle_msgs::msg::ControlModeReport;
50  using GearCommand = autoware_vehicle_msgs::msg::GearCommand;
51  using GearReport = autoware_vehicle_msgs::msg::GearReport;
52  using Odometry = nav_msgs::msg::Odometry;
53  using PoseWithCovarianceStamped = geometry_msgs::msg::PoseWithCovarianceStamped;
54  using SteeringReport = autoware_vehicle_msgs::msg::SteeringReport;
55  using TurnIndicatorsCommand = autoware_vehicle_msgs::msg::TurnIndicatorsCommand;
56  using TurnIndicatorsReport = autoware_vehicle_msgs::msg::TurnIndicatorsReport;
57  using VelocityReport = autoware_vehicle_msgs::msg::VelocityReport;
58 
63 
72 
73  std::atomic<geometry_msgs::msg::Accel> current_acceleration;
74  std::atomic<geometry_msgs::msg::Pose> current_pose;
75  std::atomic<geometry_msgs::msg::Twist> current_twist;
76  // clang-format on
77 
78 private:
79  rclcpp::Service<ControlModeCommand>::SharedPtr control_mode_request_server;
80 
81  const rclcpp::TimerBase::SharedPtr localization_update_timer;
82 
83  const rclcpp::TimerBase::SharedPtr vehicle_state_update_timer;
84 
85  std::thread spinner;
86 
87  std::atomic<bool> is_stop_requested = false;
88 
89  std::atomic<std::uint8_t> current_control_mode = ControlModeReport::AUTONOMOUS;
90 
91  std::atomic<bool> is_thrown = false;
92 
93  std::exception_ptr thrown;
94 
95 public:
96  CONCEALER_PUBLIC explicit AutowareUniverse(bool);
97 
99 
100  auto rethrow() -> void;
101 
102  auto getVehicleCommand() const -> std::tuple<double, double, double, double, int>;
103 
104  auto getRouteLanelets() const -> std::vector<std::int64_t>;
105 
106  auto getControlModeReport() const -> ControlModeReport;
107 
108  auto setManualMode() -> void;
109 };
110 } // namespace concealer
111 
112 #endif // CONCEALER__AUTOWARE_UNIVERSE_HPP_
Definition: autoware_universe.hpp:43
Publisher< GearReport > setGearReport
Definition: autoware_universe.hpp:68
autoware_vehicle_msgs::msg::GearReport GearReport
Definition: autoware_universe.hpp:51
autoware_vehicle_msgs::msg::GearCommand GearCommand
Definition: autoware_universe.hpp:50
Subscriber< Control > getCommand
Definition: autoware_universe.hpp:59
Publisher< Odometry, NormalDistribution > setOdometry
Definition: autoware_universe.hpp:65
Publisher< PoseWithCovarianceStamped > setPose
Definition: autoware_universe.hpp:66
Publisher< AccelWithCovarianceStamped > setAcceleration
Definition: autoware_universe.hpp:64
auto getRouteLanelets() const -> std::vector< std::int64_t >
Definition: autoware_universe.cpp:226
autoware_vehicle_msgs::srv::ControlModeCommand ControlModeCommand
Definition: autoware_universe.hpp:48
autoware_control_msgs::msg::Control Control
Definition: autoware_universe.hpp:47
autoware_vehicle_msgs::msg::ControlModeReport ControlModeReport
Definition: autoware_universe.hpp:49
autoware_vehicle_msgs::msg::SteeringReport SteeringReport
Definition: autoware_universe.hpp:54
auto getVehicleCommand() const -> std::tuple< double, double, double, double, int >
Definition: autoware_universe.cpp:190
autoware_vehicle_msgs::msg::TurnIndicatorsCommand TurnIndicatorsCommand
Definition: autoware_universe.hpp:55
autoware_vehicle_msgs::msg::TurnIndicatorsReport TurnIndicatorsReport
Definition: autoware_universe.hpp:56
~AutowareUniverse()
Definition: autoware_universe.cpp:177
autoware_vehicle_msgs::msg::VelocityReport VelocityReport
Definition: autoware_universe.hpp:57
Subscriber< TurnIndicatorsCommand > getTurnIndicatorsCommand
Definition: autoware_universe.hpp:61
Publisher< ControlModeReport > setControlModeReport
Definition: autoware_universe.hpp:69
Publisher< VelocityReport > setVelocityReport
Definition: autoware_universe.hpp:70
CONCEALER_PUBLIC AutowareUniverse(bool)
Definition: autoware_universe.cpp:25
std::atomic< geometry_msgs::msg::Twist > current_twist
Definition: autoware_universe.hpp:75
geometry_msgs::msg::AccelWithCovarianceStamped AccelWithCovarianceStamped
Definition: autoware_universe.hpp:46
geometry_msgs::msg::PoseWithCovarianceStamped PoseWithCovarianceStamped
Definition: autoware_universe.hpp:53
std::atomic< geometry_msgs::msg::Pose > current_pose
Definition: autoware_universe.hpp:74
Publisher< TurnIndicatorsReport > setTurnIndicatorsReport
Definition: autoware_universe.hpp:71
Subscriber< priority::PathWithLaneId > getPathWithLaneId
Definition: autoware_universe.hpp:62
auto getControlModeReport() const -> ControlModeReport
Definition: autoware_universe.cpp:235
nav_msgs::msg::Odometry Odometry
Definition: autoware_universe.hpp:52
Subscriber< GearCommand > getGearCommand
Definition: autoware_universe.hpp:60
std::atomic< geometry_msgs::msg::Accel > current_acceleration
Definition: autoware_universe.hpp:73
auto rethrow() -> void
Definition: autoware_universe.cpp:183
Publisher< SteeringReport > setSteeringReport
Definition: autoware_universe.hpp:67
auto setManualMode() -> void
Definition: autoware_universe.cpp:242
Definition: continuous_transform_broadcaster.hpp:30
#define CONCEALER_PUBLIC
Definition: visibility.hpp:49
Definition: autoware_universe.hpp:40
Definition: lanelet_wrapper.hpp:39