MRPT  1.9.9
CRobot2NavInterface.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 
12 #include <mrpt/obs/obs_frwds.h> // CSimplePointsMap
13 #include <mrpt/system/CTicTac.h>
15 #include <mrpt/system/datetime.h>
17 
18 namespace mrpt::nav
19 {
20 /** The pure virtual interface between a real or simulated robot and any
21  * `CAbstractNavigator`-derived class.
22  *
23  * The user must define a new class derived from `CRobot2NavInterface` and
24  * reimplement
25  * all pure virtual and the desired virtual methods according to the
26  * documentation in this class.
27  *
28  * [New in MRPT 1.5.0] This class does not make assumptions about the kinematic
29  * model of the robot, so it can work with either
30  * Ackermann, differential-driven or holonomic robots. It will depend on the
31  * used PTGs, so checkout
32  * each PTG documentation for the lenght and meaning of velocity commands.
33  *
34  * If used for a simulator, users may prefer to inherit from one of these
35  * classes, which already provide partial implementations:
36  * - mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven
37  * - mrpt::nav::CRobot2NavInterfaceForSimulator_Holo
38  *
39  * \sa CReactiveNavigationSystem, CAbstractNavigator
40  * \ingroup nav_reactive
41  */
43 {
44  public:
46  virtual ~CRobot2NavInterface();
47 
48  /** Get the current pose and velocity of the robot. The implementation
49  * should not take too much time to return,
50  * so if it might take more than ~10ms to ask the robot for the
51  * instantaneous data, it may be good enough to
52  * return the latest values from a cache which is updated in a parallel
53  * thread.
54  * \return false on any error retrieving these values from the robot.
55  * \callergraph */
56  virtual bool getCurrentPoseAndSpeeds(
57  /** (output) The latest robot pose (typically from a
58  mapping/localization module), in world coordinates. (x,y: meters,
59  phi: radians) */
60  mrpt::math::TPose2D& curPose,
61  /** (output) The latest robot velocity vector, in world coordinates.
62  (vx,vy: m/s, omega: rad/s) */
63  mrpt::math::TTwist2D& curVelGlobal,
64  /** (output) The timestamp for the read pose and velocity values. Use
65  mrpt::system::now() unless you have something more accurate. */
66  mrpt::system::TTimeStamp& timestamp,
67  /** (output) The latest robot raw odometry pose; may have long-time
68  drift should be more locally consistent than curPose (x,y: meters,
69  phi: radians) */
70  mrpt::math::TPose2D& curOdometry,
71  /** (output) ID of the coordinate frame for curPose. Default is not
72  modified is "map". [Only for future support to submapping,etc.] */
73  std::string& frame_id) = 0;
74 
75  /** Sends a velocity command to the robot.
76  * The number components in each command depends on children classes of
77  * mrpt::kinematics::CVehicleVelCmd.
78  * One robot may accept one or more different CVehicleVelCmd classes.
79  * This method resets the watchdog timer (that may be or may be not
80  * implemented in a particular robotic platform) started with
81  * startWatchdog()
82  * \return false on any error.
83  * \sa startWatchdog
84  * \callergraph
85  */
86  virtual bool changeSpeeds(
87  const mrpt::kinematics::CVehicleVelCmd& vel_cmd) = 0;
88 
89  /** Just like changeSpeeds(), but will be called when the last velocity
90  * command is still the preferred solution,
91  * so there is no need to change that past command. The unique effect of
92  * this callback would be resetting the watchdog timer.
93  * \return false on any error.
94  * \sa changeSpeeds(), startWatchdog()
95  * \callergraph */
96  virtual bool changeSpeedsNOP();
97 
98  /** Stop the robot right now.
99  * \param[in] isEmergencyStop true if stop is due to some unexpected error.
100  * false if "stop" happens as part of a normal operation (e.g. target
101  * reached).
102  * \return false on any error.
103  */
104  virtual bool stop(bool isEmergencyStop = true) = 0;
105 
106  /** Gets the emergency stop command for the current robot
107  * \return the emergency stop command
108  */
110 
111  /** Gets the emergency stop command for the current robot
112  * \return the emergency stop command
113  */
115 
116  /** Gets a motion command to make the robot to align with a given *relative*
117  * heading, without translating.
118  * Only for circular robots that can rotate in place; otherwise, return an
119  * empty smart pointer to indicate
120  * that the operation is not possible (this is what the default
121  * implementation does). */
123  const double relative_heading_radians);
124 
125  /** Start the watchdog timer of the robot platform, if any, for maximum
126  * expected delay between consecutive calls to changeSpeeds().
127  * \param T_ms Period, in ms.
128  * \return false on any error. */
129  virtual bool startWatchdog(float T_ms);
130 
131  /** Stop the watchdog timer.
132  * \return false on any error. \sa startWatchdog */
133  virtual bool stopWatchdog();
134 
135  /** Return the current set of obstacle points, as seen from the local
136  * coordinate frame of the robot.
137  * \return false on any error.
138  * \param[out] obstacles A representation of obstacles in robot-centric
139  * coordinates.
140  * \param[out] timestamp The timestamp for the read obstacles. Use
141  * mrpt::system::now() unless you have something more accurate.
142  */
143  virtual bool senseObstacles(
144  mrpt::maps::CSimplePointsMap& obstacles,
145  mrpt::system::TTimeStamp& timestamp) = 0;
146 
147  /** @name Navigation event callbacks
148  * @{ */
149  /** Callback: Start of navigation command */
150  virtual void sendNavigationStartEvent();
151 
152  /** Callback: End of navigation command (reach of single goal, or final
153  * waypoint of waypoint list) */
154  virtual void sendNavigationEndEvent();
155 
156  /** Callback: Reached an intermediary waypoint in waypoint list navigation.
157  * reached_nSkipped will be `true` if the waypoint was physically reached;
158  * `false` if it was actually "skipped".
159  */
160  virtual void sendWaypointReachedEvent(
161  int waypoint_index, bool reached_nSkipped);
162 
163  /** Callback: Heading towards a new intermediary/final waypoint in waypoint
164  * list navigation */
165  virtual void sendNewWaypointTargetEvent(int waypoint_index);
166 
167  /** Callback: Error asking sensory data from robot or sending motor
168  * commands. */
169  virtual void sendNavigationEndDueToErrorEvent();
170 
171  /** Callback: No progression made towards target for a predefined period of
172  * time. */
173  virtual void sendWaySeemsBlockedEvent();
174 
175  /** Callback: Apparent collision event (i.e. there is at least one obstacle
176  * point inside the robot shape) */
177  virtual void sendApparentCollisionEvent();
178 
179  /** Callback: Target seems to be blocked by an obstacle. */
181 
182  /** @} */
183 
184  /** Returns the number of seconds ellapsed since the constructor of this
185  * class was invoked, or since
186  * the last call of resetNavigationTimer(). This will be normally
187  * wall-clock time, except in simulators where this method will return
188  * simulation time. */
189  virtual double getNavigationTime();
190  /** see getNavigationTime() */
191  virtual void resetNavigationTimer();
192 
193  private:
194  /** For getNavigationTime */
196 };
197 }
198 
virtual bool stop(bool isEmergencyStop=true)=0
Stop the robot right now.
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.
virtual bool senseObstacles(mrpt::maps::CSimplePointsMap &obstacles, mrpt::system::TTimeStamp &timestamp)=0
Return the current set of obstacle points, as seen from the local coordinate frame of the robot...
mrpt::system::CTicTac m_navtime
For getNavigationTime.
virtual bool stopWatchdog()
Stop the watchdog timer.
virtual void resetNavigationTimer()
see getNavigationTime()
A high-performance stopwatch, with typical resolution of nanoseconds.
virtual void sendNavigationEndEvent()
Callback: End of navigation command (reach of single goal, or final waypoint of waypoint list) ...
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
virtual double getNavigationTime()
Returns the number of seconds ellapsed since the constructor of this class was invoked, or since the last call of resetNavigationTimer().
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...
virtual void sendCannotGetCloserToBlockedTargetEvent()
Callback: Target seems to be blocked by an obstacle.
Virtual base for velocity commands of different kinematic models of planar mobile robot...
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
virtual void sendNavigationStartEvent()
Callback: Start of navigation command.
virtual void sendNavigationEndDueToErrorEvent()
Callback: Error asking sensory data from robot or sending motor commands.
Versatile class for consistent logging and management of output messages.
virtual void sendApparentCollisionEvent()
Callback: Apparent collision event (i.e.
GLsizei const GLchar ** string
Definition: glext.h:4101
virtual void sendWaySeemsBlockedEvent()
Callback: No progression made towards target for a predefined period of time.
virtual mrpt::kinematics::CVehicleVelCmd::Ptr getEmergencyStopCmd()=0
Gets the emergency stop command for the current robot.
virtual void sendWaypointReachedEvent(int waypoint_index, bool reached_nSkipped)
Callback: Reached an intermediary waypoint in waypoint list navigation.
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...
Lightweight 2D pose.
virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd)=0
Sends a velocity command to the robot.
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
virtual mrpt::kinematics::CVehicleVelCmd::Ptr getStopCmd()=0
Gets the emergency stop command for the current robot.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020