Main MRPT website > C++ reference for MRPT 1.5.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-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 
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("target_coords = (%.03f,%.03f,%.03f deg)\n", target_coords.x, target_coords.y, target_coords.phi);
39  s += mrpt::format("target_frame_id = \"%s\"\n", target_frame_id.c_str());
40  s += mrpt::format("targetAllowedDistance = %.03f\n", targetAllowedDistance);
41  s += mrpt::format("targetIsRelative = %s\n", targetIsRelative ? "YES" : "NO");
42  s += mrpt::format("targetIsIntermediaryWaypoint = %s\n", targetIsIntermediaryWaypoint ? "YES" : "NO");
43  s += mrpt::format("targetDesiredRelSpeed = %.02f\n", targetDesiredRelSpeed);
44  return s;
45 }
46 
48 {
49  return target_coords == o.target_coords &&
50  target_frame_id == o.target_frame_id &&
51  targetAllowedDistance == o.targetAllowedDistance &&
52  targetIsRelative == o.targetIsRelative &&
53  targetDesiredRelSpeed == o.targetDesiredRelSpeed &&
54  targetIsIntermediaryWaypoint == o.targetIsIntermediaryWaypoint
55  ;
56 }
57 
58 // Gets navigation params as a human-readable format:
60 {
61  string s;
62  s+= "navparams. Single target:\n";
63  s+= target.getAsText();
64  return s;
65 }
66 
68 {
69  auto * rhs = dynamic_cast<const CAbstractNavigator::TNavigationParams *>(&o);
70  return (rhs != nullptr) && (this->target == rhs->target);
71 }
72 
74  pose(0,0,0),
75  velGlobal(0,0,0),
76  velLocal(0,0,0),
77  rawOdometry(0,0,0),
78  timestamp(INVALID_TIMESTAMP),
79  pose_frame_id()
80 {
81 }
82 
83 /*---------------------------------------------------------------
84  Constructor
85  ---------------------------------------------------------------*/
87  mrpt::utils::COutputLogger("MRPT_navigator"),
91  m_rethrow_exceptions(false),
93  m_navigationParams ( nullptr ),
94  m_robot ( react_iterf_impl ),
95  m_frame_tf (nullptr),
96  m_curPoseVel (),
98  m_latestPoses (),
100  m_timlog_delays (true, "CAbstractNavigator::m_timlog_delays"),
101  m_navProfiler (false,"mrpt::nav::CAbstractNavigator")
102 {
105  this->setVerbosityLevel(mrpt::utils::LVL_DEBUG);
106 }
107 
108 // Dtor:
110 {
112 }
113 
114 /*---------------------------------------------------------------
115  cancel
116  ---------------------------------------------------------------*/
118 {
120  MRPT_LOG_DEBUG("CAbstractNavigator::cancel() called.");
122  this->stop(false /*not emergency*/);
123 }
124 
125 
126 /*---------------------------------------------------------------
127  resume
128  ---------------------------------------------------------------*/
130 {
132 
133  MRPT_LOG_DEBUG("[CAbstractNavigator::resume() called.");
134  if ( m_navigationState == SUSPENDED )
136 }
137 
138 
139 /*---------------------------------------------------------------
140  suspend
141  ---------------------------------------------------------------*/
143 {
145 
146  // Issue an "stop" if we are moving:
147  // Update: do it *always*, even if the current velocity is zero, since
148  // we may be in the middle of a multi-part motion command. It's safer.
149  this->stop(false /*not an emergency stop*/);
150 
151  MRPT_LOG_DEBUG("CAbstractNavigator::suspend() called.");
152  if ( m_navigationState == NAVIGATING )
154 }
155 
157 {
159 
160  MRPT_LOG_DEBUG("CAbstractNavigator::resetNavError() called.");
161  if ( m_navigationState == NAV_ERROR )
162  {
165  }
166 }
167 
169 {
170  m_frame_tf = frame_tf;
171 }
172 
174 {
175  MRPT_START
176 
177  params_abstract_navigator.loadFromConfigFile(c, "CAbstractNavigator");
178 
179  m_navProfiler.enable(c.read_bool(
180  "CAbstractNavigator", "enable_time_profiler",
182 
183  // At this point, all derived classes have already loaded their parameters.
184  // Dump them to debug output:
185  {
187  this->saveConfigFile(cfg_mem);
188  MRPT_LOG_INFO(cfg_mem.getContent());
189  }
190 
191  MRPT_END
192 }
193 
195 {
196  params_abstract_navigator.saveToConfigFile(c, "CAbstractNavigator");
197 }
198 
199 /*---------------------------------------------------------------
200  navigationStep
201  ---------------------------------------------------------------*/
203 {
205  mrpt::utils::CTimeLoggerEntry tle(m_navProfiler, "CAbstractNavigator::navigationStep()");
206 
207  const TState prevState = m_navigationState;
208  switch ( m_navigationState )
209  {
210  case IDLE:
211  case SUSPENDED:
212  try
213  {
214  // If we just arrived at this state, stop robot:
216  {
217  MRPT_LOG_INFO("[CAbstractNavigator::navigationStep()] Navigation stopped.");
218  // this->stop(); stop() is called by the method switching the "state", so we have more flexibility
220  }
221  } catch (...) { }
222  break;
223 
224  case NAV_ERROR:
225  try
226  {
227  // Send end-of-navigation event:
229  {
230  TPendingEvent ev;
232  m_pending_events.push_back(ev);
233  }
234 
235  // If we just arrived at this state, stop the robot:
237  {
238  MRPT_LOG_ERROR("[CAbstractNavigator::navigationStep()] Stoping Navigation due to a NAV_ERROR state!");
239  this->stop(false /*not emergency*/);
241  }
242  } catch (...) { }
243  break;
244 
245  case NAVIGATING:
246  this->performNavigationStepNavigating(true /* do call virtual method nav implementation*/);
247  break; // End case NAVIGATING
248  };
249  m_lastNavigationState = prevState;
250 
252 }
253 
255 {
256  // Invoke pending events:
257  for (auto &ev : m_pending_events)
258  {
259  if (ev.event_noargs != nullptr) {
260  (m_robot.*(ev.event_noargs))();
261  }
262  else if (ev.event_wp_reached) {
263  m_robot.sendWaypointReachedEvent(ev.event_wp_reached_index, ev.event_wp_reached_reached);
264  }
265  else if (ev.event_new_wp) {
266  m_robot.sendNewWaypointTargetEvent(ev.event_new_wp_index);
267  }
268  else if (ev.event_cannot_get_closer_target) {
269  bool do_abort_nav;
271 
272  if (do_abort_nav)
273  {
274  MRPT_LOG_WARN("sendCannotGetCloserToBlockedTargetEvent() told me to abort navigation.");
277  m_navErrorReason.error_msg = "sendCannotGetCloserToBlockedTargetEvent() told me to abort navigation";
278 
279 
280  TPendingEvent ev;
282  m_pending_events.push_back(ev);
283  }
284  }
285  } // end for each pending event
286  m_pending_events.clear();
287 }
288 
290 {
291  try {
292  this->stop(true /* emergency*/);
293  }
294  catch (...) { }
296  // don't overwrite an error msg from a caller:
298  {
300  m_navErrorReason.error_msg = std::string("doEmergencyStop called for: ") + msg;
301  }
302  MRPT_LOG_ERROR(msg);
303 }
304 
305 
307 {
309 
310  m_navigationEndEventSent = false;
312 }
313 
315 {
316  MRPT_START;
318 
319  ASSERT_(params != nullptr);
320  ASSERT_(params->target.targetDesiredRelSpeed >= .0 && params->target.targetDesiredRelSpeed <= 1.0);
321 
322  // Copy data:
325  ASSERT_(m_navigationParams != nullptr);
326 
327  // Transform: relative -> absolute, if needed.
329  {
332  m_navigationParams->target.targetIsRelative = false; // Now it's not relative
333  }
334 
335  // new state:
338 
339  // Reset the bad navigation alarm:
340  m_badNavAlarm_minDistTarget = std::numeric_limits<double>::max();
342 
343  MRPT_END;
344 }
345 
347 {
348  MRPT_START;
350  this->processNavigateCommand(params);
351  MRPT_END;
352 }
353 
355 {
356  // Ignore calls too-close in time, e.g. from the navigationStep() methods of
357  // AbstractNavigator and a derived, overriding class.
358  const double robot_time_secs = m_robot.getNavigationTime(); // this is clockwall time for real robots, simulated time in simulators.
359 
360  const double MIN_TIME_BETWEEN_POSE_UPDATES = 20e-3;
362  {
363  const double last_call_age = robot_time_secs - m_last_curPoseVelUpdate_robot_time;
364  if (last_call_age < MIN_TIME_BETWEEN_POSE_UPDATES)
365  {
366  MRPT_LOG_THROTTLE_DEBUG_FMT(5.0,"updateCurrentPoseAndSpeeds: ignoring call, since last call was only %f ms ago.", last_call_age*1e3);
367  return; // previous data is still valid: don't query the robot again
368  }
369  }
370 
371  {
372  mrpt::utils::CTimeLoggerEntry tle(m_navProfiler, "getCurrentPoseAndSpeeds()");
373  m_curPoseVel.pose_frame_id = std::string("map"); // default
375  {
378  m_navErrorReason.error_msg = std::string("ERROR calling m_robot.getCurrentPoseAndSpeeds, stopping robot and finishing navigation");
379  try {
380  this->stop(true /*emergency*/);
381  }
382  catch (...) {}
383  MRPT_LOG_ERROR("ERROR calling m_robot.getCurrentPoseAndSpeeds, stopping robot and finishing navigation");
384  throw std::runtime_error("ERROR calling m_robot.getCurrentPoseAndSpeeds, stopping robot and finishing navigation");
385  }
386  }
389 
390  m_last_curPoseVelUpdate_robot_time = robot_time_secs;
391  const bool changed_frame_id = (m_last_curPoseVelUpdate_pose_frame_id != m_curPoseVel.pose_frame_id);
393 
394  if (changed_frame_id)
395  {
396  // If frame changed, clear past poses. This could be improved by requesting
397  // the transf between the two frames, but it's probably not worth.
400  }
401 
402  // Append to list of past poses:
405 
406  // Purge old ones:
407  while (m_latestPoses.size() > 1 &&
409  {
411  }
412  while (m_latestOdomPoses.size() > 1 &&
414  {
416  }
417 }
418 
420 {
421  return m_robot.changeSpeeds(vel_cmd);
422 }
424 {
425  return m_robot.changeSpeedsNOP();
426 }
427 bool CAbstractNavigator::stop(bool isEmergencyStop)
428 {
429  return m_robot.stop(isEmergencyStop);
430 }
431 
433  dist_to_target_for_sending_event(0),
434  alarm_seems_not_approaching_target_timeout(30),
435  dist_check_target_is_blocked(0.6),
436  hysteresis_check_target_is_blocked(3)
437 {
438 }
440 {
441  MRPT_LOAD_CONFIG_VAR_CS(dist_to_target_for_sending_event, double);
442  MRPT_LOAD_CONFIG_VAR_CS(alarm_seems_not_approaching_target_timeout, double);
443  MRPT_LOAD_CONFIG_VAR_CS(dist_check_target_is_blocked, double);
444  MRPT_LOAD_CONFIG_VAR_CS(hysteresis_check_target_is_blocked, int);
445 }
447 {
448  MRPT_SAVE_CONFIG_VAR_COMMENT(dist_to_target_for_sending_event, "Default value=0, means use the `targetAllowedDistance` passed by the user in the navigation request.");
449  MRPT_SAVE_CONFIG_VAR_COMMENT(alarm_seems_not_approaching_target_timeout, "navigator timeout (seconds) [Default=30 sec]");
450  MRPT_SAVE_CONFIG_VAR_COMMENT(dist_check_target_is_blocked, "When closer than this distance, check if the target is blocked to abort navigation with an error. [Default=0.6 m]");
451  MRPT_SAVE_CONFIG_VAR_COMMENT(hysteresis_check_target_is_blocked, "How many steps should the condition for dist_check_target_is_blocked be fulfilled to raise an event");
452 }
453 
455 {
456  return typeid(a) == typeid(b) && a.isEqual(b);
457 }
458 
459 bool CAbstractNavigator::checkHasReachedTarget(const double targetDist) const
460 {
461  return (targetDist < m_navigationParams->target.targetAllowedDistance);
462 }
463 
465 {
466  m_robot.startWatchdog(1000); // Watchdog = 1 seg
467  m_latestPoses.clear(); // Clear cache of last poses.
470 }
471 
472 void CAbstractNavigator::performNavigationStepNavigating(bool call_virtual_nav_method)
473 {
474  const TState prevState = m_navigationState;
475  try
476  {
478  {
479  MRPT_LOG_INFO("[CAbstractNavigator::navigationStep()] Starting Navigation. Watchdog initiated...\n");
480  if (m_navigationParams)
481  MRPT_LOG_DEBUG(mrpt::format("[CAbstractNavigator::navigationStep()] Navigation Params:\n%s\n", m_navigationParams->getAsText().c_str()));
482 
484  }
485 
486  // Have we just started the navigation?
488  {
489  TPendingEvent ev;
491  m_pending_events.push_back(ev);
492  }
493 
494  /* ----------------------------------------------------------------
495  Get current robot dyn state:
496  ---------------------------------------------------------------- */
498 
499  /* ----------------------------------------------------------------
500  Have we reached the target location?
501  ---------------------------------------------------------------- */
502  // Build a 2D segment from the current robot pose to the previous one:
504  const mrpt::math::TSegment2D seg_robot_mov = mrpt::math::TSegment2D(
506  m_latestPoses.size() > 1 ?
508  :
510  );
511 
512  if (m_navigationParams)
513  {
514  const double targetDist = seg_robot_mov.distance(mrpt::math::TPoint2D(m_navigationParams->target.target_coords));
515 
516  // Should "End of navigation" event be sent??
518  {
520  TPendingEvent ev;
522  m_pending_events.push_back(ev);
523  MRPT_LOG_DEBUG("[CAbstractNavigator::performNavigationStepNavigating] Enqueuing NavigationEndEvent (reason: targetDist<dist_to_target_for_sending_event).");
524  }
525 
526  // Have we really reached the target?
527  if (checkHasReachedTarget(targetDist))
528  {
530  logFmt(mrpt::utils::LVL_WARN, "Navigation target (%.03f,%.03f) was reached\n", m_navigationParams->target.target_coords.x, m_navigationParams->target.target_coords.y);
531 
533  {
534  this->stop(false /*not emergency*/);
536  {
538  TPendingEvent ev;
540  m_pending_events.push_back(ev);
541  MRPT_LOG_DEBUG("[CAbstractNavigator::performNavigationStepNavigating] Enqueuing NavigationEndEvent (reason: checkHasReachedTarget()=true).");
542  }
543  }
544  return;
545  }
546 
547  // Check the "no approaching the target"-alarm:
548  // -----------------------------------------------------------
549  if (targetDist < m_badNavAlarm_minDistTarget)
550  {
551  m_badNavAlarm_minDistTarget = targetDist;
553  }
554  else
555  {
556  // Too much time have passed?
558  {
559  MRPT_LOG_WARN("Timeout approaching the target. Aborting navigation.");
560 
563  m_navErrorReason.error_msg = std::string("Timeout approaching the target. Aborting navigation.");
564 
565  TPendingEvent ev;
567  m_pending_events.push_back(ev);
568  return;
569  }
570  }
571 
572  // Check if the target seems to be at reach, but it's clearly occupied by obstacles:
574  {
575  const auto rel_trg = m_navigationParams->target.target_coords - m_curPoseVel.pose;
576  const bool is_col = checkCollisionWithLatestObstacles(rel_trg);
577  if (is_col)
578  {
580 
581  if (send_event)
582  {
583  MRPT_LOG_THROTTLE_WARN(5.0,"Target seems to be blocked by obstacles. Invoking sendCannotGetCloserToBlockedTargetEvent().");
584 
585  TPendingEvent ev;
587  m_pending_events.push_back(ev);
588 
590  }
591  }
592  else
593  {
595  }
596  }
597  }
598 
599  // The normal execution of the navigation: Execute one step:
600  if (call_virtual_nav_method) {
602  }
603  }
604  catch (std::exception &e)
605  {
608  {
610  m_navErrorReason.error_msg = std::string("Exception: ") + std::string(e.what());
611  }
612 
613  MRPT_LOG_ERROR_FMT("[CAbstractNavigator::navigationStep] Exception:\n %s",e.what());
614  if (m_rethrow_exceptions) throw;
615  }
616  catch (...)
617  {
620  {
622  m_navErrorReason.error_msg = "Untyped exception";
623  }
624 
625  MRPT_LOG_ERROR("[CAbstractNavigator::navigationStep] Untyped exception!");
626  if (m_rethrow_exceptions) throw;
627  }
628  m_navigationState = prevState;
629 }
630 
632 {
633  // Default impl:
634  return false;
635 }
636 
638  event_noargs(nullptr),
639  event_wp_reached(false),
640  event_new_wp(false),
641  event_cannot_get_closer_target(false)
642 {
643 }
double m_badNavAlarm_minDistTarget
For sending an alarm (error event) when it seems that we are not approaching toward the target in a w...
virtual bool stop(bool isEmergencyStop=true)=0
Stop the robot right now.
TRobotPoseVel m_curPoseVel
Current robot pose (updated in CAbstractNavigator::navigationStep() )
virtual bool startWatchdog(float T_ms)
Start the watchdog timer of the robot platform, if any, for maximum expected delay between consecutiv...
virtual void sendNewWaypointTargetEvent(int waypoint_index)
Callback: Heading towards a new intermediary/final waypoint in waypoint list navigation.
A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.
virtual void loadConfigFile(const mrpt::utils::CConfigFileBase &c)
Loads all params from a file.
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const
Saves all current options to a config file.
virtual bool stopWatchdog()
Stop the watchdog timer.
mrpt::poses::FrameTransformer< 2 > * m_frame_tf
Optional, user-provided frame transformer.
#define MRPT_LOG_THROTTLE_DEBUG_FMT(_PERIOD_SECONDS, _FMT_STRING,...)
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentTime()
Returns the current (UTC) system time.
Definition: datetime.cpp:71
TNavigationParams * m_navigationParams
Current navigation parameters.
void setFrameTF(mrpt::poses::FrameTransformer< 2 > *frame_tf)
Sets a user-provided frame transformer object; used only if providing targets in a frame ID different...
double distance(const TPoint2D &point) const
Distance to point.
Base for all high-level navigation commands.
float targetAllowedDistance
(Default=0.5 meters) Allowed distance to target in order to end the navigation.
#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 ...
virtual void sendNavigationEndEvent()
Callback: End of navigation command (reach of single goal, or final waypoint of waypoint list) ...
STL namespace.
virtual void updateCurrentPoseAndSpeeds()
Call to the robot getCurrentPoseAndSpeeds() and updates members m_curPoseVel accordingly.
functor_event_void_t event_noargs
event w/o arguments
bool targetIsRelative
(Default=false) Whether the target coordinates are in global coordinates (false) or are relative to t...
#define MRPT_LOG_ERROR_FMT(_FMT_STRING,...)
virtual double getNavigationTime()
Returns the number of seconds ellapsed since the constructor of this class was invoked, or since the last call of resetNavigationTimer().
double dist_check_target_is_blocked
(Default value=0.6) When closer than this distance, check if the target is blocked to abort navigatio...
GLdouble s
Definition: glext.h:3602
void setInterpolationMethod(TInterpolatorMethod method)
Change the method used to interpolate the robot path. The default method at construction is "imSpline...
virtual void navigationStep()
This method must be called periodically in order to effectively run the navigation.
std::string pose_frame_id
map frame ID for pose
mrpt::utils::CTimeLogger m_timlog_delays
Time logger to collect delay-related stats.
virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd)
Default: forward call to m_robot.changeSpeed(). Can be overriden.
void enable(bool enabled=true)
Definition: CTimeLogger.h:88
virtual bool changeSpeedsNOP()
Default: forward call to m_robot.changeSpeedsNOP(). Can be overriden.
This class allows loading and storing values and vectors of different types from a configuration text...
TState m_navigationState
Current internal state of navigator:
Virtual base for velocity commands of different kinematic models of planar mobile robot...
This class implements a config file-like interface over a memory-stored string list.
virtual void performNavigationStep()=0
To be implemented in derived classes.
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
bool NAV_IMPEXP operator==(const CAbstractNavigator::TNavigationParamsBase &, const CAbstractNavigator::TNavigationParamsBase &)
The struct for configuring navigation requests.
CAbstractNavigator(CRobot2NavInterface &robot_interface_impl)
ctor
virtual void sendCannotGetCloserToBlockedTargetEvent(bool &do_abort_nav)
Callback: Target seems to be blocked by an obstacle.
TState
The different states for the navigation system.
2D segment, consisting of two points.
void insert(mrpt::system::TTimeStamp t, const pose_t &p)
Inserts a new pose in the sequence.
double dist_to_target_for_sending_event
Default value=0, means use the "targetAllowedDistance" passed by the user in the navigation request...
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
double targetDesiredRelSpeed
(Default=.05) Desired relative speed (wrt maximum speed), in range [0,1], of the vehicle at target...
#define MRPT_END
virtual void onNavigateCommandReceived()
Called after each call to CAbstractNavigator::navigate()
virtual void sendNavigationStartEvent()
Callback: Start of navigation command.
#define MRPT_LOG_WARN(_STRING)
virtual void sendNavigationEndDueToErrorEvent()
Callback: Error asking sensory data from robot or sending motor commands.
std::string target_frame_id
(Default="map") Frame ID in which target is given. Optional, use only for submapping applications...
const GLubyte * c
Definition: glext.h:5590
#define MRPT_LOG_INFO(_STRING)
virtual void resetNavError()
Resets a NAV_ERROR state back to IDLE
#define MRPT_LOG_THROTTLE_WARN(_PERIOD_SECONDS, _STRING)
void internal_onStartNewNavigation()
Called before starting a new navigation.
GLubyte GLubyte b
Definition: glext.h:5575
Individual target info in CAbstractNavigator::TNavigationParamsBase and derived classes.
#define MRPT_LOG_DEBUG(_STRING)
bool isEnabled() const
Definition: CTimeLogger.h:90
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
virtual void onStartNewNavigation()=0
Called whenever a new navigation has been started.
GLsizei const GLchar ** string
Definition: glext.h:3919
virtual void sendWaySeemsBlockedEvent()
Callback: No progression made towards target for a predefined period of time.
virtual void resume()
Continues with suspended navigation.
mrpt::math::TPose2D target_coords
Coordinates of desired target location. Heading may be ignored by some reactive implementations.
TState m_lastNavigationState
Last internal state of navigator:
virtual std::string getAsText() const MRPT_OVERRIDE
Gets navigation params as a human-readable format.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:17
virtual void sendWaypointReachedEvent(int waypoint_index, bool reached_nSkipped)
Callback: Reached an intermediary waypoint in waypoint list navigation.
double alarm_seems_not_approaching_target_timeout
navigator timeout (seconds) [Default=30 sec]
std::list< TPendingEvent > m_pending_events
Events generated during navigationStep(), enqueued to be called at the end of the method execution to...
double y
X,Y coordinates.
const double PREVIOUS_POSES_MAX_AGE
#define MRPT_START
virtual bool isEqual(const TNavigationParamsBase &o) const MRPT_OVERRIDE
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual void performNavigationStepNavigating(bool call_virtual_nav_method=true)
Factorization of the part inside navigationStep(), for the case of state being NAVIGATING.
void delete_safe(T *&ptr)
Calls "delete" to free an object only if the pointer is not NULL, then set the pointer to NULL...
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.
virtual bool changeSpeedsNOP()
Just like changeSpeeds(), but will be called when the last velocity command is still the preferred so...
std::string getAsText() const
Gets navigation params as a human-readable format.
A safe way to call enter() and leave() of a mrpt::utils::CTimeLogger upon construction and destructio...
Definition: CTimeLogger.h:127
void clear()
Clears the current sequence of poses.
virtual void doEmergencyStop(const std::string &msg)
Stops the robot and set navigation state to error.
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &c, const std::string &s) MRPT_OVERRIDE
This method load the options from a ".ini"-like file or memory-stored string list.
virtual void processNavigateCommand(const TNavigationParams *params)
Does the job of navigate(), except the call to onNavigateCommandReceived()
mrpt::utils::CTimeLogger m_navProfiler
Publicly available time profiling object.
TAbstractNavigatorParams params_abstract_navigator
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &c, const std::string &s) const MRPT_OVERRIDE
This method saves the options to a ".ini"-like file or memory-stored string list. ...
CRobot2NavInterface & m_robot
The navigator-robot interface.
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)...
Lightweight 2D pose.
virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd)=0
Sends a velocity command to the robot.
#define ASSERT_(f)
In this case, use getErrorReason()
iterator erase(iterator element_to_erase)
virtual void cancel()
Cancel current navegation.
std::string error_msg
Human friendly description of the error.
bool operator==(const TargetInfo &o) const
virtual void suspend()
Suspend current navegation.
virtual TNavigationParams * clone() const
#define MRPT_LOG_ERROR(_STRING)
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...
Definition: datetime.cpp:205
virtual bool checkHasReachedTarget(const double targetDist) const
Default implementation: check if target_dist is below the accepted distance.
mrpt::synch::CCriticalSectionRecursive m_nav_cs
mutex for all navigation methods
mrpt::poses::CPose2DInterpolator m_latestOdomPoses
Latest robot poses (updated in CAbstractNavigator::navigationStep() )
bool m_navigationEndEventSent
Will be false until the navigation end is sent, and it is reset with each new command.
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
mrpt::system::TTimeStamp m_badNavAlarm_lastMinDistTime
Lightweight 2D point.
GLubyte GLubyte GLubyte a
Definition: glext.h:5575
GLenum const GLfloat * params
Definition: glext.h:3514
mrpt::poses::CPose2DInterpolator m_latestPoses
double phi
Orientation (rads)
mrpt::math::TPose2D rawOdometry
raw odometry (frame does not match to "pose", but is expected to be smoother in the short term)...
virtual bool stop(bool isEmergencyStop)
Default: forward call to m_robot.stop(). Can be overriden.
virtual void navigate(const TNavigationParams *params)
Navigation request to a single target location.



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020