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



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