IMU.h
Go to the documentation of this file.
1 /*
2  * IMU.h
3  *
4  * Created on: 2018-03-05
5  * Author: mathieu
6  */
7 
8 #ifndef IMU_H_
9 #define IMU_H_
10 
11 #include <opencv2/core/core.hpp>
12 #include <rtabmap/utilite/UEvent.h>
13 #include <rtabmap/core/Transform.h>
14 
15 namespace rtabmap {
16 
17 
18 // Correspondence class to sensor_msgs/IMU
19 class IMU
20 {
21 public:
22  IMU() {}
23  IMU(const cv::Vec4d & orientation, // qx qy qz qw
24  const cv::Mat & orientationCovariance,
25  const cv::Vec3d & angularVelocity,
26  const cv::Mat & angularVelocityCovariance,
27  const cv::Vec3d & linearAcceleration,
28  const cv::Mat & linearAccelerationCovariance,
30  orientation_(orientation),
31  orientationCovariance_(orientationCovariance),
32  angularVelocity_(angularVelocity),
33  angularVelocityCovariance_(angularVelocityCovariance),
34  linearAcceleration_(linearAcceleration),
35  linearAccelerationCovariance_(linearAccelerationCovariance),
37  {
38  }
39  IMU(const cv::Vec3d & angularVelocity,
40  const cv::Mat & angularVelocityCovariance,
41  const cv::Vec3d & linearAcceleration,
42  const cv::Mat & linearAccelerationCovariance,
44  angularVelocity_(angularVelocity),
45  angularVelocityCovariance_(angularVelocityCovariance),
46  linearAcceleration_(linearAcceleration),
47  linearAccelerationCovariance_(linearAccelerationCovariance),
49  {
50  }
51 
52  // qx qy qz qw
53  const cv::Vec4d & orientation() const {return orientation_;}
54  const cv::Mat & orientationCovariance() const {return orientationCovariance_;} // 3x3 double Row major about x, y, z axes, empty if orientation is not set
55 
56  const cv::Vec3d & angularVelocity() const {return angularVelocity_;}
57  const cv::Mat & angularVelocityCovariance() const {return angularVelocityCovariance_;} // 3x3 double Row major about x, y, z axes, empty if angularVelocity is not set
58 
59  const cv::Vec3d linearAcceleration() const {return linearAcceleration_;}
60  const cv::Mat & linearAccelerationCovariance() const {return linearAccelerationCovariance_;} // 3x3 double Row major x, y z, empty if linearAcceleration is not set
61 
62  const Transform & localTransform() const {return localTransform_;}
63 
64  // apply local transform rotation to data, and set Identity rotation for local transform
65  void convertToBaseFrame();
66 
67  bool empty() const
68  {
69  return localTransform_.isNull();
70  }
71 
72 private:
73  cv::Vec4d orientation_;
74  cv::Mat orientationCovariance_; // 3x3 double Row major about x, y, z axes, empty if orientation is not set
75 
76  cv::Vec3d angularVelocity_;
77  cv::Mat angularVelocityCovariance_; // 3x3 double Row major about x, y, z axes, empty if angularVelocity is not set
78 
80  cv::Mat linearAccelerationCovariance_; // 3x3 double Row major x, y z, empty if linearAcceleration is not set
81 
83 };
84 
85 class IMUEvent : public UEvent
86 {
87 public:
89  stamp_(0.0)
90  {}
91  IMUEvent(const IMU & data, double stamp) :
92  data_(data),
93  stamp_(stamp)
94  {
95  }
96  virtual std::string getClassName() const {return "IMUEvent";}
97  const IMU & getData() const {return data_;}
98  double getStamp() const {return stamp_;}
99 
100 private:
102  double stamp_;
103 };
104 
105 }
106 
107 
108 #endif /* IMU_H_ */
IMU(const cv::Vec3d &angularVelocity, const cv::Mat &angularVelocityCovariance, const cv::Vec3d &linearAcceleration, const cv::Mat &linearAccelerationCovariance, const Transform &localTransform=Transform::getIdentity())
Definition: IMU.h:39
Definition: UEvent.h:57
cv::Vec3d angularVelocity_
Definition: IMU.h:76
double getStamp() const
Definition: IMU.h:98
cv::Mat angularVelocityCovariance_
Definition: IMU.h:77
cv::Mat linearAccelerationCovariance_
Definition: IMU.h:80
static Transform getIdentity()
Definition: Transform.cpp:401
void convertToBaseFrame()
Definition: IMU.cpp:33
cv::Vec4d orientation_
Definition: IMU.h:73
const cv::Vec4d & orientation() const
Definition: IMU.h:53
cv::Mat orientationCovariance_
Definition: IMU.h:74
IMUEvent(const IMU &data, double stamp)
Definition: IMU.h:91
cv::Vec3d linearAcceleration_
Definition: IMU.h:79
IMU(const cv::Vec4d &orientation, const cv::Mat &orientationCovariance, const cv::Vec3d &angularVelocity, const cv::Mat &angularVelocityCovariance, const cv::Vec3d &linearAcceleration, const cv::Mat &linearAccelerationCovariance, const Transform &localTransform=Transform::getIdentity())
Definition: IMU.h:23
virtual std::string getClassName() const
Definition: IMU.h:96
const Transform & localTransform() const
Definition: IMU.h:62
double stamp_
Definition: IMU.h:102
bool isNull() const
Definition: Transform.cpp:107
const cv::Mat & linearAccelerationCovariance() const
Definition: IMU.h:60
const cv::Vec3d & angularVelocity() const
Definition: IMU.h:56
const cv::Mat & orientationCovariance() const
Definition: IMU.h:54
IMU()
Definition: IMU.h:22
Transform localTransform_
Definition: IMU.h:82
bool empty() const
Definition: IMU.h:67
const cv::Mat & angularVelocityCovariance() const
Definition: IMU.h:57
const cv::Vec3d linearAcceleration() const
Definition: IMU.h:59
const IMU & getData() const
Definition: IMU.h:97


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28