OdometryEvent.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, 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 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON 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
25 SOFTWARE, 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"
33 #include "rtabmap/utilite/UMath.h"
36 
37 namespace rtabmap {
38 
39 class OdometryEvent : public UEvent
40 {
41 public:
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;
79  velocity[0] = x/_info.interval;
80  velocity[1] = y/_info.interval;
81  velocity[2] = z/_info.interval;
85  return velocity;
86  }
87  return std::vector<float>();
88  }
89  const OdometryInfo & info() const {return _info;}
90 
91 private:
95 };
96 
97 class OdometryResetEvent : public UEvent
98 {
99 public:
101  virtual ~OdometryResetEvent() {}
102  virtual std::string getClassName() const {return "OdometryResetEvent";}
103  const Transform & getPose() const {return _pose;}
104 private:
106 };
107 
108 }
109 
110 
111 #endif /* ODOMETRYEVENT_H_ */
rtabmap::SensorData
Definition: SensorData.h:51
rtabmap::OdometryEvent
Definition: OdometryEvent.h:39
rtabmap::OdometryResetEvent::getPose
const Transform & getPose() const
Definition: OdometryEvent.h:103
rtabmap::OdometryResetEvent::~OdometryResetEvent
virtual ~OdometryResetEvent()
Definition: OdometryEvent.h:101
glm::yaw
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
OdometryInfo.h
rtabmap::OdometryEvent::pose
const Transform & pose() const
Definition: OdometryEvent.h:71
rtabmap::OdometryEvent::data
const SensorData & data() const
Definition: OdometryEvent.h:70
rtabmap::OdometryEvent::_pose
Transform _pose
Definition: OdometryEvent.h:93
rtabmap::Transform::getIdentity
static Transform getIdentity()
Definition: Transform.cpp:411
SensorData.h
y
Matrix3f y
rtabmap::OdometryEvent::_data
SensorData _data
Definition: OdometryEvent.h:92
UMath.h
Basic mathematics functions.
rtabmap::OdometryInfo::transform
Transform transform
Definition: OdometryInfo.h:115
rtabmap::Transform::getTranslationAndEulerAngles
void getTranslationAndEulerAngles(float &x, float &y, float &z, float &roll, float &pitch, float &yaw) const
Definition: Transform.cpp:258
UEvent
Definition: UEvent.h:57
rtabmap::OdometryResetEvent::_pose
Transform _pose
Definition: OdometryEvent.h:105
UEvent.h
rtabmap::OdometryResetEvent::getClassName
virtual std::string getClassName() const
Definition: OdometryEvent.h:102
rtabmap::OdometryResetEvent::OdometryResetEvent
OdometryResetEvent(const Transform &pose=Transform::getIdentity())
Definition: OdometryEvent.h:100
rtabmap::OdometryEvent::OdometryEvent
OdometryEvent()
Definition: OdometryEvent.h:42
rtabmap::RegistrationInfo::covariance
cv::Mat covariance
Definition: RegistrationInfo.h:75
UASSERT
#define UASSERT(condition)
z
z
x
x
rtabmap::OdometryEvent::info
const OdometryInfo & info() const
Definition: OdometryEvent.h:89
rtabmap::OdometryEvent::OdometryEvent
OdometryEvent(const SensorData &data, const Transform &pose, const OdometryInfo &info=OdometryInfo())
Definition: OdometryEvent.h:46
glm::pitch
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
rtabmap::OdometryEvent::covariance
const cv::Mat & covariance() const
Definition: OdometryEvent.h:72
UASSERT_MSG
#define UASSERT_MSG(condition, msg_str)
Definition: ULogger.h:67
ULogger.h
ULogger class and convenient macros.
rtabmap::OdometryEvent::velocity
std::vector< float > velocity() const
Definition: OdometryEvent.h:73
rtabmap::Transform
Definition: Transform.h:41
rtabmap::OdometryInfo::interval
double interval
Definition: OdometryInfo.h:114
rtabmap::OdometryInfo::reg
RegistrationInfo reg
Definition: OdometryInfo.h:99
rtabmap::OdometryResetEvent
Definition: OdometryEvent.h:97
rtabmap::OdometryInfo
Definition: OdometryInfo.h:40
rtabmap::OdometryEvent::data
SensorData & data()
Definition: OdometryEvent.h:69
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::OdometryEvent::getClassName
virtual std::string getClassName() const
Definition: OdometryEvent.h:67
uIsFinite
bool uIsFinite(const T &value)
Definition: UMath.h:53
rtabmap::OdometryEvent::_info
OdometryInfo _info
Definition: OdometryEvent.h:94
glm::roll
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
rtabmap::OdometryEvent::~OdometryEvent
virtual ~OdometryEvent()
Definition: OdometryEvent.h:66


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:13