Autoware.Auto
xsens_imu_translator.hpp
Go to the documentation of this file.
1 // Copyright 2018 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.
16 
18 
19 #ifndef XSENS_DRIVER__XSENS_IMU_TRANSLATOR_HPP_
20 #define XSENS_DRIVER__XSENS_IMU_TRANSLATOR_HPP_
21 
25 #include <cstdint>
26 #include <mutex>
27 #include <vector>
28 #include "sensor_msgs/msg/imu.hpp"
30 
31 namespace autoware
32 {
35 namespace drivers
36 {
37 namespace xsens_driver
38 {
39 
40 class XSENS_DRIVER_PUBLIC XsensImuTranslator
41  : public XsensBaseTranslator<XsensImuTranslator, sensor_msgs::msg::Imu>
42 {
43 public:
44  class Config
45  {
46 public:
48  Config();
49 
50 private:
51  };
52 
53  explicit XsensImuTranslator(const Config & config);
54 
55  void parse_timestamp(
56  sensor_msgs::msg::Imu & message,
57  int32_t data_id,
58  const std::vector<uint8_t> & content);
59 
60  void parse_acceleration(
61  sensor_msgs::msg::Imu & message,
62  int32_t data_id,
63  const std::vector<uint8_t> & content);
64 
65  template<typename MessageT>
66  void parse_acceleration_internal(
67  sensor_msgs::msg::Imu & message,
68  const std::vector<uint8_t> & content);
69 
70  void parse_orientation_data(
71  sensor_msgs::msg::Imu & message,
72  int32_t data_id,
73  const std::vector<uint8_t> & content);
74 
75  void parse_angular_velocity(
76  sensor_msgs::msg::Imu & message,
77  int32_t data_id,
78  const std::vector<uint8_t> & content);
79 
80  template<typename MessageT>
81  void parse_orientation_quaternion(
82  sensor_msgs::msg::Imu & message,
83  const std::vector<uint8_t> & content);
84 
85  template<typename MessageT>
86  void parse_angular_velocity_rate_of_turn(
87  sensor_msgs::msg::Imu & message,
88  const std::vector<uint8_t> & content);
89 
90  void parse_xdigroup_mtdata2(
91  XDIGroup xdigroup,
92  sensor_msgs::msg::Imu & message,
93  int32_t data_id,
94  const std::vector<uint8_t> & content);
95 
96  void parse_xdi_coordinates(
97  int32_t data_id,
98  sensor_msgs::msg::Imu & message);
99 
100  template<typename T, std::size_t kNumber_of_values>
101  std::array<T, kNumber_of_values> read_values(const std::vector<uint8_t> & content)
102  {
103  std::array<T, kNumber_of_values> values;
104 
105  common::helper_functions::ByteReader byte_reader(content);
106 
107  for (std::size_t i = 0; i < kNumber_of_values; ++i) {
108  byte_reader.read(values[i]);
109  }
110  return values;
111  }
112 }; // class Driver
113 } // namespace xsens_driver
114 } // namespace drivers
115 } // namespace autoware
116 
117 #endif // XSENS_DRIVER__XSENS_IMU_TRANSLATOR_HPP_
autoware::common::helper_functions::ByteReader
A utility class to read byte vectors in big-endian order.
Definition: byte_reader.hpp:33
autoware::drivers::xsens_driver::XsensImuTranslator::Config
Definition: xsens_imu_translator.hpp:44
xsens_common.hpp
autoware::common::helper_functions::ByteReader::read
void read(T &value)
Definition: byte_reader.hpp:51
autoware::drivers::xsens_driver::XsensBaseTranslator
Definition: xsens_base_translator.hpp:44
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
xsens_base_translator.hpp
autoware::drivers::xsens_driver::XsensImuTranslator::read_values
std::array< T, kNumber_of_values > read_values(const std::vector< uint8_t > &content)
Definition: xsens_imu_translator.hpp:101
autoware::drivers::xsens_driver::XDIGroup
XDIGroup
Definition: xsens_common.hpp:152
byte_reader.hpp
This file includes common helper functions.
autoware::drivers::xsens_driver::XsensImuTranslator
Definition: xsens_imu_translator.hpp:40
visibility_control.hpp