Main MRPT website > C++ reference for MRPT 1.9.9
CWaypointsNavigator.h
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 #pragma once
10 
13 
14 namespace mrpt
15 {
16 namespace nav
17 {
18 /** This class extends `CAbstractNavigator` with the capability of following a
19  * list of waypoints. By default, waypoints are followed one by one,
20  * but, if they are tagged with `allow_skip=true` **and** the derived navigator
21  * class supports it, the navigator may choose to skip some to
22  * make a smoother, safer and shorter navigation.
23  *
24  * Waypoints have an optional `target_heading` field, which will be honored only
25  * for waypoints that are skipped, and if the underlying robot
26  * interface supports the pure-rotation methods.
27  *
28  * Notes on navigation status and event dispatchment:
29  * - Navigation state may briefly pass by the `IDLE` status between a waypoint
30  * is reached and a new navigation command is issued towards the next waypoint.
31  * - `sendNavigationEndEvent()` will be called only when the last waypoint is
32  * reached.
33  * - Reaching an intermediary waypoint (or skipping it if considered so by the
34  * navigator) generates a call to `sendWaypointReachedEvent()` instead.
35  *
36  * \sa Base class CAbstractNavigator, CWaypointsNavigator::navigateWaypoints(),
37  * and derived classes.
38  * \ingroup nav_reactive
39  */
41 {
42  public:
43  /** The struct for configuring navigation requests to CWaypointsNavigator
44  * and derived classes. */
47  {
48  /** If not empty, this will prevail over the base class single goal
49  * target.
50  * Semantic is: any of these targets will be good for heading the robot
51  * towards them,
52  * but the priority is for the latest ones in the sequence. */
53  std::vector<mrpt::nav::CAbstractNavigator::TargetInfo> multiple_targets;
54 
55  virtual std::string getAsText() const override;
56  virtual std::unique_ptr<TNavigationParams> clone() const override
57  {
58  return std::unique_ptr<TNavigationParams>(
59  new TNavigationParamsWaypoints(*this));
60  }
61 
62  protected:
63  virtual bool isEqual(
64  const CAbstractNavigator::TNavigationParamsBase& o) const override;
65  };
66 
67  /** ctor */
68  CWaypointsNavigator(CRobot2NavInterface& robot_interface_impl);
69  /** dtor */
70  virtual ~CWaypointsNavigator();
71 
72  // Overriden to call the general navigationStep(), plus waypoint selection
73  // logic.
74  virtual void navigationStep() override;
75  /** Cancel current navegation. */
76  virtual void cancel() override;
77 
78  /** \name Waypoint navigation control API
79  * @{ */
80 
81  /** Waypoint navigation request. This immediately cancels any other previous
82  * on-going navigation.
83  * \sa CAbstractNavigator::navigate() for single waypoint navigation
84  * requests.
85  */
86  virtual void navigateWaypoints(const TWaypointSequence& nav_request);
87 
88  /** Get a copy of the control structure which describes the progress status
89  * of the waypoint navigation. */
90  virtual void getWaypointNavStatus(
91  TWaypointStatusSequence& out_nav_status) const;
92 
93  /** Get a copy of the control structure which describes the progress status
94  * of the waypoint navigation. */
96  {
97  TWaypointStatusSequence nav_status;
98  this->getWaypointNavStatus(nav_status);
99  return nav_status;
100  }
101  /** @}*/
102 
103  /** Returns `true` if, according to the information gathered at the last
104  * navigation step,
105  * there is a free path to the given point; `false` otherwise: if way is
106  * blocked or there is missing information,
107  * the point is out of range for the existing PTGs, etc. */
109  const mrpt::math::TPoint2D& wp_local_wrt_robot) const;
110 
112  {
113  /** In meters. <0: unlimited */
115  /** How many times shall a future waypoint be seen as reachable to skip
116  * to it (Default: 1) */
118  /** [rad] Angular error tolerance for waypoints with an assigned heading
119  * (Default: 5 deg) */
121  /** [0,1] Relative speed when aiming at a stop-point waypoint
122  * (Default=0.10) */
124  /** >=0 number of waypoints to forward to the underlying navigation
125  * engine, to ease obstacles avoidance when a waypoint is blocked
126  * (Default=0 : none). */
128 
129  virtual void loadFromConfigFile(
131  const std::string& s) override;
132  virtual void saveToConfigFile(
134  const std::string& s) const override;
136  };
137 
139 
140  virtual void loadConfigFile(const mrpt::utils::CConfigFileBase& c)
141  override; // See base class docs!
143  const override; // See base class docs!
144 
145  protected:
146  /** The latest waypoints navigation command and the up-to-date control
147  * status. */
149  std::recursive_mutex m_nav_waypoints_cs;
150 
151  /** Implements the way to waypoint is free function in children classes:
152  * `true` must be returned
153  * if, according to the information gathered at the last navigation step,
154  * there is a free path to
155  * the given point; `false` otherwise: if way is blocked or there is
156  * missing information, the point is out of range, etc. */
157  virtual bool impl_waypoint_is_reachable(
158  const mrpt::math::TPoint2D& wp_local_wrt_robot) const = 0;
159 
160  virtual void onStartNewNavigation() override;
161 
162  virtual void onNavigateCommandReceived() override;
163 
164  virtual bool checkHasReachedTarget(const double targetDist) const override;
165  /** The waypoints-specific part of navigationStep() */
166  virtual void waypoints_navigationStep();
167 
168  bool waypoints_isAligning() const { return m_is_aligning; }
169  private:
170  /** Whether the last timestep was "is_aligning" in a waypoint with heading
171  */
175 };
176 }
177 }
virtual void cancel() override
Cancel current navegation.
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:32
bool m_was_aligning
Whether the last timestep was "is_aligning" in a waypoint with heading.
TWaypointStatusSequence m_waypoint_nav_status
The latest waypoints navigation command and the up-to-date control status.
virtual void navigationStep() override
This method must be called periodically in order to effectively run the navigation.
std::vector< mrpt::nav::CAbstractNavigator::TargetInfo > multiple_targets
If not empty, this will prevail over the base class single goal target.
virtual void onStartNewNavigation() override
Called whenever a new navigation has been started.
double waypoint_angle_tolerance
[rad] Angular error tolerance for waypoints with an assigned heading (Default: 5 deg) ...
Base for all high-level navigation commands.
std::recursive_mutex m_nav_waypoints_cs
TWaypointsNavigatorParams params_waypoints_navigator
TWaypointStatusSequence getWaypointNavStatus() const
Get a copy of the control structure which describes the progress status of the waypoint navigation...
This class extends CAbstractNavigator with the capability of following a list of waypoints.
The struct for requesting navigation requests for a sequence of waypoints.
Definition: TWaypoint.h:87
GLdouble s
Definition: glext.h:3676
bool isRelativePointReachable(const mrpt::math::TPoint2D &wp_local_wrt_robot) const
Returns true if, according to the information gathered at the last navigation step, there is a free path to the given point; false otherwise: if way is blocked or there is missing information, the point is out of range for the existing PTGs, etc.
The struct for configuring navigation requests to CWaypointsNavigator and derived classes...
This class allows loading and storing values and vectors of different types from a configuration text...
The struct for configuring navigation requests.
const GLubyte * c
Definition: glext.h:6313
virtual void loadConfigFile(const mrpt::utils::CConfigFileBase &c) override
Loads all params from a file.
The struct for querying the status of waypoints navigation.
Definition: TWaypoint.h:134
mrpt::system::TTimeStamp m_last_alignment_cmd
virtual bool isEqual(const CAbstractNavigator::TNavigationParamsBase &o) const override
GLsizei const GLchar ** string
Definition: glext.h:4101
virtual bool checkHasReachedTarget(const double targetDist) const override
Default implementation: check if target_dist is below the accepted distance.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
virtual std::string getAsText() const override
Gets navigation params as a human-readable format.
int min_timesteps_confirm_skip_waypoints
How many times shall a future waypoint be seen as reachable to skip to it (Default: 1) ...
virtual void navigateWaypoints(const TWaypointSequence &nav_request)
Waypoint navigation request.
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...
virtual void onNavigateCommandReceived() override
Called after each call to CAbstractNavigator::navigate()
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const override
Saves all current options to a config file.
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
CWaypointsNavigator(CRobot2NavInterface &robot_interface_impl)
ctor
double rel_speed_for_stop_waypoints
[0,1] Relative speed when aiming at a stop-point waypoint (Default=0.10)
Lightweight 2D point.
This is the base class for any reactive/planned navigation system.
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.
virtual std::unique_ptr< TNavigationParams > clone() const override
virtual void waypoints_navigationStep()
The waypoints-specific part of navigationStep()
int multitarget_look_ahead
>=0 number of waypoints to forward to the underlying navigation engine, to ease obstacles avoidance w...
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. ...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019