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;
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 
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_ */
GLM_FUNC_DECL T roll(detail::tquat< T, P > const &x)
SensorData & data()
Definition: OdometryEvent.h:69
Definition: UEvent.h:57
static Transform getIdentity()
Definition: Transform.cpp:380
Basic mathematics functions.
GLM_FUNC_DECL T pitch(detail::tquat< T, P > const &x)
bool uIsFinite(const T &value)
Definition: UMath.h:55
#define UASSERT(condition)
const Transform & pose() const
Definition: OdometryEvent.h:71
OdometryEvent(const SensorData &data, const Transform &pose, const OdometryInfo &info=OdometryInfo())
Definition: OdometryEvent.h:46
const SensorData & data() const
Definition: OdometryEvent.h:70
#define UASSERT_MSG(condition, msg_str)
Definition: ULogger.h:67
virtual std::string getClassName() const
const OdometryInfo & info() const
Definition: OdometryEvent.h:89
OdometryResetEvent(const Transform &pose=Transform::getIdentity())
const cv::Mat & covariance() const
Definition: OdometryEvent.h:72
const Transform & getPose() const
virtual std::string getClassName() const
Definition: OdometryEvent.h:67
ULogger class and convenient macros.
GLM_FUNC_DECL T yaw(detail::tquat< T, P > const &x)
RegistrationInfo reg
Definition: OdometryInfo.h:96
std::vector< float > velocity() const
Definition: OdometryEvent.h:73
void getTranslationAndEulerAngles(float &x, float &y, float &z, float &roll, float &pitch, float &yaw) const
Definition: Transform.cpp:227


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:59