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 
17 
18 #ifndef STATE_ESTIMATION_NODES__MEASUREMENT_CONVERSION_HPP_
19 #define STATE_ESTIMATION_NODES__MEASUREMENT_CONVERSION_HPP_
20 
21 #include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
22 #include <geometry_msgs/msg/twist_with_covariance_stamped.hpp>
24 #include <nav_msgs/msg/odometry.hpp>
25 #include <rclcpp/time.hpp>
27 
28 #include <Eigen/Geometry>
29 
30 namespace autoware
31 {
32 namespace prediction
33 {
34 
35 using MeasurementPose = Measurement<common::types::float32_t,
38 
44 
48 
57 template<typename MeasurementT, typename MessageT>
59  const MessageT &, const Eigen::Isometry3f &)
60 {
61  static_assert(
62  sizeof(MessageT) == -1,
63  "You have to have a specialization for message_to_measurement() function!");
64  // We only have this throw here to make linter happy as this is a non-void function.
65  throw std::runtime_error("You have to have a specialization for message_to_measurement()!");
66 }
67 
78 template<std::int32_t kStateDimentionality, typename FloatT>
79 static constexpr Eigen::Transform<
80  FloatT, kStateDimentionality, Eigen::TransformTraits::Isometry> downscale_isometry(
81  const Eigen::Transform<FloatT, 3, Eigen::TransformTraits::Isometry> & isometry)
82 {
83  static_assert(kStateDimentionality <= 3, "We only handle scaling the isometry down.");
84  using Isometry = Eigen::Transform<
85  FloatT, kStateDimentionality, Eigen::TransformTraits::Isometry>;
86  Isometry result{Isometry::Identity()};
87  result.linear() = isometry.rotation()
88  .template block<kStateDimentionality, kStateDimentionality>(0, 0);
89  result.translation() = isometry.translation().topRows(kStateDimentionality);
90  return result;
91 }
92 
101 template<>
102 STATE_ESTIMATION_NODES_PUBLIC MeasurementPoseAndSpeed message_to_measurement(
103  const nav_msgs::msg::Odometry & msg,
104  const Eigen::Isometry3f & tf_world_message);
105 
114 template<>
115 STATE_ESTIMATION_NODES_PUBLIC MeasurementSpeed message_to_measurement(
116  const geometry_msgs::msg::TwistWithCovarianceStamped & msg,
117  const Eigen::Isometry3f & tf_world_message);
118 
127 template<>
128 STATE_ESTIMATION_NODES_PUBLIC MeasurementPose message_to_measurement(
129  const geometry_msgs::msg::PoseWithCovarianceStamped & msg,
130  const Eigen::Isometry3f & tf_world_message);
131 
132 } // namespace prediction
133 } // namespace autoware
134 
135 
136 #endif // STATE_ESTIMATION_NODES__MEASUREMENT_CONVERSION_HPP_
static constexpr Eigen::Transform< FloatT, kStateDimentionality, Eigen::TransformTraits::Isometry > downscale_isometry(const Eigen::Transform< FloatT, 3, Eigen::TransformTraits::Isometry > &isometry)
Downscale the isometry to a lower dimention if needed.
Definition: measurement_conversion.hpp:80
float float32_t
Definition: types.hpp:36
Measurement< common::types::float32_t, motion::motion_model::ConstantAcceleration::States::POSE_X, motion::motion_model::ConstantAcceleration::States::POSE_Y > MeasurementPose
Definition: measurement_conversion.hpp:37
This file defines the constant velocity motion model.
static const index_t POSE_X
index of x position
Definition: constant_acceleration.hpp:49
MeasurementT message_to_measurement(const MessageT &, const Eigen::Isometry3f &)
Interface for converting a message into a measurement.
Definition: measurement_conversion.hpp:58
static const index_t VELOCITY_Y
index of y velocity
Definition: constant_acceleration.hpp:52
geometry_msgs::msg::TransformStamped Transform
Definition: recordreplay_planner_node.hpp:56
static const index_t POSE_Y
index of y position
Definition: constant_acceleration.hpp:50
static const index_t VELOCITY_X
index of x velocity
Definition: constant_acceleration.hpp:51
Definition: measurement.hpp:46
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