YARP
Yet Another Robot Platform
INavigation2D.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef YARP_DEV_INAVIGATION2D_H
7 #define YARP_DEV_INAVIGATION2D_H
8 
9 #include <yarp/os/Vocab.h>
10 #include <yarp/dev/api.h>
12 #include <yarp/dev/Map2DLocation.h>
13 #include <yarp/dev/Map2DPath.h>
14 #include <yarp/dev/Map2DArea.h>
15 #include <yarp/dev/MapGrid2D.h>
16 #include <vector>
17 #include <limits>
18 #include <string>
19 
20 namespace yarp {
21  namespace dev {
22  namespace Nav2D
23  {
24  class INavigation2DTargetActions;
25  class INavigation2DControlActions;
26  class INavigation2D;
27 
29  {
40  };
41 
43  {
44  global_map = yarp::os::createVocab32('g', 'l', 'o', 'b'),
45  local_map = yarp::os::createVocab32('l', 'o', 'c', 'a')
46  };
47 
49  {
51  local_trajectory = yarp::os::createVocab32('l', 'o', 'c', 'a')
52  };
53 
54  namespace INavigation2DHelpers
55  {
56  //converts a string to a NavigationStatusEnum.
57  //navigation_status_error is returned if the string is not recognized.
59 
60  //converts a NavigationStatusEnum to a string.
62  }
63  }
64  }
65 }
66 
68 {
69 public:
74 
81 
88 
95  virtual bool gotoTargetByRelativeLocation(double x, double y) = 0;
96 
104  virtual bool gotoTargetByRelativeLocation(double x, double y, double theta) = 0;
105 
113  virtual bool getRelativeLocationOfCurrentTarget(double& x, double& y, double& theta) = 0;
114 
123  virtual bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout = 0.1) = 0;
124 };
125 
127 {
128 public:
133 
138  virtual bool getNavigationStatus(NavigationStatusEnum& status) = 0;
139 
144  virtual bool stopNavigation() = 0;
145 
151  virtual bool suspendNavigation(const double time_s= std::numeric_limits<double>::infinity()) = 0;
152 
157  virtual bool resumeNavigation() = 0;
158 
164  virtual bool recomputeCurrentNavigationPath() = 0;
165 
173 
180 
188 };
189 
198 {
199 public:
203  virtual ~INavigation2D() {}
204 
210  virtual bool gotoTargetByLocationName(std::string location_or_area_name) = 0;
211 
217  virtual bool checkInsideArea(std::string area_name) = 0;
218 
224  virtual bool checkInsideArea (Nav2D::Map2DArea area) = 0;
225 
233  virtual bool checkNearToLocation(Nav2D::Map2DLocation loc, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) = 0;
234 
242  virtual bool checkNearToLocation(std::string location_name, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) = 0;
243 
249  virtual bool getNameOfCurrentTarget(std::string& location_name) = 0;
250 
256  virtual bool storeCurrentPosition(std::string location_name) = 0;
257 
264  virtual bool storeLocation(std::string location_name, Nav2D::Map2DLocation loc) = 0;
265 
272  virtual bool getLocation(std::string location_name, Nav2D::Map2DLocation& loc) = 0;
273 
274 
281  virtual bool getArea(std::string area_name, Nav2D::Map2DArea& area) = 0;
282 
288  virtual bool getLocationsList(std::vector<std::string>& locations) = 0;
289 
295  virtual bool deleteLocation(std::string location_name) = 0;
296 
301  virtual bool clearAllLocations() = 0;
302 };
303 
310 
311 #endif // YARP_DEV_INAVIGATION2D_H
constexpr yarp::conf::vocab32_t VOCAB_NAV_RESUME
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_CURRENT_WAYPOINT
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_NAVIGATION_WAYPOINTS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_NAV_MAP
constexpr yarp::conf::vocab32_t VOCAB_NAV_STOP
constexpr yarp::conf::vocab32_t VOCAB_NAV_SUSPEND
contains the definition of a Map2DArea type
contains the definition of a Map2DLocation type
contains the definition of a Map2DPath type
contains the definition of a map type
ILocalization2D interface.
virtual bool recomputeCurrentNavigationPath()=0
Forces the navigation system to recompute the path from the current robot position to the current goa...
virtual bool getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath &waypoints)=0
Returns the list of waypoints generated by the navigation algorithm.
virtual bool getCurrentNavigationWaypoint(yarp::dev::Nav2D::Map2DLocation &curr_waypoint)=0
Returns the current waypoint pursued by the navigation algorithm.
virtual bool resumeNavigation()=0
Resume a previously suspended navigation task.
virtual bool getNavigationStatus(NavigationStatusEnum &status)=0
Gets the current status of the navigation task.
virtual bool stopNavigation()=0
Terminates the current navigation task.
virtual bool suspendNavigation(const double time_s=std::numeric_limits< double >::infinity())=0
Ask to the robot to suspend the current navigation task for a defined amount of time.
virtual bool getCurrentNavigationMap(yarp::dev::Nav2D::NavigationMapTypeEnum map_type, yarp::dev::Nav2D::MapGrid2D &map)=0
Returns the current navigation map processed by the navigation algorithm.
virtual bool gotoTargetByRelativeLocation(double x, double y)=0
Ask the robot to reach a position defined in the robot reference frame.
virtual bool gotoTargetByAbsoluteLocation(yarp::dev::Nav2D::Map2DLocation loc)=0
Ask the robot to reach a position defined in the world reference frame.
virtual bool getAbsoluteLocationOfCurrentTarget(yarp::dev::Nav2D::Map2DLocation &loc)=0
Gets the last navigation target in the world reference frame.
virtual bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout=0.1)=0
Apply a velocity command.
virtual bool gotoTargetByRelativeLocation(double x, double y, double theta)=0
Ask the robot to reach a position defined in the robot reference frame.
virtual bool getRelativeLocationOfCurrentTarget(double &x, double &y, double &theta)=0
Gets the last navigation target in the robot reference frame.
An interface to control the navigation of a mobile robot in a 2D environment.
virtual bool checkNearToLocation(Nav2D::Map2DLocation loc, double linear_tolerance, double angular_tolerance=std::numeric_limits< double >::infinity())=0
Check if the robot is currently near to the specified area.
virtual bool getLocation(std::string location_name, Nav2D::Map2DLocation &loc)=0
Retrieves a location previously stored by the user.
virtual bool storeCurrentPosition(std::string location_name)=0
Store the current location of the robot.
virtual ~INavigation2D()
Destructor.
virtual bool getNameOfCurrentTarget(std::string &location_name)=0
Gets the name of the current target, if available (set by gotoTargetByLocationName)
virtual bool gotoTargetByLocationName(std::string location_or_area_name)=0
Ask the robot to reach a previously stored location/area.
virtual bool checkInsideArea(Nav2D::Map2DArea area)=0
Check if the robot is currently inside the specified area.
virtual bool deleteLocation(std::string location_name)=0
Delete a location.
virtual bool getLocationsList(std::vector< std::string > &locations)=0
Get a list of all stored locations.
virtual bool clearAllLocations()=0
Delete all stored locations.
virtual bool storeLocation(std::string location_name, Nav2D::Map2DLocation loc)=0
Store a location specified by the user in the world reference frame.
virtual bool checkNearToLocation(std::string location_name, double linear_tolerance, double angular_tolerance=std::numeric_limits< double >::infinity())=0
Check if the robot is currently near to the specified area.
virtual bool getArea(std::string area_name, Nav2D::Map2DArea &area)=0
Retrieves an area previously stored by the user.
virtual bool checkInsideArea(std::string area_name)=0
Check if the robot is currently inside the specified area.
std::int32_t vocab32_t
Definition: numeric.h:78
std::string statusToString(NavigationStatusEnum status)
NavigationStatusEnum stringToStatus(std::string s)
@ navigation_status_preparing_before_move
Definition: INavigation2D.h:31
@ navigation_status_goal_reached
Definition: INavigation2D.h:34
@ navigation_status_waiting_obstacle
Definition: INavigation2D.h:33
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.
Definition: Vocab.h:28
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_dev_API
Definition: api.h:18