Autoware.Auto
platform_interface.hpp
Go to the documentation of this file.
1 // Copyright 2020-2021 the Autoware Foundation
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 // Co-developed by Tier IV, Inc. and Apex.AI, Inc.
18 #ifndef VEHICLE_INTERFACE__PLATFORM_INTERFACE_HPP_
19 #define VEHICLE_INTERFACE__PLATFORM_INTERFACE_HPP_
20 
21 #include <common/types.hpp>
22 
23 #include <autoware_auto_control_msgs/msg/ackermann_control_command.hpp>
24 
25 #include <autoware_auto_vehicle_msgs/msg/gear_command.hpp>
26 #include <autoware_auto_vehicle_msgs/msg/gear_report.hpp>
27 #include <autoware_auto_vehicle_msgs/msg/hand_brake_command.hpp>
28 #include <autoware_auto_vehicle_msgs/msg/hand_brake_report.hpp>
29 #include <autoware_auto_vehicle_msgs/msg/hazard_lights_command.hpp>
30 #include <autoware_auto_vehicle_msgs/msg/hazard_lights_report.hpp>
31 #include <autoware_auto_vehicle_msgs/msg/headlights_command.hpp>
32 #include <autoware_auto_vehicle_msgs/msg/headlights_report.hpp>
33 #include <autoware_auto_vehicle_msgs/msg/horn_command.hpp>
34 #include <autoware_auto_vehicle_msgs/msg/horn_report.hpp>
35 #include <autoware_auto_vehicle_msgs/msg/wipers_command.hpp>
36 #include <autoware_auto_vehicle_msgs/msg/wipers_report.hpp>
37 #include <autoware_auto_vehicle_msgs/msg/raw_control_command.hpp>
38 #include <autoware_auto_vehicle_msgs/msg/vehicle_control_command.hpp>
39 #include <autoware_auto_vehicle_msgs/msg/vehicle_odometry.hpp>
40 #include <autoware_auto_vehicle_msgs/msg/vehicle_state_command.hpp>
41 #include <autoware_auto_vehicle_msgs/msg/vehicle_state_report.hpp>
42 #include <autoware_auto_vehicle_msgs/srv/autonomy_mode_change.hpp>
43 #include <vehicle_interface/visibility_control.hpp>
44 
45 #include <chrono>
46 
48 
49 using autoware_auto_vehicle_msgs::msg::GearCommand;
50 using autoware_auto_vehicle_msgs::msg::GearReport;
51 using autoware_auto_vehicle_msgs::msg::HandBrakeCommand;
52 using autoware_auto_vehicle_msgs::msg::HandBrakeReport;
53 using autoware_auto_vehicle_msgs::msg::HazardLightsCommand;
54 using autoware_auto_vehicle_msgs::msg::HazardLightsReport;
55 using autoware_auto_vehicle_msgs::msg::HeadlightsCommand;
56 using autoware_auto_vehicle_msgs::msg::HeadlightsReport;
57 using autoware_auto_vehicle_msgs::msg::HornCommand;
58 using autoware_auto_vehicle_msgs::msg::HornReport;
59 using autoware_auto_vehicle_msgs::msg::WipersCommand;
60 using autoware_auto_vehicle_msgs::msg::WipersReport;
61 using autoware_auto_vehicle_msgs::msg::RawControlCommand;
62 using autoware_auto_control_msgs::msg::AckermannControlCommand;
64 using autoware_auto_vehicle_msgs::msg::VehicleStateCommand;
65 using autoware_auto_vehicle_msgs::msg::VehicleStateReport;
66 using autoware_auto_vehicle_msgs::msg::VehicleOdometry;
67 using ModeChangeRequest = autoware_auto_vehicle_msgs::srv::AutonomyModeChange_Request;
68 using ModeChangeResponse = autoware_auto_vehicle_msgs::srv::AutonomyModeChange_Response;
69 
70 namespace autoware
71 {
72 namespace drivers
73 {
74 namespace vehicle_interface
75 {
76 
81 {
82 public:
84  PlatformInterface() = default;
86  virtual ~PlatformInterface() = default;
87 
95  virtual bool8_t update(std::chrono::nanoseconds timeout) = 0;
101  virtual bool8_t send_state_command(const VehicleStateCommand & msg) = 0;
107  virtual bool8_t send_control_command(const VehicleControlCommand & msg) = 0;
113  virtual bool8_t send_control_command(const AckermannControlCommand & msg) = 0;
119  virtual bool8_t send_control_command(const RawControlCommand & msg) = 0;
125  virtual bool8_t handle_mode_change_request(ModeChangeRequest::SharedPtr request) = 0;
126 
132  const VehicleStateReport & get_state_report() const noexcept;
135  const VehicleOdometry & get_odometry() const noexcept;
138  const HeadlightsReport & get_headlights_report() const noexcept;
141  const HornReport & get_horn_report() const noexcept;
144  const WipersReport & get_wipers_report() const noexcept;
147  const GearReport & get_gear_report() const noexcept;
148 
153  virtual void send_gear_command(const GearCommand & msg);
154 
159  virtual void send_hand_brake_command(const HandBrakeCommand & msg);
160 
165  virtual void send_headlights_command(const HeadlightsCommand & msg);
166 
171  virtual void send_horn_command(const HornCommand & msg);
172 
177  virtual void send_wipers_command(const WipersCommand & msg);
178 
183  virtual void send_hazard_lights_command(const HazardLightsCommand & msg);
184 
185 protected:
187  VehicleStateReport & state_report() noexcept;
189  VehicleOdometry & odometry() noexcept;
191  HeadlightsReport & headlights_report() noexcept;
193  HornReport & horn_report() noexcept;
195  WipersReport & wipers_report() noexcept;
197  GearReport & gear_report() noexcept;
198 
199 private:
200  HeadlightsReport m_headlights_report{};
201  HornReport m_horn_report{};
202  WipersReport m_wipers_report{};
203  VehicleStateReport m_state_report{};
204  GearReport m_gear_report{};
205  VehicleOdometry m_odometry{};
206 }; // class PlatformInterface
207 } // namespace vehicle_interface
208 } // namespace drivers
209 } // namespace autoware
210 
211 #endif // VEHICLE_INTERFACE__PLATFORM_INTERFACE_HPP_
autoware::motion::control::pure_pursuit::VehicleControlCommand
autoware_auto_vehicle_msgs::msg::VehicleControlCommand VehicleControlCommand
Definition: pure_pursuit.hpp:41
types.hpp
This file includes common type definition.
autoware::drivers::vehicle_interface::PlatformInterface
Definition: platform_interface.hpp:80
autoware::common::types::bool8_t
bool bool8_t
Definition: types.hpp:39
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
ModeChangeRequest
autoware_auto_vehicle_msgs::srv::AutonomyModeChange_Request ModeChangeRequest
Definition: ne_raptor_interface.hpp:128
ModeChangeResponse
autoware_auto_vehicle_msgs::srv::AutonomyModeChange_Response ModeChangeResponse
Definition: ne_raptor_interface.hpp:129
VEHICLE_INTERFACE_PUBLIC
#define VEHICLE_INTERFACE_PUBLIC
Definition: drivers/vehicle_interface/include/vehicle_interface/visibility_control.hpp:44