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-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(
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::utils::COutputLogger("MRPT_navigator"),
98  m_robot(react_iterf_impl),
99  m_frame_tf(nullptr),
100  m_curPoseVel(),
102  m_latestPoses(),
104  m_timlog_delays(true, "CAbstractNavigator::m_timlog_delays")
105 {
108  this->setVerbosityLevel(mrpt::utils::LVL_DEBUG);
109 }
110 
111 // Dtor:
113 /** \callergraph */
115 {
116  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
117  MRPT_LOG_DEBUG("CAbstractNavigator::cancel() called.");
119  this->stop(false /*not emergency*/);
120 }
121 
122 /** \callergraph */
124 {
125  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
126 
127  MRPT_LOG_DEBUG("[CAbstractNavigator::resume() called.");
129 }
130 
131 /** \callergraph */
133 {
134  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
135 
136  // Issue an "stop" if we are moving:
137  // Update: do it *always*, even if the current velocity is zero, since
138  // we may be in the middle of a multi-part motion command. It's safer.
139  this->stop(false /*not an emergency stop*/);
140 
141  MRPT_LOG_DEBUG("CAbstractNavigator::suspend() called.");
143 }
144 
145 /** \callergraph */
147 {
148  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
149 
150  MRPT_LOG_DEBUG("CAbstractNavigator::resetNavError() called.");
152 }
153 
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(
219  std::bind(
221  sendNavigationEndDueToErrorEvent,
222  std::ref(m_robot)));
223  }
224 
225  // If we just arrived at this state, stop the robot:
227  {
229  "[CAbstractNavigator::navigationStep()] Stopping "
230  "Navigation due to a NAV_ERROR state!");
231  this->stop(false /*not emergency*/);
233  }
234  }
235  catch (...)
236  {
237  }
238  break;
239 
240  case NAVIGATING:
242  true /* do call virtual method nav implementation*/);
243  break; // End case NAVIGATING
244  };
245  m_lastNavigationState = prevState;
246 
248 }
249 
250 /** \callergraph */
252 {
253  // Invoke pending events:
254  for (auto& ev : m_pending_events)
255  {
256  ev();
257  }
258  m_pending_events.clear();
259 }
260 
261 /** \callergraph */
263 {
264  try
265  {
266  this->stop(true /* emergency*/);
267  }
268  catch (...)
269  {
270  }
272  MRPT_LOG_ERROR(msg);
273 }
274 
276 {
277  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
278 
279  m_navigationEndEventSent = false;
280  m_navigationParams.reset();
281 }
282 
284 {
285  MRPT_START;
286  std::lock_guard<std::recursive_mutex> csl(m_nav_cs);
287 
288  ASSERT_(params != nullptr);
289  ASSERT_(
290  params->target.targetDesiredRelSpeed >= .0 &&
291  params->target.targetDesiredRelSpeed <= 1.0);
292 
293  // Copy data:
294  m_navigationParams = params->clone();
295 
296  // Transform: relative -> absolute, if needed.
297  if (m_navigationParams->target.targetIsRelative)
298  {
300  m_navigationParams->target.target_coords =
301  m_curPoseVel.pose + m_navigationParams->target.target_coords;
302  m_navigationParams->target.targetIsRelative =
303  false; // Now it's not relative
304  }
305 
306  // new state:
308 
309  // Reset the bad navigation alarm:
310  m_badNavAlarm_minDistTarget = std::numeric_limits<double>::max();
312 
313  MRPT_END;
314 }
315 
318 {
319  MRPT_START;
321  this->processNavigateCommand(params);
322  MRPT_END;
323 }
324 
326 {
327  // Ignore calls too-close in time, e.g. from the navigationStep() methods of
328  // AbstractNavigator and a derived, overriding class.
329  const double robot_time_secs =
330  m_robot.getNavigationTime(); // this is clockwall time for real robots,
331  // simulated time in simulators.
332 
333  const double MIN_TIME_BETWEEN_POSE_UPDATES = 20e-3;
335  {
336  const double last_call_age =
337  robot_time_secs - m_last_curPoseVelUpdate_robot_time;
338  if (last_call_age < MIN_TIME_BETWEEN_POSE_UPDATES)
339  {
341  5.0,
342  "updateCurrentPoseAndSpeeds: ignoring call, since last call "
343  "was only %f ms ago.",
344  last_call_age * 1e3);
345  return; // previous data is still valid: don't query the robot
346  // again
347  }
348  }
349 
350  {
352  m_timlog_delays, "getCurrentPoseAndSpeeds()");
353  m_curPoseVel.pose_frame_id = std::string("map"); // default
358  {
360  try
361  {
362  this->stop(true /*emergency*/);
363  }
364  catch (...)
365  {
366  }
368  "ERROR calling m_robot.getCurrentPoseAndSpeeds, stopping robot "
369  "and finishing navigation");
370  throw std::runtime_error(
371  "ERROR calling m_robot.getCurrentPoseAndSpeeds, stopping robot "
372  "and finishing navigation");
373  }
374  }
377 
378  m_last_curPoseVelUpdate_robot_time = robot_time_secs;
379  const bool changed_frame_id =
382 
383  if (changed_frame_id)
384  {
385  // If frame changed, clear past poses. This could be improved by
386  // requesting
387  // the transf between the two frames, but it's probably not worth.
390  }
391 
392  // Append to list of past poses:
395 
396  // Purge old ones:
397  while (m_latestPoses.size() > 1 &&
399  m_latestPoses.begin()->first, m_latestPoses.rbegin()->first) >
401  {
403  }
404  while (m_latestOdomPoses.size() > 1 &&
406  m_latestOdomPoses.begin()->first,
408  {
410  }
411 }
412 
413 /** \callergraph */
415  const mrpt::kinematics::CVehicleVelCmd& vel_cmd)
416 {
417  return m_robot.changeSpeeds(vel_cmd);
418 }
419 /** \callergraph */
421 /** \callergraph */
422 bool CAbstractNavigator::stop(bool isEmergencyStop)
423 {
424  return m_robot.stop(isEmergencyStop);
425 }
426 
428  : dist_to_target_for_sending_event(0),
429  alarm_seems_not_approaching_target_timeout(30),
430  dist_check_target_is_blocked(0.6),
431  hysteresis_check_target_is_blocked(3)
432 {
433 }
436 {
437  MRPT_LOAD_CONFIG_VAR_CS(dist_to_target_for_sending_event, double);
438  MRPT_LOAD_CONFIG_VAR_CS(alarm_seems_not_approaching_target_timeout, double);
439  MRPT_LOAD_CONFIG_VAR_CS(dist_check_target_is_blocked, double);
440  MRPT_LOAD_CONFIG_VAR_CS(hysteresis_check_target_is_blocked, int);
441 }
444 {
446  dist_to_target_for_sending_event,
447  "Default value=0, means use the `targetAllowedDistance` passed by the "
448  "user in the navigation request.");
450  alarm_seems_not_approaching_target_timeout,
451  "navigator timeout (seconds) [Default=30 sec]");
453  dist_check_target_is_blocked,
454  "When closer than this distance, check if the target is blocked to "
455  "abort navigation with an error. [Default=0.6 m]");
457  dist_to_target_for_sending_event,
458  "Default value=0, means use the `targetAllowedDistance` passed by the"
459  " user in the navigation request.");
461  alarm_seems_not_approaching_target_timeout,
462  "navigator timeout (seconds) [Default=30 sec]");
464  dist_check_target_is_blocked,
465  "When closer than this distance, check if the target is blocked to "
466  "abort navigation with an error. [Default=0.6 m]");
468  hysteresis_check_target_is_blocked,
469  "How many steps should the condition for dist_check_target_is_blocked "
470  "be fulfilled to raise an event");
471 }
472 
476 {
477  return typeid(a) == typeid(b) && a.isEqual(b);
478 }
479 
480 /** \callergraph */
481 bool CAbstractNavigator::checkHasReachedTarget(const double targetDist) const
482 {
483  return (targetDist < m_navigationParams->target.targetAllowedDistance);
484 }
485 
486 /** \callergraph */
488 {
489  m_robot.startWatchdog(1000); // Watchdog = 1 seg
490  m_latestPoses.clear(); // Clear cache of last poses.
493 }
494 
495 /** \callergraph */
497  bool call_virtual_nav_method)
498 {
499  const TState prevState = m_navigationState;
500  try
501  {
503  {
505  "[CAbstractNavigator::navigationStep()] Starting Navigation. "
506  "Watchdog initiated...\n");
507  if (m_navigationParams)
509  mrpt::format(
510  "[CAbstractNavigator::navigationStep()] Navigation "
511  "Params:\n%s\n",
512  m_navigationParams->getAsText().c_str()));
513 
515  }
516 
517  // Have we just started the navigation?
519  {
520  m_pending_events.push_back(
521  std::bind(
523  std::ref(m_robot)));
524  }
525 
526  /* ----------------------------------------------------------------
527  Get current robot dyn state:
528  ---------------------------------------------------------------- */
530 
531  /* ----------------------------------------------------------------
532  Have we reached the target location?
533  ---------------------------------------------------------------- */
534  // Build a 2D segment from the current robot pose to the previous one:
536  const mrpt::math::TSegment2D seg_robot_mov = mrpt::math::TSegment2D(
538  m_latestPoses.size() > 1
539  ? mrpt::math::TPoint2D((++m_latestPoses.rbegin())->second)
540  : mrpt::math::TPoint2D((m_latestPoses.rbegin())->second));
541 
542  if (m_navigationParams)
543  {
544  const double targetDist = seg_robot_mov.distance(
545  mrpt::math::TPoint2D(m_navigationParams->target.target_coords));
546 
547  // Should "End of navigation" event be sent??
548  if (!m_navigationParams->target.targetIsIntermediaryWaypoint &&
550  targetDist <
552  {
554  m_pending_events.push_back(
555  std::bind(
557  std::ref(m_robot)));
558  }
559 
560  // Have we really reached the target?
561  if (checkHasReachedTarget(targetDist))
562  {
564  logFmt(
565  mrpt::utils::LVL_WARN,
566  "Navigation target (%.03f,%.03f) was reached\n",
567  m_navigationParams->target.target_coords.x,
568  m_navigationParams->target.target_coords.y);
569 
570  if (!m_navigationParams->target.targetIsIntermediaryWaypoint)
571  {
572  this->stop(false /*not emergency*/);
574  {
576  m_pending_events.push_back(
577  std::bind(
579  std::ref(m_robot)));
580  }
581  }
582  return;
583  }
584 
585  // Check the "no approaching the target"-alarm:
586  // -----------------------------------------------------------
587  if (targetDist < m_badNavAlarm_minDistTarget)
588  {
589  m_badNavAlarm_minDistTarget = targetDist;
591  }
592  else
593  {
594  // Too much time have passed?
599  .alarm_seems_not_approaching_target_timeout)
600  {
602  "Timeout approaching the target. Aborting navigation.");
603 
605 
606  m_pending_events.push_back(
607  std::bind(
609  std::ref(m_robot)));
610  return;
611  }
612  }
613 
614  // Check if the target seems to be at reach, but it's clearly
615  // occupied by obstacles:
616  if (targetDist <
618  {
619  const auto rel_trg = m_navigationParams->target.target_coords -
621  const bool is_col = checkCollisionWithLatestObstacles(rel_trg);
622  if (is_col)
623  {
624  const bool send_event =
628 
629  if (send_event)
630  {
632  5.0,
633  "Target seems to be blocked by obstacles. Invoking"
634  " sendCannotGetCloserToBlockedTargetEvent().");
635 
636  m_pending_events.push_back(
637  std::bind(
639  sendCannotGetCloserToBlockedTargetEvent,
640  std::ref(m_robot)));
641 
643  }
644  }
645  else
646  {
648  }
649  }
650  }
651 
652  // The normal execution of the navigation: Execute one step:
653  if (call_virtual_nav_method)
654  {
656  }
657  }
658  catch (std::exception& e)
659  {
661  "[CAbstractNavigator::navigationStep] Exception:\n %s", e.what());
662  }
663  catch (...)
664  {
666  "[CAbstractNavigator::navigationStep] Untyped exception!");
667  }
668  m_navigationState = prevState;
669 }
670 
672  const mrpt::math::TPose2D& relative_robot_pose) const
673 {
674  // Default impl:
675  return false;
676 }
const double PREVIOUS_POSES_MAX_AGE
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
#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
#define MRPT_LOG_WARN(_STRING)
#define MRPT_LOG_THROTTLE_WARN(_PERIOD_SECONDS, _STRING)
#define MRPT_LOG_THROTTLE_DEBUG_FMT(_PERIOD_SECONDS, _FMT_STRING,...)
#define MRPT_LOG_ERROR(_STRING)
#define MRPT_LOG_DEBUG(_STRING)
#define MRPT_LOG_INFO(_STRING)
#define MRPT_LOG_ERROR_FMT(_FMT_STRING,...)
Virtual base for velocity commands of different kinematic models of planar mobile robot.
mrpt::poses::CPose2DInterpolator m_latestOdomPoses
virtual bool checkHasReachedTarget(const double targetDist) const
Default implementation: check if target_dist is below the accepted distance.
CRobot2NavInterface & m_robot
The navigator-robot interface.
TState m_navigationState
Current internal state of navigator:
virtual void onNavigateCommandReceived()
Called after each call to CAbstractNavigator::navigate()
void doEmergencyStop(const std::string &msg)
Stops the robot and set navigation state to error.
virtual void resume()
Continues with suspended navigation.
mrpt::utils::CTimeLogger m_timlog_delays
Time logger to collect delay-related stats.
virtual void cancel()
Cancel current navegation.
virtual void suspend()
Suspend current navegation.
virtual void navigate(const TNavigationParams *params)
Navigation request to a single target location.
mrpt::system::TTimeStamp m_badNavAlarm_lastMinDistTime
bool m_navigationEndEventSent
Will be false until the navigation end is sent, and it is reset with each new command.
virtual void navigationStep()
This method must be called periodically in order to effectively run the navigation.
void processNavigateCommand(const TNavigationParams *params)
Does the job of navigate(), except the call to onNavigateCommandReceived()
virtual bool changeSpeedsNOP()
Default: forward call to m_robot.changeSpeedsNOP().
TRobotPoseVel m_curPoseVel
Current robot pose (updated in CAbstractNavigator::navigationStep() )
virtual bool stop(bool isEmergencyStop)
Default: forward call to m_robot.stop().
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),...
void internal_onStartNewNavigation()
Called before starting a new navigation.
virtual void resetNavError()
Resets a NAV_ERROR state back to IDLE
virtual void onStartNewNavigation()=0
Called whenever a new navigation has been started.
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 changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd)
Default: forward call to m_robot.changeSpeed().
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const
Saves all current options to a config file.
std::unique_ptr< TNavigationParams > m_navigationParams
Current navigation parameters.
virtual void performNavigationStepNavigating(bool call_virtual_nav_method=true)
Factorization of the part inside navigationStep(), for the case of state being NAVIGATING.
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...
TState m_lastNavigationState
Last internal state of navigator:
virtual void loadConfigFile(const mrpt::utils::CConfigFileBase &c)
Loads all params from a file.
TAbstractNavigatorParams params_abstract_navigator
void updateCurrentPoseAndSpeeds()
Call to the robot getCurrentPoseAndSpeeds() and updates members m_curPoseVel accordingly.
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...
mrpt::poses::CPose2DInterpolator m_latestPoses
Latest robot poses (updated in CAbstractNavigator::navigationStep() )
TState
The different states for the navigation system.
CAbstractNavigator(CRobot2NavInterface &robot_interface_impl)
ctor
virtual void performNavigationStep()=0
To be implemented in derived classes.
std::recursive_mutex m_nav_cs
mutex for all navigation methods
mrpt::poses::FrameTransformer< 2 > * m_frame_tf
Optional, user-provided frame transformer.
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
virtual void sendWaySeemsBlockedEvent()
Callback: No progression made towards target for a predefined period of time.
virtual bool stop(bool isEmergencyStop=true)=0
Stop the robot right now.
virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd)=0
Sends a velocity command to the robot.
virtual bool stopWatchdog()
Stop the watchdog timer.
virtual double getNavigationTime()
Returns the number of seconds ellapsed since the constructor of this class was invoked,...
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 void sendNavigationStartEvent()
Callback: Start of navigation command.
virtual bool startWatchdog(float T_ms)
Start the watchdog timer of the robot platform, if any, for maximum expected delay between consecutiv...
virtual void sendNavigationEndEvent()
Callback: End of navigation command (reach of single goal, or final waypoint of waypoint list)
virtual bool changeSpeedsNOP()
Just like changeSpeeds(), but will be called when the last velocity command is still the preferred so...
void insert(mrpt::system::TTimeStamp t, const pose_t &p)
Inserts a new pose in the sequence.
iterator erase(iterator element_to_erase)
void clear()
Clears the current sequence of poses.
void setInterpolationMethod(TInterpolatorMethod method)
Change the method used to interpolate the robot path.
This class allows loading and storing values and vectors of different types from a configuration text...
This class implements a config file-like interface over a memory-stored string list.
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
Definition: datetime.h:16
GLenum GLint ref
Definition: glext.h:4050
const GLubyte * c
Definition: glext.h:6313
GLubyte GLubyte b
Definition: glext.h:6279
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLdouble s
Definition: glext.h:3676
GLenum const GLfloat * params
Definition: glext.h:3534
GLsizei const GLchar ** string
Definition: glext.h:4101
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:208
mrpt::system::TTimeStamp getCurrentTime()
Returns the current (UTC) system time.
Definition: datetime.cpp:73
#define MRPT_START
Definition: mrpt_macros.h:425
#define ASSERT_(f)
Definition: mrpt_macros.h:309
#define MRPT_END
Definition: mrpt_macros.h:429
bool operator==(const CAbstractNavigator::TNavigationParamsBase &, const CAbstractNavigator::TNavigationParamsBase &)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:19
Lightweight 2D point.
Lightweight 2D pose.
double phi
Orientation (rads)
2D segment, consisting of two points.
double distance(const TPoint2D &point) const
Distance to point.
void rotate(const double ang)
Transform the (vx,vy) components for a counterclockwise rotation of ang radians.
double dist_check_target_is_blocked
(Default value=0.6) When closer than this distance, check if the target is blocked to abort navigatio...
int hysteresis_check_target_is_blocked
(Default=3) How many steps should the condition for dist_check_target_is_blocked be fulfilled to rais...
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &c, const std::string &s) const override
This method saves the options to a ".ini"-like file or memory-stored string list.
double dist_to_target_for_sending_event
Default value=0, means use the "targetAllowedDistance" passed by the user in the navigation request.
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &c, const std::string &s) override
This method load the options from a ".ini"-like file or memory-stored string list.
Base for all high-level navigation commands.
The struct for configuring navigation requests.
virtual bool isEqual(const TNavigationParamsBase &o) const override
virtual std::string getAsText() const override
Gets navigation params as a human-readable format.
mrpt::math::TPose2D rawOdometry
raw odometry (frame does not match to "pose", but is expected to be smoother in the short term).
std::string pose_frame_id
map frame ID for pose
Individual target info in CAbstractNavigator::TNavigationParamsBase and derived classes.
std::string target_frame_id
(Default="map") Frame ID in which target is given.
mrpt::math::TPose2D target_coords
Coordinates of desired target location.
bool operator==(const TargetInfo &o) const
double targetDesiredRelSpeed
(Default=.05) Desired relative speed (wrt maximum speed), in range [0,1], of the vehicle at target.
float targetAllowedDistance
(Default=0.5 meters) Allowed distance to target in order to end the navigation.
std::string getAsText() const
Gets navigation params as a human-readable format.
bool targetIsRelative
(Default=false) Whether the target coordinates are in global coordinates (false) or are relative to t...
A safe way to call enter() and leave() of a mrpt::utils::CTimeLogger upon construction and destructio...
Definition: CTimeLogger.h:153



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 63ea9d1f1 Thu Nov 23 00:06:53 2017 +0100 at mar 26 may 2026 12:19:29 CEST