ImuConverter.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <depthai/depthai.hpp>
5 #include <iostream>
6 #include <opencv2/opencv.hpp>
7 #include <sstream>
8 #include <unordered_map>
9 
10 #ifdef IS_ROS2
11  #include "rclcpp/rclcpp.hpp"
12  #include "sensor_msgs/msg/imu.hpp"
13 #else
14  #include <ros/ros.h>
15 
16  #include <boost/make_shared.hpp>
17 
18  #include "sensor_msgs/Imu.h"
19 #endif
20 
21 namespace dai {
22 
23 namespace ros {
24 
25 #ifdef IS_ROS2
26 namespace ImuMsgs = sensor_msgs::msg;
27 using ImuPtr = ImuMsgs::Imu::SharedPtr;
28 #else
29 namespace ImuMsgs = sensor_msgs;
30 using ImuPtr = ImuMsgs::Imu::Ptr;
31 #endif
32 
34 
35 class ImuConverter {
36  public:
37  ImuConverter(const std::string& frameName,
39  double linear_accel_cov = 0.0,
40  double angular_velocity_cov = 0.0);
41 
42  void toRosMsg(std::shared_ptr<dai::IMUData> inData, std::deque<ImuMsgs::Imu>& outImuMsg);
43 
44  private:
45  void FillImuData_LinearInterpolation(std::vector<IMUPacket>& imuPackets, std::deque<ImuMsgs::Imu>& imuMsgs);
46  ImuMsgs::Imu CreateUnitMessage(dai::IMUReportAccelerometer accel, dai::IMUReportGyroscope gyro);
47 
48  uint32_t _sequenceNum;
49  double _linear_accel_cov, _angular_velocity_cov;
50  const std::string _frameName = "";
52  std::chrono::time_point<std::chrono::steady_clock> _steadyBaseTime;
53 #ifdef IS_ROS2
54  rclcpp::Time _rosBaseTime;
55 #else
57 #endif
58 };
59 
60 } // namespace ros
61 
62 namespace rosBridge = ros;
63 
64 } // namespace dai
std::chrono::time_point< std::chrono::steady_clock > _steadyBaseTime
ImuSyncMethod _syncMode
ImuMsgs::Imu::Ptr ImuPtr


depthai_bridge
Author(s): Sachin Guruswamy
autogenerated on Tue May 10 2022 03:01:27