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-2018, 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/core/Clock.h>
14 #include <mrpt/poses/poses_frwds.h>
15 #include <mutex>
16 #include <optional>
17 
18 namespace mrpt::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::Clock::time_point tim);
46 
47  /** Updates the filter with new odometry readings. */
49  const mrpt::math::TPose2D& newGlobalOdometry,
50  mrpt::Clock::time_point 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::Clock::time_point tim_query = mrpt::Clock::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(mrpt::poses::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 
93  std::optional<mrpt::Clock::time_point> m_last_loc_time;
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 
101  std::optional<mrpt::Clock::time_point> m_last_odo_time;
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 }
116 #endif
117 
118 
std::chrono::time_point< Clock > time_point
Definition: Clock.h:26
std::optional< mrpt::Clock::time_point > m_last_odo_time
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.
A simple filter to estimate and extrapolate the robot 2D (x,y,phi) pose from asynchronous odometry an...
static time_point now() noexcept
Returns the current time, with the highest resolution available.
Definition: Clock.cpp:46
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 processUpdateNewOdometry(const mrpt::math::TPose2D &newGlobalOdometry, mrpt::Clock::time_point cur_tim, bool hasVelocities=false, const mrpt::math::TTwist2D &newRobotVelLocal=mrpt::math::TTwist2D())
Updates the filter with new odometry readings.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
double max_localiz_age
To consider data old, in seconds.
bool getCurrentEstimate(mrpt::math::TPose2D &pose, mrpt::math::TTwist2D &velLocal, mrpt::math::TTwist2D &velGlobal, mrpt::Clock::time_point tim_query=mrpt::Clock::now()) const
Get the estimate for a given timestamp (defaults to now()), obtained as:
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:38
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...
void processUpdateNewPoseLocalization(const mrpt::math::TPose2D &newPose, mrpt::Clock::time_point tim)
Updates the filter with new global-coordinates localization data from a localization or SLAM source...
GLfloat GLfloat p
Definition: glext.h:6305
std::optional< mrpt::Clock::time_point > m_last_loc_time



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020