RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
OdometryEvent.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef ODOMETRYEVENT_H_
29#define ODOMETRYEVENT_H_
30
31#include "rtabmap/utilite/UEvent.h"
34#include "rtabmap/core/SensorData.h"
35#include "rtabmap/core/OdometryInfo.h"
36
37namespace rtabmap {
38
56class OdometryEvent : public UEvent
57{
58public:
61 {
62 _info.reg.covariance = cv::Mat::eye(6,6,CV_64FC1);
63 }
74 const SensorData & data,
75 const Transform & pose,
76 const OdometryInfo & info = OdometryInfo()) :
77 _data(data),
78 _pose(pose),
79 _info(info)
80 {
81 if(_info.reg.covariance.empty())
82 {
83 _info.reg.covariance = cv::Mat::eye(6,6,CV_64FC1);
84 }
85 UASSERT(_info.reg.covariance.cols == 6 && _info.reg.covariance.rows == 6 && _info.reg.covariance.type() == CV_64FC1);
86 UASSERT_MSG(uIsFinite(_info.reg.covariance.at<double>(0,0)) && _info.reg.covariance.at<double>(0,0)>0, "Transitional variance should not be null! (set to 1 if unknown)");
87 UASSERT_MSG(uIsFinite(_info.reg.covariance.at<double>(1,1)) && _info.reg.covariance.at<double>(1,1)>0, "Transitional variance should not be null! (set to 1 if unknown)");
88 UASSERT_MSG(uIsFinite(_info.reg.covariance.at<double>(2,2)) && _info.reg.covariance.at<double>(2,2)>0, "Transitional variance should not be null! (set to 1 if unknown)");
89 UASSERT_MSG(uIsFinite(_info.reg.covariance.at<double>(3,3)) && _info.reg.covariance.at<double>(3,3)>0, "Rotational variance should not be null! (set to 1 if unknown)");
90 UASSERT_MSG(uIsFinite(_info.reg.covariance.at<double>(4,4)) && _info.reg.covariance.at<double>(4,4)>0, "Rotational variance should not be null! (set to 1 if unknown)");
91 UASSERT_MSG(uIsFinite(_info.reg.covariance.at<double>(5,5)) && _info.reg.covariance.at<double>(5,5)>0, "Rotational variance should not be null! (set to 1 if unknown)");
92 }
93 virtual ~OdometryEvent() {}
94 virtual std::string getClassName() const {return "OdometryEvent";}
95
97 SensorData & data() {return _data;}
99 const SensorData & data() const {return _data;}
101 const Transform & pose() const {return _pose;}
103 const cv::Mat & covariance() const {return _info.reg.covariance;}
109 std::vector<float> velocity() const {
110 if(_info.interval>0.0)
111 {
112 std::vector<float> velocity(6,0);
113 float x,y,z,roll,pitch,yaw;
114 _info.transform.getTranslationAndEulerAngles(x,y,z,roll,pitch,yaw);
115 velocity[0] = x/_info.interval;
116 velocity[1] = y/_info.interval;
117 velocity[2] = z/_info.interval;
118 velocity[3] = roll/_info.interval;
119 velocity[4] = pitch/_info.interval;
120 velocity[5] = yaw/_info.interval;
121 return velocity;
122 }
123 return std::vector<float>();
124 }
126 const OdometryInfo & info() const {return _info;}
127
128private:
129 SensorData _data;
130 Transform _pose;
131 OdometryInfo _info;
132};
133
145{
146public:
148 OdometryResetEvent(const Transform & pose = Transform::getIdentity()){_pose = pose;}
149 virtual ~OdometryResetEvent() {}
150 virtual std::string getClassName() const {return "OdometryResetEvent";}
152 const Transform & getPose() const {return _pose;}
153private:
154 Transform _pose;
155};
156
157}
158
159
160#endif /* ODOMETRYEVENT_H_ */
ULogger class and convenient macros.
#define UASSERT(condition)
Definition ULogger.h:66
Basic mathematics functions.
bool uIsFinite(const T &value)
Definition UMath.h:53
One processed frame with the pose the odometry integrated for it.
OdometryEvent(const SensorData &data, const Transform &pose, const OdometryInfo &info=OdometryInfo())
Constructor.
const cv::Mat & covariance() const
virtual std::string getClassName() const
const OdometryInfo & info() const
OdometryEvent()
Creates an empty event, with an identity covariance.
const SensorData & data() const
const Transform & pose() const
std::vector< float > velocity() const
Linear and angular velocity, from the motion and the frame interval.
What one Odometry iteration produced, beyond the pose.
RegistrationInfo reg
Registration result: matches, inliers, covariance, ICP indicators and timings.
double interval
Time since the previous processed frame (s); the divisor for velocities.
Transform transform
Motion since the previous frame, null when lost.
Asks OdometryThread to restart the odometry from a given pose.
OdometryResetEvent(const Transform &pose=Transform::getIdentity())
virtual std::string getClassName() const
const Transform & getPose() const
Container class for all sensor data captured at a specific time.
Definition SensorData.h:97
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
static Transform getIdentity()
Returns identity transform.
void getTranslationAndEulerAngles(float &x, float &y, float &z, float &roll, float &pitch, float &yaw) const
Extracts translation and Euler angles (radians).