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-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 #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::config::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 }
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
TWaypoint.h
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::waypoint_angle_tolerance
double waypoint_angle_tolerance
[rad] Angular error tolerance for waypoints with an assigned heading (Default: 5 deg)
Definition: CWaypointsNavigator.h:120
s
GLdouble s
Definition: glext.h:3676
mrpt::nav::CWaypointsNavigator::TNavigationParamsWaypoints::clone
virtual std::unique_ptr< TNavigationParams > clone() const override
Definition: CWaypointsNavigator.h:56
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,...
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::CWaypointsNavigator::m_last_alignment_cmd
mrpt::system::TTimeStamp m_last_alignment_cmd
Definition: CWaypointsNavigator.h:174
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::CWaypointsNavigator
This class extends CAbstractNavigator with the capability of following a list of waypoints.
Definition: CWaypointsNavigator.h:40
mrpt::system::TTimeStamp
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
Definition: datetime.h:31
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::CWaypointsNavigator::cancel
virtual void cancel() override
Cancel current navegation.
Definition: CWaypointsNavigator.cpp:105
mrpt::nav::CAbstractNavigator::TNavigationParams
The struct for configuring navigation requests.
Definition: CAbstractNavigator.h:118
mrpt::nav::CWaypointsNavigator::waypoints_isAligning
bool waypoints_isAligning() const
Definition: CWaypointsNavigator.h:168
mrpt::nav::CWaypointsNavigator::params_waypoints_navigator
TWaypointsNavigatorParams params_waypoints_navigator
Definition: CWaypointsNavigator.h:138
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::max_distance_to_allow_skip_waypoint
double max_distance_to_allow_skip_waypoint
In meters.
Definition: CWaypointsNavigator.h:114
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::config::CLoadableOptions
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Definition: config/CLoadableOptions.h:28
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
CAbstractNavigator.h
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::nav::CWaypointsNavigator::m_nav_waypoints_cs
std::recursive_mutex m_nav_waypoints_cs
Definition: CWaypointsNavigator.h:149
mrpt::nav::CWaypointsNavigator::TWaypointsNavigatorParams::TWaypointsNavigatorParams
TWaypointsNavigatorParams()
Definition: CWaypointsNavigator.cpp:537
mrpt::nav::CWaypointsNavigator::TNavigationParamsWaypoints::isEqual
virtual bool isEqual(const CAbstractNavigator::TNavigationParamsBase &o) const override
Definition: CWaypointsNavigator.cpp:35
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::CWaypointsNavigator::TNavigationParamsWaypoints::getAsText
virtual std::string getAsText() const override
Gets navigation params as a human-readable format.
Definition: CWaypointsNavigator.cpp:19
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
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::TWaypointsNavigatorParams
Definition: CWaypointsNavigator.h:111
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::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::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::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



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