Main MRPT website > C++ reference for MRPT 1.9.9
CRobot2DPoseEstimator.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef CRobot2DPoseEstimator_H
10 #define CRobot2DPoseEstimator_H
11 
13 #include <mrpt/system/datetime.h>
14 #include <mutex>
15 
16 namespace mrpt
17 {
18 namespace poses
19 {
20 /** A simple filter to estimate and extrapolate the robot 2D (x,y,phi) pose from
21  *asynchronous odometry and localization/SLAM data.
22  * The implemented model is a state vector:
23  * - TPose2D (x,y,phi) + TTwist2D (vx,vy,omega)
24  * The filter can be asked for an extrapolation for some arbitrary time `t'`,
25  *and it'll do a simple linear prediction.
26  * **All methods are thread-safe**.
27  * \ingroup poses_grp poses_pdf_grp
28  */
30 {
31  public:
32  /** Default constructor */
34  /** Destructor */
35  virtual ~CRobot2DPoseEstimator();
36  /** Resets all internal state. */
37  void reset();
38 
39  /** Updates the filter with new global-coordinates localization data from a
40  * localization or SLAM source.
41  * \param tim The timestamp of the sensor readings used to evaluate
42  * localization / SLAM.
43  */
45  const mrpt::math::TPose2D& newPose, mrpt::system::TTimeStamp tim);
46 
47  /** Updates the filter with new odometry readings. */
49  const mrpt::math::TPose2D& newGlobalOdometry,
50  mrpt::system::TTimeStamp cur_tim, bool hasVelocities = false,
51  const mrpt::math::TTwist2D& newRobotVelLocal = mrpt::math::TTwist2D());
52 
53  /** Get the estimate for a given timestamp (defaults to `now()`), obtained
54  * as:
55  *
56  * last_loc (+) [ last_odo (-) odo_ref ] (+) extrapolation_from_vw
57  *
58  * \return true is the estimate can be trusted. False if the real observed
59  * data is too old or there is no valid data yet.
60  * \sa getLatestRobotPose
61  */
62  bool getCurrentEstimate(
64  mrpt::math::TTwist2D& velGlobal,
65  mrpt::system::TTimeStamp tim_query = mrpt::system::now()) const;
66 
67  /** Get the latest known robot pose, either from odometry or localization.
68  * This differs from getCurrentEstimate() in that this method does NOT
69  * extrapolate as getCurrentEstimate() does.
70  * \return false if there is not estimation yet.
71  * \sa getCurrentEstimate
72  */
73  bool getLatestRobotPose(mrpt::math::TPose2D& pose) const;
74 
75  /** \overload */
76  bool getLatestRobotPose(CPose2D& pose) const;
77 
78  struct TOptions
79  {
81  /** To consider data old, in seconds */
83  /** To consider data old, in seconds */
85  };
86 
87  /** parameters of the filter. */
89 
90  private:
91  std::mutex m_cs;
92 
94  /** Last pose as estimated by the localization/SLAM subsystem. */
96 
97  /** The interpolated odometry position for the last "m_robot_pose" (used as
98  * "coordinates base" for subsequent odo readings) */
100 
103  /** Robot odometry-based velocity in a local frame of reference. */
105 
106  /** An auxiliary method to extrapolate the pose of a robot located at "p"
107  * with velocities (v,w) after a time delay "delta_time". */
108  static void extrapolateRobotPose(
109  const mrpt::math::TPose2D& p,
110  const mrpt::math::TTwist2D& robot_vel_local, const double delta_time,
111  mrpt::math::TPose2D& new_p);
112 
113 }; // end of class
114 
115 } // End of namespace
116 } // End of namespace
117 
118 #endif
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:32
mrpt::math::TPose2D m_loc_odo_ref
The interpolated odometry position for the last "m_robot_pose" (used as "coordinates base" for subseq...
double max_odometry_age
To consider data old, in seconds.
bool getLatestRobotPose(mrpt::math::TPose2D &pose) const
Get the latest known robot pose, either from odometry or localization.
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:76
A simple filter to estimate and extrapolate the robot 2D (x,y,phi) pose from asynchronous odometry an...
void reset()
Resets all internal state.
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
mrpt::math::TPose2D m_last_loc
Last pose as estimated by the localization/SLAM subsystem.
void processUpdateNewPoseLocalization(const mrpt::math::TPose2D &newPose, mrpt::system::TTimeStamp tim)
Updates the filter with new global-coordinates localization data from a localization or SLAM source...
mrpt::system::TTimeStamp m_last_loc_time
mrpt::system::TTimeStamp m_last_odo_time
void processUpdateNewOdometry(const mrpt::math::TPose2D &newGlobalOdometry, mrpt::system::TTimeStamp cur_tim, bool hasVelocities=false, const mrpt::math::TTwist2D &newRobotVelLocal=mrpt::math::TTwist2D())
Updates the filter with new odometry readings.
double max_localiz_age
To consider data old, in seconds.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
bool getCurrentEstimate(mrpt::math::TPose2D &pose, mrpt::math::TTwist2D &velLocal, mrpt::math::TTwist2D &velGlobal, mrpt::system::TTimeStamp tim_query=mrpt::system::now()) const
Get the estimate for a given timestamp (defaults to now()), obtained as:
Lightweight 2D pose.
TOptions params
parameters of the filter.
mrpt::math::TTwist2D m_robot_vel_local
Robot odometry-based velocity in a local frame of reference.
static void extrapolateRobotPose(const mrpt::math::TPose2D &p, const mrpt::math::TTwist2D &robot_vel_local, const double delta_time, mrpt::math::TPose2D &new_p)
An auxiliary method to extrapolate the pose of a robot located at "p" with velocities (v...
GLfloat GLfloat p
Definition: glext.h:6305



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019