60 m_robot_vel_local =
TTwist2D(.0, .0, .0);
71 m_last_loc_time = cur_tim;
78 extrapolateRobotPose(m_last_odo,m_robot_vel_local,dT,m_loc_odo_ref);
84 const TPose2D &newGlobalOdometry,
97 if (dT<=0) std::cerr <<
"[CRobot2DPoseEstimator::processUpdateNewOdometry] WARNING: Diff. in timestamps between odometry should be >0, and it's " << dT <<
"\n";
103 m_robot_vel_local = velLocal;
109 m_robot_vel_local =
TTwist2D(.0, .0, .0);
113 m_last_odo_time = cur_tim;
114 m_last_odo = newGlobalOdometry;
124 const double dTimeLoc =
timeDifference(m_last_loc_time, tim_query);
125 if (dTimeLoc>
params.max_localiz_age)
133 const double dTimeOdo =
timeDifference(m_last_odo_time, tim_query);
134 if (dTimeOdo >
params.max_odometry_age)
137 extrapolateRobotPose(
p, m_robot_vel_local,dTimeOdo,pose);
140 velLocal = m_robot_vel_local;
141 velGlobal = velLocal;
153 bool ret = getCurrentEstimate(pose, velLocal, velGlobal, tim_query);
173 ret_odo = (m_last_odo_time>m_last_loc_time);
192 const double delta_time,
195 if (velLocal.
vx==0 && velLocal.
vy ==0 && velLocal.
omega == 0)
200 if (std::abs(velLocal.
vy)>1e-2)
207 new_p.
phi =
p.phi + delta_time * velLocal.
omega;
212 const double R = velLocal.
vx / velLocal.
omega;
213 const double theta = velLocal.
omega*delta_time;
214 const double cc = cos(
p.phi);
215 const double ss = sin(
p.phi);
217 const double arc_x =
R*sin(theta);
218 const double arc_y =
R*(1-cos(theta));
220 new_p.
x =
p.x + cc*arc_x - ss*arc_y;
221 new_p.
y =
p.y + ss*arc_x + cc*arc_y;
222 new_p.
phi =
p.phi + theta;
230 bool ret = getCurrentEstimate(
p, velLocal, velGlobal, tim_query);
241 bool v = getLatestRobotPose(
p);
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
double x() const
Common members of all points & poses classes.
A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
CRobot2DPoseEstimator()
Default constructor.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
bool getLatestRobotPose(mrpt::math::TPose2D &pose) const
Get the latest known robot pose, either from odometry or localization.
void composePoint(double lx, double ly, double &gx, double &gy) const
An alternative, slightly more efficient way of doing with G and L being 2D points and P this 2D pose...
void reset()
Resets all internal state.
GLubyte GLubyte GLubyte GLubyte w
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
This base provides a set of functions for maths stuff.
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...
double vy
Velocity components: X,Y (m/s)
This namespace provides multitask, synchronization utilities.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
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.
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...
virtual ~CRobot2DPoseEstimator()
Destructor.
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:
const double & phi() const
Get the phi angle of the 2D pose (in radians)
double BASE_IMPEXP timeDifference(const mrpt::system::TTimeStamp t_first, const mrpt::system::TTimeStamp t_later)
Returns the time difference from t1 to t2 (positive if t2 is posterior to t1), in seconds...
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...
GLenum const GLfloat * params
double phi
Orientation (rads)
double omega
Angular velocity (rad/s)