Autoware.Auto
covariance_insertion_node.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 
17 
18 #ifndef COVARIANCE_INSERTION_NODES__COVARIANCE_INSERTION_NODE_HPP_
19 #define COVARIANCE_INSERTION_NODES__COVARIANCE_INSERTION_NODE_HPP_
20 
21 #include <rclcpp/rclcpp.hpp>
22 #include <rclcpp/publisher.hpp>
23 #include <rclcpp/subscription.hpp>
24 
25 #include <common/types.hpp>
26 #include <mpark_variant_vendor/variant.hpp>
30 
31 #include <string>
32 #include <map>
33 #include <memory>
34 #include <vector>
35 
36 namespace autoware
37 {
38 namespace covariance_insertion_nodes
39 {
40 
46 class COVARIANCE_INSERTION_NODES_PUBLIC CovarianceInsertionNode : public rclcpp::Node
47 {
48 public:
50  using MsgVariant = mpark::variant<
52  geometry_msgs::msg::Pose,
53  geometry_msgs::msg::PoseStamped,
54  geometry_msgs::msg::PoseWithCovariance,
55  geometry_msgs::msg::PoseWithCovarianceStamped,
56  geometry_msgs::msg::Twist,
57  geometry_msgs::msg::TwistStamped,
58  geometry_msgs::msg::TwistWithCovariance,
59  geometry_msgs::msg::TwistWithCovarianceStamped>;
60 
67  explicit CovarianceInsertionNode(const rclcpp::NodeOptions & options);
68 
69 private:
70  // Validate that we can change the covariances of the entries from parameters.
71  void validate(const MsgVariant & msg_variant);
72 
73  // Create a publisher and a subscriber that add covariance.
74  void create_pub_sub(const MsgVariant & msg_variant);
75 
76  // Create a message variant from the input message.
77  MsgVariant fill_message_variant(const std::string & input_msg_type_name);
78 
79  std::unique_ptr<covariance_insertion::CovarianceInsertion> m_core;
80  rclcpp::SubscriptionBase::SharedPtr m_subscription{};
81  rclcpp::PublisherBase::SharedPtr m_publisher{};
82  std::size_t m_history_size{};
83  std::string m_input_topic{};
84  std::string m_output_topic{};
85  std::string m_input_msg_type_name{};
86 };
87 } // namespace covariance_insertion_nodes
88 } // namespace autoware
89 
90 #endif // COVARIANCE_INSERTION_NODES__COVARIANCE_INSERTION_NODE_HPP_
ROS 2 Node for the covariance_insertion_nodes.
Definition: covariance_insertion_node.hpp:46
mpark::variant< nav_msgs::msg::Odometry, geometry_msgs::msg::Pose, geometry_msgs::msg::PoseStamped, geometry_msgs::msg::PoseWithCovariance, geometry_msgs::msg::PoseWithCovarianceStamped, geometry_msgs::msg::Twist, geometry_msgs::msg::TwistStamped, geometry_msgs::msg::TwistWithCovariance, geometry_msgs::msg::TwistWithCovarianceStamped > MsgVariant
A variant that holds all possible message types that this node can work with.
Definition: covariance_insertion_node.hpp:59
This file includes common type definition.
autoware_auto_msgs::msg::VehicleOdometry Odometry
Definition: safety_state_machine.hpp:43
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24