Main MRPT website > C++ reference for MRPT 1.9.9
CAbstractNavigator.cpp
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 
10 #include "nav-precomp.h" // Precomp header
11 
15 #include <limits>
16 #include <typeinfo>
17 
18 using namespace mrpt::nav;
19 using namespace std;
20 
21 const double PREVIOUS_POSES_MAX_AGE = 20; // seconds
22 
23 // Ctor: CAbstractNavigator::TargetInfo
25  : target_coords(0, 0, 0),
26  target_frame_id("map"),
27  targetAllowedDistance(0.5),
28  targetIsRelative(false),
29  targetDesiredRelSpeed(.05),
30  targetIsIntermediaryWaypoint(false)
31 {
32 }
33 
34 // Gets navigation params as a human-readable format:
36 {
37  string s;
38  s += mrpt::format(
39  "target_coords = (%.03f,%.03f,%.03f deg)\n", target_coords.x,
40  target_coords.y, target_coords.phi);
41  s += mrpt::format("target_frame_id = \"%s\"\n", target_frame_id.c_str());
42  s += mrpt::format("targetAllowedDistance = %.03f\n", targetAllowedDistance);
43  s += mrpt::format(
44  "targetIsRelative = %s\n", targetIsRelative ? "YES" : "NO");
45  s += mrpt::format(
46  "targetIsIntermediaryWaypoint = %s\n",
47  targetIsIntermediaryWaypoint ? "YES" : "NO");
48  s += mrpt::format("targetDesiredRelSpeed = %.02f\n", targetDesiredRelSpeed);
49  return s;
50 }
51 
53  const TargetInfo& o) const
54 {
55  return target_coords == o.target_coords &&
56  target_frame_id == o.target_frame_id &&
57  targetAllowedDistance == o.targetAllowedDistance &&
58  targetIsRelative == o.targetIsRelative &&
59  targetDesiredRelSpeed == o.targetDesiredRelSpeed &&
60  targetIsIntermediaryWaypoint == o.targetIsIntermediaryWaypoint;
61 }
62 
63 // Gets navigation params as a human-readable format:
65 {
66  string s;
67  s += "navparams. Single target:\n";
68  s += target.getAsText();
69  return s;
70 }
71 
74 {
75  auto* rhs = dynamic_cast<const CAbstractNavigator::TNavigationParams*>(&o);
76  return (rhs != nullptr) && (this->target == rhs->target);
77 }
78 
80  : pose(0, 0, 0),
81  velGlobal(0, 0, 0),
82  velLocal(0, 0, 0),
83  rawOdometry(0, 0, 0),
84  timestamp(INVALID_TIMESTAMP),
85  pose_frame_id()
86 {
87 }
88 
89 /*---------------------------------------------------------------
90  Constructor
91  ---------------------------------------------------------------*/
93  : mrpt::system::COutputLogger("MRPT_navigator"),
98  m_robot(react_iterf_impl),
99  m_curPoseVel(),
101  m_latestPoses(),
103  m_timlog_delays(true, "CAbstractNavigator::m_timlog_delays")
104 {
108 }
109 
110 // Dtor:
112 /** \callergraph */
114 {
115  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
116  MRPT_LOG_DEBUG("CAbstractNavigator::cancel() called.");
118  this->stop(false /*not emergency*/);
119 }
120 
121 /** \callergraph */
123 {
124  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
125 
126  MRPT_LOG_DEBUG("[CAbstractNavigator::resume() called.");
128 }
129 
130 /** \callergraph */
132 {
133  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
134 
135  // Issue an "stop" if we are moving:
136  // Update: do it *always*, even if the current velocity is zero, since
137  // we may be in the middle of a multi-part motion command. It's safer.
138  this->stop(false /*not an emergency stop*/);
139 
140  MRPT_LOG_DEBUG("CAbstractNavigator::suspend() called.");
142 }
143 
144 /** \callergraph */
146 {
147  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
148 
149  MRPT_LOG_DEBUG("CAbstractNavigator::resetNavError() called.");
151 }
152 
154  const std::weak_ptr<mrpt::poses::FrameTransformer<2>>& frame_tf)
155 {
156  m_frame_tf = frame_tf;
157 }
158 
160 {
161  MRPT_START
162 
163  params_abstract_navigator.loadFromConfigFile(c, "CAbstractNavigator");
164 
165  // At this point, all derived classes have already loaded their parameters.
166  // Dump them to debug output:
167  {
169  this->saveConfigFile(cfg_mem);
170  MRPT_LOG_INFO(cfg_mem.getContent());
171  }
172 
173  MRPT_END
174 }
175 
177 {
178  params_abstract_navigator.saveToConfigFile(c, "CAbstractNavigator");
179 }
180 
181 /** \callergraph */
183 {
184  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
186  m_timlog_delays, "CAbstractNavigator::navigationStep()");
187 
188  const TState prevState = m_navigationState;
189  switch (m_navigationState)
190  {
191  case IDLE:
192  case SUSPENDED:
193  try
194  {
195  // If we just arrived at this state, stop robot:
197  {
199  "[CAbstractNavigator::navigationStep()] Navigation "
200  "stopped.");
201  // this->stop(); stop() is called by the method switching
202  // the "state", so we have more flexibility
204  }
205  }
206  catch (...)
207  {
208  }
209  break;
210 
211  case NAV_ERROR:
212  try
213  {
214  // Send end-of-navigation event:
217  {
218  m_pending_events.push_back(std::bind(
220  std::ref(m_robot)));
221  }
222 
223  // If we just arrived at this state, stop the robot:
225  {
227  "[CAbstractNavigator::navigationStep()] Stopping "
228  "Navigation due to a NAV_ERROR state!");
229  this->stop(false /*not emergency*/);
231  }
232  }
233  catch (...)
234  {
235  }
236  break;
237 
238  case NAVIGATING:
240  true /* do call virtual method nav implementation*/);
241  break; // End case NAVIGATING
242  };
243  m_lastNavigationState = prevState;
244 
246 }
247 
248 /** \callergraph */
250 {
251  // Invoke pending events:
252  for (auto& ev : m_pending_events)
253  {
254  ev();
255  }
256  m_pending_events.clear();
257 }
258 
259 /** \callergraph */
261 {
262  try
263  {
264  this->stop(true /* emergency*/);
265  }
266  catch (...)
267  {
268  }
270  MRPT_LOG_ERROR(msg);
271 }
272 
274 {
275  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
276 
277  m_navigationEndEventSent = false;
278  m_navigationParams.reset();
279 }
280 
282 {
283  MRPT_START;
284  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
285 
286  ASSERT_(params != nullptr);
287  ASSERT_(
288  params->target.targetDesiredRelSpeed >= .0 &&
289  params->target.targetDesiredRelSpeed <= 1.0);
290 
291  // Copy data:
292  m_navigationParams = params->clone();
293 
294  // Transform: relative -> absolute, if needed.
295  if (m_navigationParams->target.targetIsRelative)
296  {
298  m_navigationParams->target.target_coords =
299  m_curPoseVel.pose + m_navigationParams->target.target_coords;
300  m_navigationParams->target.targetIsRelative =
301  false; // Now it's not relative
302  }
303 
304  // new state:
306 
307  // Reset the bad navigation alarm:
308  m_badNavAlarm_minDistTarget = std::numeric_limits<double>::max();
310 
311  MRPT_END;
312 }
313 
316 {
317  MRPT_START;
319  this->processNavigateCommand(params);
320  MRPT_END;
321 }
322 
324 {
325  // Ignore calls too-close in time, e.g. from the navigationStep() methods of
326  // AbstractNavigator and a derived, overriding class.
327  const double robot_time_secs =
328  m_robot.getNavigationTime(); // this is clockwall time for real robots,
329  // simulated time in simulators.
330 
331  const double MIN_TIME_BETWEEN_POSE_UPDATES = 20e-3;
333  {
334  const double last_call_age =
335  robot_time_secs - m_last_curPoseVelUpdate_robot_time;
336  if (last_call_age < MIN_TIME_BETWEEN_POSE_UPDATES)
337  {
339  5.0,
340  "updateCurrentPoseAndSpeeds: ignoring call, since last call "
341  "was only %f ms ago.",
342  last_call_age * 1e3);
343  return; // previous data is still valid: don't query the robot
344  // again
345  }
346  }
347 
348  {
350  m_timlog_delays, "getCurrentPoseAndSpeeds()");
351  m_curPoseVel.pose_frame_id = std::string("map"); // default
356  {
358  try
359  {
360  this->stop(true /*emergency*/);
361  }
362  catch (...)
363  {
364  }
366  "ERROR calling m_robot.getCurrentPoseAndSpeeds, stopping robot "
367  "and finishing navigation");
368  throw std::runtime_error(
369  "ERROR calling m_robot.getCurrentPoseAndSpeeds, stopping robot "
370  "and finishing navigation");
371  }
372  }
375 
376  m_last_curPoseVelUpdate_robot_time = robot_time_secs;
377  const bool changed_frame_id =
380 
381  if (changed_frame_id)
382  {
383  // If frame changed, clear past poses. This could be improved by
384  // requesting
385  // the transf between the two frames, but it's probably not worth.
388  }
389 
390  // Append to list of past poses:
393 
394  // Purge old ones:
395  while (m_latestPoses.size() > 1 &&
397  m_latestPoses.begin()->first, m_latestPoses.rbegin()->first) >
399  {
401  }
402  while (m_latestOdomPoses.size() > 1 &&
404  m_latestOdomPoses.begin()->first,
406  {
408  }
409 }
410 
411 /** \callergraph */
413  const mrpt::kinematics::CVehicleVelCmd& vel_cmd)
414 {
415  return m_robot.changeSpeeds(vel_cmd);
416 }
417 /** \callergraph */
419 /** \callergraph */
420 bool CAbstractNavigator::stop(bool isEmergencyStop)
421 {
422  return m_robot.stop(isEmergencyStop);
423 }
424 
426  : dist_to_target_for_sending_event(0),
427  alarm_seems_not_approaching_target_timeout(30),
428  dist_check_target_is_blocked(0.6),
429  hysteresis_check_target_is_blocked(3)
430 {
431 }
434 {
435  MRPT_LOAD_CONFIG_VAR_CS(dist_to_target_for_sending_event, double);
436  MRPT_LOAD_CONFIG_VAR_CS(alarm_seems_not_approaching_target_timeout, double);
437  MRPT_LOAD_CONFIG_VAR_CS(dist_check_target_is_blocked, double);
438  MRPT_LOAD_CONFIG_VAR_CS(hysteresis_check_target_is_blocked, int);
439 }
442 {
444  dist_to_target_for_sending_event,
445  "Default value=0, means use the `targetAllowedDistance` passed by the "
446  "user in the navigation request.");
448  alarm_seems_not_approaching_target_timeout,
449  "navigator timeout (seconds) [Default=30 sec]");
451  dist_check_target_is_blocked,
452  "When closer than this distance, check if the target is blocked to "
453  "abort navigation with an error. [Default=0.6 m]");
455  dist_to_target_for_sending_event,
456  "Default value=0, means use the `targetAllowedDistance` passed by the"
457  " user in the navigation request.");
459  alarm_seems_not_approaching_target_timeout,
460  "navigator timeout (seconds) [Default=30 sec]");
462  dist_check_target_is_blocked,
463  "When closer than this distance, check if the target is blocked to "
464  "abort navigation with an error. [Default=0.6 m]");
466  hysteresis_check_target_is_blocked,
467  "How many steps should the condition for dist_check_target_is_blocked "
468  "be fulfilled to raise an event");
469 }
470 
474 {
475  return typeid(a) == typeid(b) && a.isEqual(b);
476 }
477 
478 /** \callergraph */
479 bool CAbstractNavigator::checkHasReachedTarget(const double targetDist) const
480 {
481  return (targetDist < m_navigationParams->target.targetAllowedDistance);
482 }
483 
484 /** \callergraph */
486 {
487  m_robot.startWatchdog(1000); // Watchdog = 1 seg
488  m_latestPoses.clear(); // Clear cache of last poses.
491 }
492 
493 /** \callergraph */
495  bool call_virtual_nav_method)
496 {
497  const TState prevState = m_navigationState;
498  try
499  {
501  {
503  "[CAbstractNavigator::navigationStep()] Starting Navigation. "
504  "Watchdog initiated...\n");
505  if (m_navigationParams)
507  "[CAbstractNavigator::navigationStep()] Navigation "
508  "Params:\n%s\n",
509  m_navigationParams->getAsText().c_str()));
510 
512  }
513 
514  // Have we just started the navigation?
516  {
517  m_pending_events.push_back(std::bind(
519  std::ref(m_robot)));
520  }
521 
522  /* ----------------------------------------------------------------
523  Get current robot dyn state:
524  ---------------------------------------------------------------- */
526 
527  /* ----------------------------------------------------------------
528  Have we reached the target location?
529  ---------------------------------------------------------------- */
530  // Build a 2D segment from the current robot pose to the previous one:
532  const mrpt::math::TSegment2D seg_robot_mov = mrpt::math::TSegment2D(
534  m_latestPoses.size() > 1
535  ? mrpt::math::TPoint2D((++m_latestPoses.rbegin())->second)
536  : mrpt::math::TPoint2D((m_latestPoses.rbegin())->second));
537 
538  if (m_navigationParams)
539  {
540  const double targetDist = seg_robot_mov.distance(
541  mrpt::math::TPoint2D(m_navigationParams->target.target_coords));
542 
543  // Should "End of navigation" event be sent??
544  if (!m_navigationParams->target.targetIsIntermediaryWaypoint &&
546  targetDist <
548  {
550  m_pending_events.push_back(std::bind(
552  std::ref(m_robot)));
553  }
554 
555  // Have we really reached the target?
556  if (checkHasReachedTarget(targetDist))
557  {
559  logFmt(
561  "Navigation target (%.03f,%.03f) was reached\n",
562  m_navigationParams->target.target_coords.x,
563  m_navigationParams->target.target_coords.y);
564 
565  if (!m_navigationParams->target.targetIsIntermediaryWaypoint)
566  {
567  this->stop(false /*not emergency*/);
569  {
571  m_pending_events.push_back(std::bind(
573  std::ref(m_robot)));
574  }
575  }
576  return;
577  }
578 
579  // Check the "no approaching the target"-alarm:
580  // -----------------------------------------------------------
581  if (targetDist < m_badNavAlarm_minDistTarget)
582  {
583  m_badNavAlarm_minDistTarget = targetDist;
585  }
586  else
587  {
588  // Too much time have passed?
593  .alarm_seems_not_approaching_target_timeout)
594  {
596  "Timeout approaching the target. Aborting navigation.");
597 
599 
600  m_pending_events.push_back(std::bind(
602  std::ref(m_robot)));
603  return;
604  }
605  }
606 
607  // Check if the target seems to be at reach, but it's clearly
608  // occupied by obstacles:
609  if (targetDist <
611  {
612  const auto rel_trg = m_navigationParams->target.target_coords -
614  const bool is_col = checkCollisionWithLatestObstacles(rel_trg);
615  if (is_col)
616  {
617  const bool send_event =
621 
622  if (send_event)
623  {
625  5.0,
626  "Target seems to be blocked by obstacles. Invoking"
627  " sendCannotGetCloserToBlockedTargetEvent().");
628 
629  m_pending_events.push_back(std::bind(
631  sendCannotGetCloserToBlockedTargetEvent,
632  std::ref(m_robot)));
633 
635  }
636  }
637  else
638  {
640  }
641  }
642  }
643 
644  // The normal execution of the navigation: Execute one step:
645  if (call_virtual_nav_method)
646  {
648  }
649  }
650  catch (std::exception& e)
651  {
653  "[CAbstractNavigator::navigationStep] Exception:\n %s", e.what());
654  }
655  catch (...)
656  {
658  "[CAbstractNavigator::navigationStep] Untyped exception!");
659  }
660  m_navigationState = prevState;
661 }
662 
664  const mrpt::math::TPose2D& relative_robot_pose) const
665 {
666  // Default impl:
667  return false;
668 }
mrpt::nav::CAbstractNavigator::m_navigationState
TState m_navigationState
Current internal state of navigator:
Definition: CAbstractNavigator.h:305
mrpt::nav::CAbstractNavigator::changeSpeeds
virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd)
Default: forward call to m_robot.changeSpeed().
Definition: CAbstractNavigator.cpp:412
mrpt::nav::CRobot2NavInterface::changeSpeeds
virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd)=0
Sends a velocity command to the robot.
mrpt::system::timeDifference
double 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.
Definition: datetime.cpp:209
mrpt::math::TTwist2D::rotate
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
Definition: lightweight_geom_data.cpp:117
mrpt::nav::CAbstractNavigator::onNavigateCommandReceived
virtual void onNavigateCommandReceived()
Called after each call to CAbstractNavigator::navigate()
Definition: CAbstractNavigator.cpp:273
nav-precomp.h
mrpt::poses::CPoseInterpolatorBase::size
size_t size() const
Definition: CPoseInterpolatorBase.h:109
mrpt::nav::CAbstractNavigator::TargetInfo::TargetInfo
TargetInfo()
Definition: CAbstractNavigator.cpp:24
mrpt::nav::CAbstractNavigator::TRobotPoseVel::timestamp
mrpt::system::TTimeStamp timestamp
Definition: CAbstractNavigator.h:325
mrpt::nav::CRobot2NavInterface::sendNavigationEndEvent
virtual void sendNavigationEndEvent()
Callback: End of navigation command (reach of single goal, or final waypoint of waypoint list)
Definition: CRobot2NavInterface.cpp:63
mrpt::nav::CAbstractNavigator::performNavigationStep
virtual void performNavigationStep()=0
To be implemented in derived classes.
mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::dist_to_target_for_sending_event
double dist_to_target_for_sending_event
Default value=0, means use the "targetAllowedDistance" passed by the user in the navigation request.
Definition: CAbstractNavigator.h:202
CConfigFileMemory.h
mrpt::nav::CAbstractNavigator::TargetInfo
Individual target info in CAbstractNavigator::TNavigationParamsBase and derived classes.
Definition: CAbstractNavigator.h:69
mrpt::nav::CAbstractNavigator::NAV_ERROR
@ NAV_ERROR
Definition: CAbstractNavigator.h:177
s
GLdouble s
Definition: glext.h:3676
MRPT_LOG_INFO
#define MRPT_LOG_INFO(_STRING)
Definition: system/COutputLogger.h:429
mrpt::nav::CAbstractNavigator::dispatchPendingNavEvents
void dispatchPendingNavEvents()
Definition: CAbstractNavigator.cpp:249
MRPT_SAVE_CONFIG_VAR_COMMENT
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
Definition: config/CConfigFileBase.h:459
mrpt::nav::CAbstractNavigator::checkHasReachedTarget
virtual bool checkHasReachedTarget(const double targetDist) const
Default implementation: check if target_dist is below the accepted distance.
Definition: CAbstractNavigator.cpp:479
mrpt::nav::CAbstractNavigator::TState
TState
The different states for the navigation system.
Definition: CAbstractNavigator.h:172
mrpt::system::COutputLogger::setVerbosityLevel
void setVerbosityLevel(const VerbosityLevel level)
alias of setMinLoggingLevel()
Definition: COutputLogger.cpp:138
mrpt::nav::CAbstractNavigator::m_last_curPoseVelUpdate_robot_time
double m_last_curPoseVelUpdate_robot_time
Definition: CAbstractNavigator.h:333
MRPT_LOG_DEBUG
#define MRPT_LOG_DEBUG(_STRING)
Use: MRPT_LOG_DEBUG("message");
Definition: system/COutputLogger.h:427
mrpt::nav::CAbstractNavigator::m_badNavAlarm_minDistTarget
double m_badNavAlarm_minDistTarget
For sending an alarm (error event) when it seems that we are not approaching toward the target in a w...
Definition: CAbstractNavigator.h:343
mrpt::math::TPose2D::phi
double phi
Orientation (rads)
Definition: lightweight_geom_data.h:195
mrpt::nav::CAbstractNavigator::TRobotPoseVel::pose_frame_id
std::string pose_frame_id
map frame ID for pose
Definition: CAbstractNavigator.h:327
mrpt::nav::CAbstractNavigator::m_pending_events
std::vector< std::function< void(void)> > m_pending_events
Events generated during navigationStep(), enqueued to be called at the end of the method execution to...
Definition: CAbstractNavigator.h:246
mrpt::nav::CAbstractNavigator::TRobotPoseVel::velLocal
mrpt::math::TTwist2D velLocal
Definition: CAbstractNavigator.h:321
mrpt::nav::CAbstractNavigator::internal_onStartNewNavigation
void internal_onStartNewNavigation()
Called before starting a new navigation.
Definition: CAbstractNavigator.cpp:485
mrpt::nav::CAbstractNavigator::navigationStep
virtual void navigationStep()
This method must be called periodically in order to effectively run the navigation.
Definition: CAbstractNavigator.cpp:182
mrpt::math::TSegment2D::distance
double distance(const TPoint2D &point) const
Distance to point.
Definition: lightweight_geom_data.cpp:503
mrpt::nav::CAbstractNavigator::setFrameTF
void setFrameTF(const std::weak_ptr< mrpt::poses::FrameTransformer< 2 >> &frame_tf)
Sets a user-provided frame transformer object; used only if providing targets in a frame ID different...
Definition: CAbstractNavigator.cpp:153
c
const GLubyte * c
Definition: glext.h:6313
mrpt::nav::CAbstractNavigator::m_navigationParams
std::unique_ptr< TNavigationParams > m_navigationParams
Current navigation parameters.
Definition: CAbstractNavigator.h:307
mrpt::nav::CRobot2NavInterface::startWatchdog
virtual bool startWatchdog(float T_ms)
Start the watchdog timer of the robot platform, if any, for maximum expected delay between consecutiv...
Definition: CRobot2NavInterface.cpp:37
INVALID_TIMESTAMP
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:15
mrpt::nav::CAbstractNavigator::updateCurrentPoseAndSpeeds
void updateCurrentPoseAndSpeeds()
Call to the robot getCurrentPoseAndSpeeds() and updates members m_curPoseVel accordingly.
Definition: CAbstractNavigator.cpp:323
mrpt::nav::CAbstractNavigator::processNavigateCommand
void processNavigateCommand(const TNavigationParams *params)
Does the job of navigate(), except the call to onNavigateCommandReceived()
Definition: CAbstractNavigator.cpp:281
mrpt::nav::CRobot2NavInterface::changeSpeedsNOP
virtual bool changeSpeedsNOP()
Just like changeSpeeds(), but will be called when the last velocity command is still the preferred so...
Definition: CRobot2NavInterface.cpp:21
mrpt::nav::CRobot2NavInterface::getNavigationTime
virtual double getNavigationTime()
Returns the number of seconds ellapsed since the constructor of this class was invoked,...
Definition: CRobot2NavInterface.cpp:119
mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::saveToConfigFile
virtual void saveToConfigFile(mrpt::config::CConfigFileBase &c, const std::string &s) const override
This method saves the options to a ".ini"-like file or memory-stored string list.
Definition: CAbstractNavigator.cpp:440
mrpt::nav
Definition: CAbstractHolonomicReactiveMethod.h:23
mrpt::nav::CAbstractNavigator::TargetInfo::targetAllowedDistance
float targetAllowedDistance
(Default=0.5 meters) Allowed distance to target in order to end the navigation.
Definition: CAbstractNavigator.h:79
mrpt::nav::CAbstractNavigator::TRobotPoseVel::TRobotPoseVel
TRobotPoseVel()
Definition: CAbstractNavigator.cpp:79
MRPT_LOG_THROTTLE_WARN
#define MRPT_LOG_THROTTLE_WARN(_PERIOD_SECONDS, _STRING)
Definition: system/COutputLogger.h:453
mrpt::poses::CPoseInterpolatorBase::erase
iterator erase(iterator element_to_erase)
Definition: CPoseInterpolatorBase.h:103
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::nav::CAbstractNavigator::m_navigationEndEventSent
bool m_navigationEndEventSent
Will be false until the navigation end is sent, and it is reset with each new command.
Definition: CAbstractNavigator.h:235
mrpt::nav::CRobot2NavInterface
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
Definition: CRobot2NavInterface.h:44
mrpt::nav::CAbstractNavigator::TargetInfo::targetIsRelative
bool targetIsRelative
(Default=false) Whether the target coordinates are in global coordinates (false) or are relative to t...
Definition: CAbstractNavigator.h:83
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
mrpt::nav::CAbstractNavigator::TRobotPoseVel::pose
mrpt::math::TPose2D pose
Definition: CAbstractNavigator.h:320
mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::TAbstractNavigatorParams
TAbstractNavigatorParams()
Definition: CAbstractNavigator.cpp:425
mrpt::poses::CPoseInterpolatorBase::setInterpolationMethod
void setInterpolationMethod(TInterpolatorMethod method)
Change the method used to interpolate the robot path.
Definition: CPoseInterpolatorBase.hpp:348
mrpt::nav::CAbstractNavigator::~CAbstractNavigator
virtual ~CAbstractNavigator()
dtor
Definition: CAbstractNavigator.cpp:111
mrpt::nav::CAbstractNavigator::TNavigationParams::isEqual
virtual bool isEqual(const TNavigationParamsBase &o) const override
Definition: CAbstractNavigator.cpp:72
mrpt::poses::CPoseInterpolatorBase::rbegin
reverse_iterator rbegin()
Definition: CPoseInterpolatorBase.h:81
lightweight_geom_data.h
mrpt::nav::CAbstractNavigator::params_abstract_navigator
TAbstractNavigatorParams params_abstract_navigator
Definition: CAbstractNavigator.h:221
mrpt::poses::CPoseInterpolatorBase::insert
void insert(mrpt::system::TTimeStamp t, const pose_t &p)
Inserts a new pose in the sequence.
Definition: CPoseInterpolatorBase.hpp:41
mrpt::nav::CAbstractNavigator::onStartNewNavigation
virtual void onStartNewNavigation()=0
Called whenever a new navigation has been started.
mrpt::nav::CAbstractNavigator::loadConfigFile
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c)
Loads all params from a file.
Definition: CAbstractNavigator.cpp:159
mrpt::nav::CRobot2NavInterface::stopWatchdog
virtual bool stopWatchdog()
Stop the watchdog timer.
Definition: CRobot2NavInterface.cpp:47
mrpt::nav::CAbstractNavigator::TNavigationParams
The struct for configuring navigation requests.
Definition: CAbstractNavigator.h:118
mrpt::system::COutputLogger::logFmt
void logFmt(const VerbosityLevel level, const char *fmt,...) const MRPT_printf_format_check(3
Alternative logging method, which mimics the printf behavior.
Definition: COutputLogger.cpp:80
mrpt::nav::operator==
bool operator==(const CAbstractNavigator::TNavigationParamsBase &, const CAbstractNavigator::TNavigationParamsBase &)
Definition: CAbstractNavigator.cpp:471
mrpt::nav::CAbstractNavigator::m_lastNavigationState
TState m_lastNavigationState
Last internal state of navigator:
Definition: CAbstractNavigator.h:232
mrpt::nav::CAbstractNavigator::performNavigationStepNavigating
virtual void performNavigationStepNavigating(bool call_virtual_nav_method=true)
Factorization of the part inside navigationStep(), for the case of state being NAVIGATING.
Definition: CAbstractNavigator.cpp:494
mrpt::nav::CAbstractNavigator::TargetInfo::targetDesiredRelSpeed
double targetDesiredRelSpeed
(Default=.05) Desired relative speed (wrt maximum speed), in range [0,1], of the vehicle at target.
Definition: CAbstractNavigator.h:89
mrpt::nav::CAbstractNavigator::TargetInfo::target_frame_id
std::string target_frame_id
(Default="map") Frame ID in which target is given.
Definition: CAbstractNavigator.h:76
MRPT_LOAD_CONFIG_VAR_CS
#define MRPT_LOAD_CONFIG_VAR_CS(variableName, variableType)
Shortcut for MRPT_LOAD_CONFIG_VAR() for config file object named c and section string named s
Definition: config/CConfigFileBase.h:291
mrpt::nav::CAbstractNavigator::TRobotPoseVel::rawOdometry
mrpt::math::TPose2D rawOdometry
raw odometry (frame does not match to "pose", but is expected to be smoother in the short term).
Definition: CAbstractNavigator.h:324
MRPT_START
#define MRPT_START
Definition: exceptions.h:262
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::nav::CAbstractNavigator::doEmergencyStop
void doEmergencyStop(const std::string &msg)
Stops the robot and set navigation state to error.
Definition: CAbstractNavigator.cpp:260
mrpt::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
mrpt::nav::CRobot2NavInterface::sendWaySeemsBlockedEvent
virtual void sendWaySeemsBlockedEvent()
Callback: No progression made towards target for a predefined period of time.
Definition: CRobot2NavInterface.cpp:94
MRPT_LOG_ERROR_FMT
#define MRPT_LOG_ERROR_FMT(_FMT_STRING,...)
Definition: system/COutputLogger.h:467
MRPT_LOG_ERROR
#define MRPT_LOG_ERROR(_STRING)
Definition: system/COutputLogger.h:433
mrpt::poses::imLinear2Neig
@ imLinear2Neig
Definition: CPoseInterpolatorBase.h:40
mrpt::nav::CAbstractNavigator::TargetInfo::target_coords
mrpt::math::TPose2D target_coords
Coordinates of desired target location.
Definition: CAbstractNavigator.h:73
b
GLubyte GLubyte b
Definition: glext.h:6279
mrpt::nav::CAbstractNavigator::m_latestOdomPoses
mrpt::poses::CPose2DInterpolator m_latestOdomPoses
Definition: CAbstractNavigator.h:336
mrpt::nav::CAbstractNavigator::m_robot
CRobot2NavInterface & m_robot
The navigator-robot interface.
Definition: CAbstractNavigator.h:310
mrpt::poses::CPoseInterpolatorBase::clear
void clear()
Clears the current sequence of poses.
Definition: CPoseInterpolatorBase.hpp:30
mrpt::math::TPose2D
Lightweight 2D pose.
Definition: lightweight_geom_data.h:186
mrpt::nav::CAbstractNavigator::TNavigationParams::getAsText
virtual std::string getAsText() const override
Gets navigation params as a human-readable format.
Definition: CAbstractNavigator.cpp:64
mrpt::system::LVL_WARN
@ LVL_WARN
Definition: system/COutputLogger.h:32
mrpt::nav::CAbstractNavigator::TargetInfo::getAsText
std::string getAsText() const
Gets navigation params as a human-readable format.
Definition: CAbstractNavigator.cpp:35
mrpt::nav::CAbstractNavigator::stop
virtual bool stop(bool isEmergencyStop)
Default: forward call to m_robot.stop().
Definition: CAbstractNavigator.cpp:420
CAbstractNavigator.h
mrpt::math::TPoint2D
Lightweight 2D point.
Definition: lightweight_geom_data.h:42
mrpt::config::CConfigFileMemory::getContent
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
Definition: CConfigFileMemory.cpp:66
mrpt::math::TSegment2D
2D segment, consisting of two points.
Definition: lightweight_geom_data.h:958
mrpt::poses::FrameTransformer< 2 >
mrpt::nav::CAbstractNavigator::m_curPoseVel
TRobotPoseVel m_curPoseVel
Current robot pose (updated in CAbstractNavigator::navigationStep() )
Definition: CAbstractNavigator.h:332
mrpt::nav::CRobot2NavInterface::getCurrentPoseAndSpeeds
virtual bool getCurrentPoseAndSpeeds(mrpt::math::TPose2D &curPose, mrpt::math::TTwist2D &curVelGlobal, mrpt::system::TTimeStamp &timestamp, mrpt::math::TPose2D &curOdometry, std::string &frame_id)=0
Get the current pose and velocity of the robot.
mrpt::nav::CAbstractNavigator::NAVIGATING
@ NAVIGATING
Definition: CAbstractNavigator.h:175
MRPT_LOG_WARN
#define MRPT_LOG_WARN(_STRING)
Definition: system/COutputLogger.h:431
mrpt::nav::CAbstractNavigator::suspend
virtual void suspend()
Suspend current navegation.
Definition: CAbstractNavigator.cpp:131
mrpt::system::CTimeLoggerEntry
A safe way to call enter() and leave() of a mrpt::system::CTimeLogger upon construction and destructi...
Definition: system/CTimeLogger.h:151
mrpt::nav::CAbstractNavigator::resetNavError
virtual void resetNavError()
Resets a NAV_ERROR state back to IDLE
Definition: CAbstractNavigator.cpp:145
mrpt::nav::CAbstractNavigator::changeSpeedsNOP
virtual bool changeSpeedsNOP()
Default: forward call to m_robot.changeSpeedsNOP().
Definition: CAbstractNavigator.cpp:418
mrpt::system::LVL_DEBUG
@ LVL_DEBUG
Definition: system/COutputLogger.h:30
mrpt::nav::CRobot2NavInterface::stop
virtual bool stop(bool isEmergencyStop=true)=0
Stop the robot right now.
mrpt::system::getCurrentTime
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
Definition: datetime.cpp:74
mrpt::poses::CPoseInterpolatorBase::begin
iterator begin()
Definition: CPoseInterpolatorBase.h:75
mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::hysteresis_check_target_is_blocked
int hysteresis_check_target_is_blocked
(Default=3) How many steps should the condition for dist_check_target_is_blocked be fulfilled to rais...
Definition: CAbstractNavigator.h:210
mrpt::nav::CAbstractNavigator::SUSPENDED
@ SUSPENDED
Definition: CAbstractNavigator.h:176
mrpt::nav::CAbstractNavigator::checkCollisionWithLatestObstacles
virtual bool checkCollisionWithLatestObstacles(const mrpt::math::TPose2D &relative_robot_pose) const
Checks whether the robot shape, when placed at the given pose (relative to the current pose),...
Definition: CAbstractNavigator.cpp:663
mrpt::poses::CPoseInterpolatorBase::empty
bool empty() const
Definition: CPoseInterpolatorBase.h:110
mrpt::nav::CAbstractNavigator::m_frame_tf
std::weak_ptr< mrpt::poses::FrameTransformer< 2 > > m_frame_tf
Optional, user-provided frame transformer.
Definition: CAbstractNavigator.h:313
MRPT_LOG_THROTTLE_DEBUG_FMT
#define MRPT_LOG_THROTTLE_DEBUG_FMT(_PERIOD_SECONDS, _FMT_STRING,...)
Usage: MRPT_LOG_THROTTLE_DEBUG_FMT(5.0, "i=%u", i);
Definition: system/COutputLogger.h:496
mrpt::nav::CAbstractNavigator::m_last_curPoseVelUpdate_pose_frame_id
std::string m_last_curPoseVelUpdate_pose_frame_id
Definition: CAbstractNavigator.h:334
mrpt::nav::CAbstractNavigator::cancel
virtual void cancel()
Cancel current navegation.
Definition: CAbstractNavigator.cpp:113
MRPT_END
#define MRPT_END
Definition: exceptions.h:266
mrpt::nav::CRobot2NavInterface::sendNavigationStartEvent
virtual void sendNavigationStartEvent()
Callback: Start of navigation command.
Definition: CRobot2NavInterface.cpp:56
mrpt::nav::CAbstractNavigator::CAbstractNavigator
CAbstractNavigator(CRobot2NavInterface &robot_interface_impl)
ctor
Definition: CAbstractNavigator.cpp:92
mrpt::nav::CAbstractNavigator::navigate
virtual void navigate(const TNavigationParams *params)
Navigation request to a single target location.
Definition: CAbstractNavigator.cpp:314
mrpt::nav::CAbstractNavigator::IDLE
@ IDLE
Definition: CAbstractNavigator.h:174
mrpt::nav::CAbstractNavigator::m_counter_check_target_is_blocked
int m_counter_check_target_is_blocked
Definition: CAbstractNavigator.h:236
ref
GLenum GLint ref
Definition: glext.h:4050
mrpt::nav::CAbstractNavigator::m_timlog_delays
mrpt::system::CTimeLogger m_timlog_delays
Time logger to collect delay-related stats.
Definition: CAbstractNavigator.h:339
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::nav::CAbstractNavigator::TargetInfo::operator==
bool operator==(const TargetInfo &o) const
Definition: CAbstractNavigator.cpp:52
mrpt::config::CConfigFileMemory
This class implements a config file-like interface over a memory-stored string list.
Definition: config/CConfigFileMemory.h:30
mrpt::nav::CAbstractNavigator::TRobotPoseVel::velGlobal
mrpt::math::TTwist2D velGlobal
Definition: CAbstractNavigator.h:321
mrpt::nav::CRobot2NavInterface::sendNavigationEndDueToErrorEvent
virtual void sendNavigationEndDueToErrorEvent()
Callback: Error asking sensory data from robot or sending motor commands.
Definition: CRobot2NavInterface.cpp:86
mrpt::kinematics::CVehicleVelCmd
Virtual base for velocity commands of different kinematic models of planar mobile robot.
Definition: CVehicleVelCmd.h:22
mrpt::nav::CAbstractNavigator::TargetInfo::targetIsIntermediaryWaypoint
bool targetIsIntermediaryWaypoint
Definition: CAbstractNavigator.h:90
mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::dist_check_target_is_blocked
double dist_check_target_is_blocked
(Default value=0.6) When closer than this distance, check if the target is blocked to abort navigatio...
Definition: CAbstractNavigator.h:207
mrpt::nav::CAbstractNavigator::saveConfigFile
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const
Saves all current options to a config file.
Definition: CAbstractNavigator.cpp:176
mrpt::nav::CAbstractNavigator::m_latestPoses
mrpt::poses::CPose2DInterpolator m_latestPoses
Latest robot poses (updated in CAbstractNavigator::navigationStep() )
Definition: CAbstractNavigator.h:336
mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::loadFromConfigFile
virtual void loadFromConfigFile(const mrpt::config::CConfigFileBase &c, const std::string &s) override
This method load the options from a ".ini"-like file or memory-stored string list.
Definition: CAbstractNavigator.cpp:432
mrpt::system::COutputLogger::COutputLogger
COutputLogger()
Default class constructor.
Definition: COutputLogger.cpp:59
mrpt::nav::CAbstractNavigator::m_badNavAlarm_lastMinDistTime
mrpt::system::TTimeStamp m_badNavAlarm_lastMinDistTime
Definition: CAbstractNavigator.h:344
mrpt::nav::CAbstractNavigator::TNavigationParamsBase
Base for all high-level navigation commands.
Definition: CAbstractNavigator.h:104
params
GLenum const GLfloat * params
Definition: glext.h:3534
a
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
mrpt::nav::CAbstractNavigator::m_nav_cs
std::recursive_mutex m_nav_cs
mutex for all navigation methods
Definition: CAbstractNavigator.h:316
mrpt::nav::CAbstractNavigator::resume
virtual void resume()
Continues with suspended navigation.
Definition: CAbstractNavigator.cpp:122
PREVIOUS_POSES_MAX_AGE
const double PREVIOUS_POSES_MAX_AGE
Definition: CAbstractNavigator.cpp:21



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST