Autoware.Auto
measurement_conversion.hpp
Go to the documentation of this file.
1 // Copyright 2021 Apex.AI, Inc.
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.
16 
19 
20 #ifndef MEASUREMENT_CONVERSION__MEASUREMENT_CONVERSION_HPP_
21 #define MEASUREMENT_CONVERSION__MEASUREMENT_CONVERSION_HPP_
22 
23 #include <autoware_auto_geometry_msgs/msg/relative_position_with_covariance_stamped.hpp>
24 #include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
25 #include <geometry_msgs/msg/twist_with_covariance_stamped.hpp>
28 #include <nav_msgs/msg/odometry.hpp>
29 #include <rclcpp/time.hpp>
31 
32 #include <Eigen/Geometry>
33 
34 namespace autoware
35 {
36 namespace common
37 {
38 namespace state_estimation
39 {
40 
41 namespace detail
42 {
43 inline const geometry_msgs::msg::PoseWithCovariance & unstamp(
44  const geometry_msgs::msg::PoseWithCovarianceStamped & msg)
45 {
46  return msg.pose;
47 }
48 inline const autoware_auto_geometry_msgs::msg::RelativePositionWithCovarianceStamped & unstamp(
49  const autoware_auto_geometry_msgs::msg::RelativePositionWithCovarianceStamped & msg) {return msg;}
50 
51 } // namespace detail
52 
59 template<typename MeasurementT>
60 struct MEASUREMENT_CONVERSION_PUBLIC convert_to
61 {
62  static_assert(
63  autoware::common::type_traits::impossible_branch<MeasurementT>(),
64  "This struct should always have a specialization.");
65 };
66 
72 template<typename MeasurementT>
73 struct MEASUREMENT_CONVERSION_PUBLIC convert_to<Stamped<MeasurementT>>
74 {
90  template<typename MsgT>
91  static Stamped<MeasurementT> from(const MsgT & msg)
92  {
93  return Stamped<MeasurementT>{
94  time_utils::from_message(msg.header.stamp),
96  };
97  }
98 };
99 
101 template<>
102 struct MEASUREMENT_CONVERSION_PUBLIC convert_to<PoseMeasurementXYZRPY64>
103 {
104  using MatrixT = PoseMeasurementXYZRPY64::State::Matrix;
105  static PoseMeasurementXYZRPY64 from(const geometry_msgs::msg::PoseWithCovariance & msg);
106  static bool variance_check(MatrixT & covariance);
107  static double noise_add_to_variance;
108 };
109 
111 template<>
112 struct MEASUREMENT_CONVERSION_PUBLIC convert_to<PoseMeasurementXYZ64>
113 {
114  static PoseMeasurementXYZ64 from(
115  const autoware_auto_geometry_msgs::msg::RelativePositionWithCovarianceStamped & msg);
116 };
117 
118 } // namespace state_estimation
119 } // namespace common
120 } // namespace autoware
121 
122 
123 #endif // MEASUREMENT_CONVERSION__MEASUREMENT_CONVERSION_HPP_
autoware::common::state_estimation::Stamped
Definition: measurement_typedefs.hpp:35
measurement_typedefs.hpp
autoware::common::state_estimation::convert_to< Stamped< MeasurementT > >::from
static Stamped< MeasurementT > from(const MsgT &msg)
A general function to be called for all Stamped measurements.
Definition: measurement_conversion.hpp:91
autoware::common::state_estimation::convert_to< PoseMeasurementXYZRPY64 >::noise_add_to_variance
static double noise_add_to_variance
Definition: measurement_conversion.hpp:107
visibility_control.hpp
autoware::common::state_estimation::LinearMeasurement
A class that represents a linear measurement.
Definition: linear_measurement.hpp:46
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
time_utils::from_message
TIME_UTILS_PUBLIC std::chrono::system_clock::time_point from_message(builtin_interfaces::msg::Time t) noexcept
Convert from std::chrono::time_point from time message.
Definition: time_utils.cpp:80
autoware::common::state_estimation::detail::unstamp
const geometry_msgs::msg::PoseWithCovariance & unstamp(const geometry_msgs::msg::PoseWithCovarianceStamped &msg)
Definition: measurement_conversion.hpp:43
time_utils.hpp
autoware::common::state_estimation::convert_to< PoseMeasurementXYZRPY64 >::MatrixT
PoseMeasurementXYZRPY64::State::Matrix MatrixT
Definition: measurement_conversion.hpp:104
autoware::common::state_estimation::convert_to
A default template structure used for message conversion. Only its specializations are to be used.
Definition: measurement_conversion.hpp:60