Main MRPT website > C++ reference for MRPT 1.9.9
CWaypointsNavigator.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 
13 #include <mrpt/poses/CPose2D.h>
14 #include <mrpt/math/wrap2pi.h>
15 
16 using namespace mrpt::nav;
17 using namespace std;
18 
20 {
21  std::string s = TNavigationParams::getAsText();
22  if (!multiple_targets.empty())
23  {
24  s += "multiple_targets:\n";
25  int i = 0;
26  for (const auto& e : multiple_targets)
27  {
28  s += mrpt::format("target[%i]:\n", i++);
29  s += e.getAsText();
30  }
31  }
32  return s;
33 }
34 
37 {
38  auto o =
40  &rhs);
41  return o != nullptr &&
43  multiple_targets == o->multiple_targets;
44 }
45 
47  : CAbstractNavigator(robot_if),
48  m_was_aligning(false),
49  m_is_aligning(false),
50  m_last_alignment_cmd(mrpt::system::now())
51 {
52 }
53 
56 {
58 
59  std::lock_guard<std::recursive_mutex> csl(m_nav_waypoints_cs);
60 
61  m_was_aligning = false;
64  m_waypoint_nav_status.waypoint_index_current_goal = -1; // Not started yet.
65 }
66 
68  const TWaypointSequence& nav_request)
69 {
71 
73 
74  std::lock_guard<std::recursive_mutex> csl(m_nav_waypoints_cs);
75 
76  m_pending_events.clear();
77 
78  const size_t N = nav_request.waypoints.size();
79  ASSERTMSG_(N > 0, "List of waypoints is empty!");
80 
82  // Copy waypoints fields data, leave status fields to defaults:
83  for (size_t i = 0; i < N; i++)
84  {
85  ASSERT_(nav_request.waypoints[i].isValid());
86  m_waypoint_nav_status.waypoints[i] = nav_request.waypoints[i];
87  }
89 
90  m_waypoint_nav_status.waypoint_index_current_goal = -1; // Not started yet.
91 
92  // The main loop navigationStep() will iterate over waypoints and send them
93  // to navigate()
94  MRPT_END
95 }
96 
98  TWaypointStatusSequence& out_nav_status) const
99 {
100  // No need to lock mutex...
101  out_nav_status = m_waypoint_nav_status;
102 }
103 
104 /** \callergraph */
106 {
107  {
108  std::lock_guard<std::recursive_mutex> csl(m_nav_waypoints_cs);
110  }
112 }
113 
114 /** \callergraph */
116 {
117  MRPT_START
118 
119  using mrpt::square;
120 
121  // --------------------------------------
122  // Waypoint navigation algorithm
123  // --------------------------------------
124  m_is_aligning =
125  false; // the robot is aligning into a waypoint with a desired heading
126 
127  {
129  m_timlog_delays, "CWaypointsNavigator::navigationStep()");
130  std::lock_guard<std::recursive_mutex> csl(m_nav_waypoints_cs);
131 
133  m_waypoint_nav_status; // shortcut to save typing
134 
135  if (wps.waypoints.empty() || wps.final_goal_reached)
136  {
137  // No nav request is pending or it was canceled
138  }
139  else
140  {
141  // 0) Get current robot pose:
143 
144  // 1) default policy: go thru WPs one by one
145  const int prev_wp_index = wps.waypoint_index_current_goal;
146 
147  mrpt::math::TSegment2D robot_move_seg;
148  robot_move_seg.point1.x = m_curPoseVel.pose.x;
149  robot_move_seg.point1.y = m_curPoseVel.pose.y;
151  {
152  robot_move_seg.point2 = robot_move_seg.point1;
153  }
154  else
155  {
156  robot_move_seg.point2.x = wps.last_robot_pose.x;
157  robot_move_seg.point2.y = wps.last_robot_pose.y;
158  }
159  wps.last_robot_pose = m_curPoseVel.pose; // save for next iters
160 
161  if (wps.waypoint_index_current_goal >= 0)
162  {
163  auto& wp = wps.waypoints[wps.waypoint_index_current_goal];
164  const double dist2target = robot_move_seg.distance(wp.target);
165  if (dist2target < wp.allowed_distance ||
166  m_was_aligning /* we were already aligning at a WP */)
167  {
168  bool consider_wp_reached = false;
169  if (wp.target_heading == TWaypoint::INVALID_NUM)
170  {
171  consider_wp_reached = true;
172  }
173  else
174  {
175  // Handle pure-rotation robot interface to honor
176  // target_heading
177  const double ang_err = mrpt::math::angDistance(
178  m_curPoseVel.pose.phi, wp.target_heading);
179  const double tim_since_last_align =
182  const double ALIGN_WAIT_TIME = 1.5; // seconds
183 
184  if (std::abs(ang_err) <=
186  .waypoint_angle_tolerance &&
187  /* give some time for the alignment (if supported in
188  this robot) to finish)*/
189  tim_since_last_align > ALIGN_WAIT_TIME)
190  {
191  consider_wp_reached = true;
192  }
193  else
194  {
195  m_is_aligning = true;
196 
197  if (!m_was_aligning)
198  {
199  // 1st time we are aligning:
200  // Send vel_cmd to the robot:
202  align_cmd = m_robot.getAlignCmd(ang_err);
203 
205  "[CWaypointsNavigator::navigationStep] "
206  "Trying to align to heading: %.02f deg. "
207  "Relative heading: %.02f deg. "
208  "With motion cmd: %s",
209  mrpt::RAD2DEG(wp.target_heading),
210  mrpt::RAD2DEG(ang_err),
211  align_cmd ? align_cmd->asString().c_str()
212  : "nullptr (operation not "
213  "supported by this robot)");
214 
215  this->stop(false /*not emergency*/); // In any
216  // case,
217  // do a
218  // "stop"
219  if (align_cmd)
220  {
221  this->changeSpeeds(*align_cmd);
222  }
223  else
224  {
225  consider_wp_reached =
226  true; // this robot does not support
227  // "in place" alignment
228  }
229  }
230  else
231  {
233  0.5,
234  "[CWaypointsNavigator::navigationStep] "
235  "Waiting for the robot to get aligned: "
236  "current_heading=%.02f deg "
237  "target_heading=%.02f deg",
239  mrpt::RAD2DEG(wp.target_heading));
240  }
241  }
242  }
243 
244  if (consider_wp_reached)
245  {
247  "[CWaypointsNavigator::navigationStep] Waypoint "
248  << (wps.waypoint_index_current_goal + 1) << "/"
249  << wps.waypoints.size()
250  << " reached."
251  " segment-to-target dist: "
252  << dist2target
253  << ", allowed_dist: " << wp.allowed_distance);
254 
255  wp.reached = true;
256  wp.skipped = false;
257  wp.timestamp_reach = mrpt::system::now();
258 
259  m_pending_events.push_back(
260  std::bind(
262  std::ref(m_robot),
264  true /*reason: really reached*/));
265 
266  // Was this the final goal??
268  int(wps.waypoints.size() - 1))
269  {
271  }
272  else
273  {
274  wps.final_goal_reached = true;
275  // Make sure the end-navigation event is issued,
276  // navigation state switches to IDLE, etc:
277  this->performNavigationStepNavigating(false);
278  }
279  }
280  }
281  }
282 
283  // 2) More advanced policy: if available, use children class methods
284  // to decide
285  // which is the best candidate for the next waypoint, if we can
286  // skip current one:
287  if (!wps.final_goal_reached &&
288  wps.waypoint_index_current_goal >= 0 &&
289  wps.waypoints[wps.waypoint_index_current_goal].allow_skip)
290  {
291  const mrpt::poses::CPose2D robot_pose(m_curPoseVel.pose);
292  int most_advanced_wp = wps.waypoint_index_current_goal;
293  const int most_advanced_wp_at_begin = most_advanced_wp;
294 
295  for (int idx = wps.waypoint_index_current_goal;
296  idx < (int)wps.waypoints.size(); idx++)
297  {
298  if (idx < 0) continue;
299  if (wps.waypoints[idx].reached) continue;
300 
301  // Is it reachable?
302  mrpt::math::TPoint2D wp_local_wrt_robot;
303  robot_pose.inverseComposePoint(
304  wps.waypoints[idx].target, wp_local_wrt_robot);
305 
307  .max_distance_to_allow_skip_waypoint > 0 &&
308  wp_local_wrt_robot.norm() >
311  continue; // Skip this one, it is too far away
312 
313  const bool is_reachable =
314  this->impl_waypoint_is_reachable(wp_local_wrt_robot);
315 
316  if (is_reachable)
317  {
318  // Robustness filter: only skip to a future waypoint if
319  // it is seen as "reachable" during
320  // a given number of timesteps:
321  if (++wps.waypoints[idx].counter_seen_reachable >
324  {
325  most_advanced_wp = idx;
326  }
327  }
328 
329  // Is allowed to skip it?
330  if (!wps.waypoints[idx].allow_skip)
331  break; // Do not keep trying, since we are now allowed
332  // to skip this one.
333  }
334 
335  if (most_advanced_wp >= 0)
336  {
337  wps.waypoint_index_current_goal = most_advanced_wp;
338  for (int k = most_advanced_wp_at_begin;
339  k < most_advanced_wp; k++)
340  {
341  auto& wp = wps.waypoints[k];
342  wp.reached = true;
343  wp.skipped = true;
344  wp.timestamp_reach = mrpt::system::now();
345 
346  m_pending_events.push_back(
347  std::bind(
349  std::ref(m_robot), k,
350  false /*reason: skipped*/));
351  }
352  }
353  }
354 
355  // Still not started and no better guess? Start with the first
356  // waypoint:
357  if (wps.waypoint_index_current_goal < 0)
359 
360  // 3) Should I request a new (single target) navigation command?
361  // Only if the temporary goal changed:
362  if (wps.waypoint_index_current_goal >= 0 &&
363  prev_wp_index != wps.waypoint_index_current_goal)
364  {
365  ASSERT_(
367  int(wps.waypoints.size()));
369 
370  // Notify we have a new "current waypoint"
371  m_pending_events.push_back(
372  std::bind(
375 
376  // Send the current targets + "multitarget_look_ahead"
377  // additional ones to help the local planner.
379 
380  // Check skippable flag while traversing from current wp forward
381  // "multitarget_look_ahead" steps:
382  int wp_last_idx = wps.waypoint_index_current_goal;
383  for (int nstep = 0;
384  wp_last_idx < int(wps.waypoints.size()) - 1 &&
386  ++nstep)
387  {
388  if (!m_waypoint_nav_status.waypoints[wp_last_idx]
389  .allow_skip)
390  break;
391  wp_last_idx++;
392  }
393 
394  for (int wp_idx = wps.waypoint_index_current_goal;
395  wp_idx <= wp_last_idx; wp_idx++)
396  {
397  TWaypointStatus& wp = wps.waypoints[wp_idx];
398  const bool is_final_wp =
399  ((wp_idx + 1) == int(wps.waypoints.size()));
400 
402 
403  ti.target_coords.x = wp.target.x;
404  ti.target_coords.y = wp.target.y;
405  ti.target_coords.phi =
407  ? wp.target_heading
408  : .0);
411  ti.targetIsRelative = false;
412  ti.targetIsIntermediaryWaypoint = !is_final_wp;
414  (is_final_wp ||
418  : 1.;
419 
420  // For backwards compat. with single-target code, write
421  // single target info too for the first, next, waypoint:
422  if (wp_idx == wps.waypoint_index_current_goal)
423  {
424  nav_cmd.target = ti;
425  }
426  // Append to list of targets:
427  nav_cmd.multiple_targets.emplace_back(ti);
428  }
429  this->processNavigateCommand(&nav_cmd);
430 
432  "[CWaypointsNavigator::navigationStep] Active waypoint "
433  "changed. Current status:\n"
434  << this->getWaypointNavStatus().getAsText());
435  }
436  }
437  }
438 
439  // Note: navigationStep() called *after* waypoints part to get
440  // end-of-navigation events *after*
441  // waypoints-related events:
442 
443  m_was_aligning = m_is_aligning; // Let the next timestep know about this
444 
445  MRPT_END
446 }
447 
449 {
450  MRPT_START
451  m_is_aligning =
452  false; // the robot is aligning into a waypoint with a desired heading
453 
455  {
457  }
458 
459  // Call base navigation step to execute one-single waypoint navigation, as
460  // usual:
461  if (!m_is_aligning)
462  {
463  CAbstractNavigator::navigationStep(); // This internally locks
464  // "m_nav_cs"
465  }
466  else
467  {
468  // otherwise, at least, process pending events:
470  }
471 
472  MRPT_END
473 }
474 
475 /** \callergraph */
477 /** \callergraph */
479  const mrpt::math::TPoint2D& wp_local_wrt_robot) const
480 {
481  return impl_waypoint_is_reachable(wp_local_wrt_robot);
482 }
483 
485 {
486  MRPT_START
487 
488  params_waypoints_navigator.loadFromConfigFile(c, "CWaypointsNavigator");
490 
491  MRPT_END
492 }
493 
495 {
497  params_waypoints_navigator.saveToConfigFile(c, "CWaypointsNavigator");
498 }
499 
503 {
504  MRPT_LOAD_CONFIG_VAR(max_distance_to_allow_skip_waypoint, double, c, s);
505  MRPT_LOAD_CONFIG_VAR(min_timesteps_confirm_skip_waypoints, int, c, s);
506  MRPT_LOAD_CONFIG_VAR_DEGREES(waypoint_angle_tolerance, c, s);
507  MRPT_LOAD_CONFIG_VAR(rel_speed_for_stop_waypoints, double, c, s);
508  MRPT_LOAD_CONFIG_VAR(multitarget_look_ahead, int, c, s);
509 }
510 
514 {
516  max_distance_to_allow_skip_waypoint,
517  "Max distance to `foresee` waypoints [meters]. (<0: unlimited)");
519  min_timesteps_confirm_skip_waypoints,
520  "Min timesteps a `future` waypoint must be seen as reachable to become "
521  "the active one.");
523  "waypoint_angle_tolerance", waypoint_angle_tolerance,
524  "Angular error tolerance for waypoints with an assigned heading [deg] "
525  "(Default: 5 deg)");
527  rel_speed_for_stop_waypoints,
528  "[0,1] Relative speed when aiming at a stop-point waypoint "
529  "(Default=0.10)");
531  multitarget_look_ahead,
532  ">=0 number of waypoints to forward to the underlying navigation "
533  "engine, to ease obstacles avoidance when a waypoint is blocked "
534  "(Default=0 : none)");
535 }
536 
538  : max_distance_to_allow_skip_waypoint(-1.0),
539  min_timesteps_confirm_skip_waypoints(1),
540  waypoint_angle_tolerance(mrpt::DEG2RAD(5.0)),
541  rel_speed_for_stop_waypoints(0.10),
542  multitarget_look_ahead(0)
543 {
544 }
545 
546 /** \callergraph */
547 bool CWaypointsNavigator::checkHasReachedTarget(const double targetDist) const
548 {
549  bool ret;
550  const TWaypointStatus* wp = nullptr;
551  const auto& wps = m_waypoint_nav_status;
552  if (m_navigationParams->target.targetIsIntermediaryWaypoint)
553  {
554  ret = false;
555  }
556  else if (wps.timestamp_nav_started != INVALID_TIMESTAMP)
557  {
558  wp = (!wps.waypoints.empty() && wps.waypoint_index_current_goal >= 0 &&
559  wps.waypoint_index_current_goal < (int)wps.waypoints.size())
560  ? &wps.waypoints[wps.waypoint_index_current_goal]
561  : nullptr;
562  ret =
563  (wp == nullptr &&
564  targetDist <= m_navigationParams->target.targetAllowedDistance) ||
565  (wp->reached);
566  }
567  else
568  {
569  ret = (targetDist <= m_navigationParams->target.targetAllowedDistance);
570  }
572  "CWaypointsNavigator::checkHasReachedTarget() called "
573  "with targetDist="
574  << targetDist << " return=" << ret
575  << " waypoint: " << (wp == nullptr ? std::string("") : wp->getAsText())
576  << "wps.timestamp_nav_started="
577  << (wps.timestamp_nav_started == INVALID_TIMESTAMP
578  ? "INVALID_TIMESTAMP"
580  wps.timestamp_nav_started)));
581  return ret;
582 }
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::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::nav::CWaypointsNavigator::isRelativePointReachable
bool isRelativePointReachable(const mrpt::math::TPoint2D &wp_local_wrt_robot) const
Returns true if, according to the information gathered at the last navigation step,...
Definition: CWaypointsNavigator.cpp:478
mrpt::nav::TWaypoint::INVALID_NUM
static const int INVALID_NUM
The default value of fields (used to detect non-set values)
Definition: TWaypoint.h:67
mrpt::nav::CAbstractNavigator::onNavigateCommandReceived
virtual void onNavigateCommandReceived()
Called after each call to CAbstractNavigator::navigate()
Definition: CAbstractNavigator.cpp:273
nav-precomp.h
mrpt::nav::TWaypoint::target_heading
double target_heading
[Default=any heading] Optionally, set to the desired orientation [radians] of the robot at this waypo...
Definition: TWaypoint.h:35
MRPT_LOG_INFO_FMT
#define MRPT_LOG_INFO_FMT(_FMT_STRING,...)
Definition: system/COutputLogger.h:463
mrpt::system::dateTimeLocalToString
std::string dateTimeLocalToString(const mrpt::system::TTimeStamp t)
Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS....
Definition: datetime.cpp:270
mrpt::math::TPoint2D::y
double y
Definition: lightweight_geom_data.h:49
MRPT_LOG_THROTTLE_INFO_FMT
#define MRPT_LOG_THROTTLE_INFO_FMT(_PERIOD_SECONDS, _FMT_STRING,...)
Definition: system/COutputLogger.h:499
mrpt::nav::CAbstractNavigator::TargetInfo
Individual target info in CAbstractNavigator::TNavigationParamsBase and derived classes.
Definition: CAbstractNavigator.h:69
s
GLdouble s
Definition: glext.h:3676
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
CWaypointsNavigator.h
MRPT_LOAD_CONFIG_VAR
#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...
Definition: config/CConfigFileBase.h:282
mrpt::nav::CWaypointsNavigator::impl_waypoint_is_reachable
virtual bool impl_waypoint_is_reachable(const mrpt::math::TPoint2D &wp_local_wrt_robot) const =0
Implements the way to waypoint is free function in children classes: true must be returned if,...
mrpt::math::TPose2D::phi
double phi
Orientation (rads)
Definition: lightweight_geom_data.h:195
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::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
c
const GLubyte * c
Definition: glext.h:6313
mrpt::nav::CWaypointsNavigator::m_was_aligning
bool m_was_aligning
Whether the last timestep was "is_aligning" in a waypoint with heading.
Definition: CWaypointsNavigator.h:172
mrpt::nav::CWaypointsNavigator::~CWaypointsNavigator
virtual ~CWaypointsNavigator()
dtor
Definition: CWaypointsNavigator.cpp:54
mrpt::nav::TWaypointStatus::reached
bool reached
Whether this waypoint has been reached already (to within the allowed distance as per user specificat...
Definition: TWaypoint.h:114
mrpt::nav::CAbstractNavigator::m_navigationParams
std::unique_ptr< TNavigationParams > m_navigationParams
Current navigation parameters.
Definition: CAbstractNavigator.h:307
mrpt::math::angDistance
T angDistance(T from, T to)
Computes the shortest angular increment (or distance) between two planar orientations,...
Definition: wrap2pi.h:98
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::CAbstractNavigator::TNavigationParams::target
TargetInfo target
Navigation target.
Definition: CAbstractNavigator.h:121
mrpt::system::now
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:75
mrpt::nav
Definition: CAbstractHolonomicReactiveMethod.h:23
mrpt::nav::CWaypointsNavigator::m_last_alignment_cmd
mrpt::system::TTimeStamp m_last_alignment_cmd
Definition: CWaypointsNavigator.h:174
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::math::TPoint2D::x
double x
X,Y coordinates.
Definition: lightweight_geom_data.h:49
mrpt::math::TPose2D::y
double y
Definition: lightweight_geom_data.h:193
wrap2pi.h
mrpt::nav::CWaypointsNavigator::navigationStep
virtual void navigationStep() override
This method must be called periodically in order to effectively run the navigation.
Definition: CWaypointsNavigator.cpp:448
mrpt::nav::CWaypointsNavigator::checkHasReachedTarget
virtual bool checkHasReachedTarget(const double targetDist) const override
Default implementation: check if target_dist is below the accepted distance.
Definition: CWaypointsNavigator.cpp:547
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::nav::CAbstractNavigator
This is the base class for any reactive/planned navigation system.
Definition: CAbstractNavigator.h:59
mrpt::nav::CWaypointsNavigator::TNavigationParamsWaypoints
The struct for configuring navigation requests to CWaypointsNavigator and derived classes.
Definition: CWaypointsNavigator.h:45
mrpt::nav::CWaypointsNavigator::getWaypointNavStatus
TWaypointStatusSequence getWaypointNavStatus() const
Get a copy of the control structure which describes the progress status of the waypoint navigation.
Definition: CWaypointsNavigator.h:95
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::square
T square(const T x)
Inline function for the square of a number.
Definition: core/include/mrpt/core/bits_math.h:18
mrpt::RAD2DEG
double RAD2DEG(const double x)
Radians to degrees.
Definition: core/include/mrpt/core/bits_math.h:48
CPose2D.h
mrpt::nav::CAbstractNavigator::TRobotPoseVel::pose
mrpt::math::TPose2D pose
Definition: CAbstractNavigator.h:320
mrpt::nav::TWaypointStatusSequence::waypoint_index_current_goal
int waypoint_index_current_goal
Index in waypoints of the waypoint the navigator is currently trying to reach.
Definition: TWaypoint.h:147
mrpt::nav::TWaypointSequence::waypoints
std::vector< TWaypoint > waypoints
Definition: TWaypoint.h:90
mrpt::nav::CAbstractNavigator::TNavigationParams::isEqual
virtual bool isEqual(const TNavigationParamsBase &o) const override
Definition: CAbstractNavigator.cpp:72
mrpt::nav::CRobot2NavInterface::getAlignCmd
virtual mrpt::kinematics::CVehicleVelCmd::Ptr getAlignCmd(const double relative_heading_radians)
Gets a motion command to make the robot to align with a given relative heading, without translating.
Definition: CRobot2NavInterface.cpp:30
mrpt::nav::CWaypointsNavigator::waypoints_navigationStep
virtual void waypoints_navigationStep()
The waypoints-specific part of navigationStep()
Definition: CWaypointsNavigator.cpp:115
mrpt::nav::CWaypointsNavigator::onNavigateCommandReceived
virtual void onNavigateCommandReceived() override
Called after each call to CAbstractNavigator::navigate()
Definition: CWaypointsNavigator.cpp:55
mrpt::nav::CAbstractNavigator::loadConfigFile
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c)
Loads all params from a file.
Definition: CAbstractNavigator.cpp:159
mrpt::nav::CWaypointsNavigator::cancel
virtual void cancel() override
Cancel current navegation.
Definition: CWaypointsNavigator.cpp:105
mrpt::nav::CWaypointsNavigator::params_waypoints_navigator
TWaypointsNavigatorParams params_waypoints_navigator
Definition: CWaypointsNavigator.h:138
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::nav::CWaypointsNavigator::TWaypointsNavigatorParams::max_distance_to_allow_skip_waypoint
double max_distance_to_allow_skip_waypoint
In meters.
Definition: CWaypointsNavigator.h:114
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::format
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
mrpt::poses::CPose2D
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:40
mrpt::nav::TWaypointStatusSequence::timestamp_nav_started
mrpt::system::TTimeStamp timestamp_nav_started
Timestamp of user navigation command.
Definition: TWaypoint.h:140
mrpt::nav::CAbstractNavigator::TargetInfo::target_coords
mrpt::math::TPose2D target_coords
Coordinates of desired target location.
Definition: CAbstractNavigator.h:73
mrpt::nav::CAbstractNavigator::m_robot
CRobot2NavInterface & m_robot
The navigator-robot interface.
Definition: CAbstractNavigator.h:310
mrpt::nav::TWaypointStatusSequence::final_goal_reached
bool final_goal_reached
Whether the final waypoint has been reached successfuly.
Definition: TWaypoint.h:142
MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT
#define MRPT_SAVE_CONFIG_VAR_DEGREES_COMMENT( __entryName, __variable, __comment)
Definition: config/CConfigFileBase.h:466
mrpt::nav::CAbstractNavigator::stop
virtual bool stop(bool isEmergencyStop)
Default: forward call to m_robot.stop().
Definition: CAbstractNavigator.cpp:420
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::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: CWaypointsNavigator.cpp:512
mrpt::math::TPoint2D
Lightweight 2D point.
Definition: lightweight_geom_data.h:42
mrpt::nav::CWaypointsNavigator::TNavigationParamsWaypoints::multiple_targets
std::vector< mrpt::nav::CAbstractNavigator::TargetInfo > multiple_targets
If not empty, this will prevail over the base class single goal target.
Definition: CWaypointsNavigator.h:53
mrpt::math::TSegment2D
2D segment, consisting of two points.
Definition: lightweight_geom_data.h:958
mrpt::nav::CWaypointsNavigator::m_nav_waypoints_cs
std::recursive_mutex m_nav_waypoints_cs
Definition: CWaypointsNavigator.h:149
mrpt::nav::CAbstractNavigator::m_curPoseVel
TRobotPoseVel m_curPoseVel
Current robot pose (updated in CAbstractNavigator::navigationStep() )
Definition: CAbstractNavigator.h:332
ASSERTMSG_
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:101
mrpt::poses::CPose2D::inverseComposePoint
void inverseComposePoint(const double gx, const double gy, double &lx, double &ly) const
Computes the 2D point L such as .
Definition: CPose2D.cpp:206
mrpt::nav::TWaypointStatus::getAsText
std::string getAsText() const
Gets navigation params as a human-readable format.
Definition: TWaypoint.cpp:102
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::TWaypointsNavigatorParams
TWaypointsNavigatorParams()
Definition: CWaypointsNavigator.cpp:537
mrpt::kinematics::CVehicleVelCmd::Ptr
std::shared_ptr< CVehicleVelCmd > Ptr
Definition: CVehicleVelCmd.h:24
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_LOG_DEBUG_STREAM
#define MRPT_LOG_DEBUG_STREAM(__CONTENTS)
Use: MRPT_LOG_DEBUG_STREAM("Var=" << value << " foo=" << foo_var);
Definition: system/COutputLogger.h:471
mrpt::nav::TWaypointStatus
A waypoint with an execution status.
Definition: TWaypoint.h:110
mrpt::nav::CWaypointsNavigator::TNavigationParamsWaypoints::isEqual
virtual bool isEqual(const CAbstractNavigator::TNavigationParamsBase &o) const override
Definition: CWaypointsNavigator.cpp:35
mrpt::nav::CRobot2NavInterface::sendWaypointReachedEvent
virtual void sendWaypointReachedEvent(int waypoint_index, bool reached_nSkipped)
Callback: Reached an intermediary waypoint in waypoint list navigation.
Definition: CRobot2NavInterface.cpp:70
mrpt::nav::CAbstractNavigator::SUSPENDED
@ SUSPENDED
Definition: CAbstractNavigator.h:176
mrpt::nav::TWaypointSequence
The struct for requesting navigation requests for a sequence of waypoints.
Definition: TWaypoint.h:88
mrpt::nav::CWaypointsNavigator::saveConfigFile
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const override
Saves all current options to a config file.
Definition: CWaypointsNavigator.cpp:494
mrpt::nav::CWaypointsNavigator::CWaypointsNavigator
CWaypointsNavigator(CRobot2NavInterface &robot_interface_impl)
ctor
Definition: CWaypointsNavigator.cpp:46
mrpt::nav::TWaypoint::allowed_distance
double allowed_distance
[Must be set by the user] How close should the robot get to this waypoint for it to be considered rea...
Definition: TWaypoint.h:43
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::TWaypointStatusSequence::last_robot_pose
mrpt::math::TPose2D last_robot_pose
Robot pose at last time step (has INVALID_NUM fields upon initialization)
Definition: TWaypoint.h:151
mrpt::nav::CWaypointsNavigator::TNavigationParamsWaypoints::getAsText
virtual std::string getAsText() const override
Gets navigation params as a human-readable format.
Definition: CWaypointsNavigator.cpp:19
mrpt::nav::TWaypoint::target_frame_id
std::string target_frame_id
(Default="map") Frame ID in which target is given.
Definition: TWaypoint.h:39
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::min_timesteps_confirm_skip_waypoints
int min_timesteps_confirm_skip_waypoints
How many times shall a future waypoint be seen as reachable to skip to it (Default: 1)
Definition: CWaypointsNavigator.h:117
ref
GLenum GLint ref
Definition: glext.h:4050
mrpt::nav::TWaypointStatusSequence::waypoints
std::vector< TWaypointStatus > waypoints
Waypoints parameters and status (reached, skipped, etc.)
Definition: TWaypoint.h:138
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::CWaypointsNavigator::navigateWaypoints
virtual void navigateWaypoints(const TWaypointSequence &nav_request)
Waypoint navigation request.
Definition: CWaypointsNavigator.cpp:67
mrpt::nav::CWaypointsNavigator::m_is_aligning
bool m_is_aligning
Definition: CWaypointsNavigator.h:173
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::multitarget_look_ahead
int multitarget_look_ahead
>=0 number of waypoints to forward to the underlying navigation engine, to ease obstacles avoidance w...
Definition: CWaypointsNavigator.h:127
mrpt::math::TPoint2D::norm
double norm() const
Point norm.
Definition: lightweight_geom_data.h:179
mrpt::math::TSegment2D::point1
TPoint2D point1
Origin point.
Definition: lightweight_geom_data.h:964
mrpt::nav::TWaypoint::target
mrpt::math::TPoint2D target
[Must be set by the user] Coordinates of desired target location (world/global coordinates).
Definition: TWaypoint.h:29
mrpt::math::TSegment2D::point2
TPoint2D point2
Destiny point.
Definition: lightweight_geom_data.h:968
mrpt::nav::CRobot2NavInterface::sendNewWaypointTargetEvent
virtual void sendNewWaypointTargetEvent(int waypoint_index)
Callback: Heading towards a new intermediary/final waypoint in waypoint list navigation.
Definition: CRobot2NavInterface.cpp:79
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::rel_speed_for_stop_waypoints
double rel_speed_for_stop_waypoints
[0,1] Relative speed when aiming at a stop-point waypoint (Default=0.10)
Definition: CWaypointsNavigator.h:123
mrpt::nav::CAbstractNavigator::TargetInfo::targetIsIntermediaryWaypoint
bool targetIsIntermediaryWaypoint
Definition: CAbstractNavigator.h:90
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::CWaypointsNavigator::loadConfigFile
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c) override
Loads all params from a file.
Definition: CWaypointsNavigator.cpp:484
mrpt::nav::TWaypointStatusSequence
The struct for querying the status of waypoints navigation.
Definition: TWaypoint.h:135
mrpt::nav::CWaypointsNavigator::m_waypoint_nav_status
TWaypointStatusSequence m_waypoint_nav_status
The latest waypoints navigation command and the up-to-date control status.
Definition: CWaypointsNavigator.h:148
mrpt::math::TPose2D::x
double x
X,Y coordinates.
Definition: lightweight_geom_data.h:193
MRPT_LOAD_CONFIG_VAR_DEGREES
#define MRPT_LOAD_CONFIG_VAR_DEGREES( variableName, configFileObject, sectionNameStr)
Loads a double variable, stored as radians but entered in the INI-file as degrees.
Definition: config/CConfigFileBase.h:296
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::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: CWaypointsNavigator.cpp:501
mrpt::nav::CAbstractNavigator::TNavigationParamsBase
Base for all high-level navigation commands.
Definition: CAbstractNavigator.h:104
mrpt::nav::CWaypointsNavigator::onStartNewNavigation
virtual void onStartNewNavigation() override
Called whenever a new navigation has been started.
Definition: CWaypointsNavigator.cpp:476
mrpt::DEG2RAD
double DEG2RAD(const double x)
Degrees to radians.
Definition: core/include/mrpt/core/bits_math.h:42



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