RTAB-Map 0.23.10
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
39class OdometryEvent : public UEvent
40{
41public:
43 {
44 _info.reg.covariance = cv::Mat::eye(6,6,CV_64FC1);
45 }
47 const SensorData & data,
48 const Transform & pose,
49 const OdometryInfo & info = OdometryInfo()) :
50 _data(data),
51 _pose(pose),
52 _info(info)
53 {
54 if(_info.reg.covariance.empty())
55 {
56 _info.reg.covariance = cv::Mat::eye(6,6,CV_64FC1);
57 }
58 UASSERT(_info.reg.covariance.cols == 6 && _info.reg.covariance.rows == 6 && _info.reg.covariance.type() == CV_64FC1);
59 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)");
60 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)");
61 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)");
62 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)");
63 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)");
64 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)");
65 }
66 virtual ~OdometryEvent() {}
67 virtual std::string getClassName() const {return "OdometryEvent";}
68
69 SensorData & data() {return _data;}
70 const SensorData & data() const {return _data;}
71 const Transform & pose() const {return _pose;}
72 const cv::Mat & covariance() const {return _info.reg.covariance;}
73 std::vector<float> velocity() const {
74 if(_info.interval>0.0)
75 {
76 std::vector<float> velocity(6,0);
77 float x,y,z,roll,pitch,yaw;
78 _info.transform.getTranslationAndEulerAngles(x,y,z,roll,pitch,yaw);
79 velocity[0] = x/_info.interval;
80 velocity[1] = y/_info.interval;
81 velocity[2] = z/_info.interval;
82 velocity[3] = roll/_info.interval;
83 velocity[4] = pitch/_info.interval;
84 velocity[5] = yaw/_info.interval;
85 return velocity;
86 }
87 return std::vector<float>();
88 }
89 const OdometryInfo & info() const {return _info;}
90
91private:
92 SensorData _data;
93 Transform _pose;
94 OdometryInfo _info;
95};
96
98{
99public:
100 OdometryResetEvent(const Transform & pose = Transform::getIdentity()){_pose = pose;}
101 virtual ~OdometryResetEvent() {}
102 virtual std::string getClassName() const {return "OdometryResetEvent";}
103 const Transform & getPose() const {return _pose;}
104private:
105 Transform _pose;
106};
107
108}
109
110
111#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
virtual std::string getClassName() const
virtual std::string getClassName() 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).