YARP
Yet Another Robot Platform
INavigation2D.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_DEV_INAVIGATION2D_H
10 #define YARP_DEV_INAVIGATION2D_H
11 
12 #include <yarp/os/Vocab.h>
13 #include <yarp/dev/api.h>
15 #include <yarp/dev/Map2DLocation.h>
16 #include <yarp/dev/Map2DPath.h>
17 #include <yarp/dev/Map2DArea.h>
18 #include <yarp/dev/MapGrid2D.h>
19 #include <vector>
20 #include <limits>
21 #include <string>
22 
23 namespace yarp {
24  namespace dev {
25  namespace Nav2D
26  {
27  class INavigation2DTargetActions;
28  class INavigation2DControlActions;
29  class INavigation2D;
30 
32  {
43  };
44 
46  {
47  global_map = yarp::os::createVocab('g', 'l', 'o', 'b'),
48  local_map = yarp::os::createVocab('l', 'o', 'c', 'a')
49  };
50 
52  {
54  local_trajectory = yarp::os::createVocab('l', 'o', 'c', 'a')
55  };
56 
57  namespace INavigation2DHelpers
58  {
59  //converts a string to a NavigationStatusEnum.
60  //navigation_status_error is returned if the string is not recognized.
62 
63  //converts a NavigationStatusEnum to a string.
65  }
66  }
67  }
68 }
69 
71 {
72 public:
77 
84 
91 
98  virtual bool gotoTargetByRelativeLocation(double x, double y) = 0;
99 
107  virtual bool gotoTargetByRelativeLocation(double x, double y, double theta) = 0;
108 
116  virtual bool getRelativeLocationOfCurrentTarget(double& x, double& y, double& theta) = 0;
117 
126  virtual bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout = 0.1) = 0;
127 };
128 
130 {
131 public:
136 
141  virtual bool getNavigationStatus(NavigationStatusEnum& status) = 0;
142 
147  virtual bool stopNavigation() = 0;
148 
154  virtual bool suspendNavigation(const double time_s= std::numeric_limits<double>::infinity()) = 0;
155 
160  virtual bool resumeNavigation() = 0;
161 
167  virtual bool recomputeCurrentNavigationPath() = 0;
168 
176 
183 
191 };
192 
201 {
202 public:
206  virtual ~INavigation2D() {}
207 
213  virtual bool gotoTargetByLocationName(std::string location_or_area_name) = 0;
214 
220  virtual bool checkInsideArea(std::string area_name) = 0;
221 
227  virtual bool checkInsideArea (Nav2D::Map2DArea area) = 0;
228 
236  virtual bool checkNearToLocation(Nav2D::Map2DLocation loc, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) = 0;
237 
245  virtual bool checkNearToLocation(std::string location_name, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) = 0;
246 
252  virtual bool getNameOfCurrentTarget(std::string& location_name) = 0;
253 
259  virtual bool storeCurrentPosition(std::string location_name) = 0;
260 
267  virtual bool storeLocation(std::string location_name, Nav2D::Map2DLocation loc) = 0;
268 
275  virtual bool getLocation(std::string location_name, Nav2D::Map2DLocation& loc) = 0;
276 
277 
284  virtual bool getArea(std::string area_name, Nav2D::Map2DArea& area) = 0;
285 
291  virtual bool getLocationsList(std::vector<std::string>& locations) = 0;
292 
298  virtual bool deleteLocation(std::string location_name) = 0;
299 
304  virtual bool clearAllLocations() = 0;
305 };
306 
313 
314 #endif // YARP_DEV_INAVIGATION2D_H
yarp::dev::Nav2D::INavigation2D::clearAllLocations
virtual bool clearAllLocations()=0
Delete all stored locations.
yarp::dev::Nav2D::INavigation2D::checkNearToLocation
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.
MapGrid2D.h
contains the definition of a map type
yarp::os::createVocab
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
yarp::dev::Nav2D::navigation_status_thinking
@ navigation_status_thinking
Definition: INavigation2D.h:41
Map2DArea.h
contains the definition of a Map2DArea type
yarp::dev::Nav2D::INavigation2DTargetActions::applyVelocityCommand
virtual bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout=0.1)=0
Apply a velocity command.
yarp::dev::Nav2D::global_map
@ global_map
Definition: INavigation2D.h:47
yarp::dev::Nav2D::INavigation2D::gotoTargetByLocationName
virtual bool gotoTargetByLocationName(std::string location_or_area_name)=0
Ask the robot to reach a previously stored location/area.
yarp::dev::Nav2D::INavigation2D::storeLocation
virtual bool storeLocation(std::string location_name, Nav2D::Map2DLocation loc)=0
Store a location specified by the user in the world reference frame.
VOCAB_NAV_SUSPEND
constexpr yarp::conf::vocab32_t VOCAB_NAV_SUSPEND
Definition: INavigation2D.h:308
yarp::dev::Nav2D::INavigation2DTargetActions
Definition: INavigation2D.h:71
yarp::dev::Nav2D::INavigation2DControlActions::resumeNavigation
virtual bool resumeNavigation()=0
Resume a previously suspended navigation task.
yarp::dev::Nav2D::ILocalization2D
ILocalization2D interface.
Definition: ILocalization2D.h:40
yarp::dev::Nav2D::TrajectoryTypeEnum
TrajectoryTypeEnum
Definition: INavigation2D.h:52
yarp::dev::Nav2D::INavigation2D
An interface to control the navigation of a mobile robot in a 2D environment.
Definition: INavigation2D.h:201
VOCAB_NAV_GET_CURRENT_WAYPOINT
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_CURRENT_WAYPOINT
Definition: INavigation2D.h:311
yarp::dev::Nav2D::INavigation2D::checkInsideArea
virtual bool checkInsideArea(Nav2D::Map2DArea area)=0
Check if the robot is currently inside the specified area.
yarp::dev::Nav2D::NavigationStatusEnum
NavigationStatusEnum
Definition: INavigation2D.h:32
yarp::dev::Nav2D::global_trajectory
@ global_trajectory
Definition: INavigation2D.h:53
yarp::dev::Nav2D::local_trajectory
@ local_trajectory
Definition: INavigation2D.h:54
yarp::dev::Nav2D::INavigation2DTargetActions::getAbsoluteLocationOfCurrentTarget
virtual bool getAbsoluteLocationOfCurrentTarget(yarp::dev::Nav2D::Map2DLocation &loc)=0
Gets the last navigation target in the world reference frame.
yarp::dev::Nav2D::INavigation2DControlActions::stopNavigation
virtual bool stopNavigation()=0
Terminates the current navigation task.
yarp::dev::Nav2D::navigation_status_paused
@ navigation_status_paused
Definition: INavigation2D.h:40
VOCAB_NAV_GET_NAVIGATION_WAYPOINTS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_NAVIGATION_WAYPOINTS
Definition: INavigation2D.h:310
VOCAB_NAV_GET_NAV_MAP
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_NAV_MAP
Definition: INavigation2D.h:312
yarp::dev::Nav2D::INavigation2D::~INavigation2D
virtual ~INavigation2D()
Destructor.
Definition: INavigation2D.h:206
yarp::dev::Nav2D::INavigation2DTargetActions::gotoTargetByRelativeLocation
virtual bool gotoTargetByRelativeLocation(double x, double y)=0
Ask the robot to reach a position defined in the robot reference frame.
yarp::dev::Nav2D::MapGrid2D
Definition: MapGrid2D.h:32
yarp::dev::Nav2D::INavigation2DControlActions::getNavigationStatus
virtual bool getNavigationStatus(NavigationStatusEnum &status)=0
Gets the current status of the navigation task.
yarp::dev::Nav2D::INavigation2D::storeCurrentPosition
virtual bool storeCurrentPosition(std::string location_name)=0
Store the current location of the robot.
yarp::dev::Nav2D::INavigation2DTargetActions::~INavigation2DTargetActions
virtual ~INavigation2DTargetActions()
Destructor.
Definition: INavigation2D.h:76
yarp::dev::Nav2D::INavigation2DControlActions::suspendNavigation
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.
yarp::dev::Nav2D::INavigation2DTargetActions::gotoTargetByRelativeLocation
virtual bool gotoTargetByRelativeLocation(double x, double y, double theta)=0
Ask the robot to reach a position defined in the robot reference frame.
Map2DLocation.h
contains the definition of a Map2DLocation type
yarp::dev::Nav2D::INavigation2DHelpers::stringToStatus
NavigationStatusEnum stringToStatus(std::string s)
Definition: INavigation2D.cpp:26
yarp::dev::Nav2D::navigation_status_moving
@ navigation_status_moving
Definition: INavigation2D.h:35
yarp::dev::Nav2D::navigation_status_failing
@ navigation_status_failing
Definition: INavigation2D.h:39
yarp::dev::Nav2D::navigation_status_goal_reached
@ navigation_status_goal_reached
Definition: INavigation2D.h:37
yarp::dev::Nav2D::navigation_status_idle
@ navigation_status_idle
Definition: INavigation2D.h:33
yarp::dev::Nav2D::Map2DPath
Definition: Map2DPath.h:27
YARP_dev_API
#define YARP_dev_API
Definition: api.h:19
ILocalization2D.h
yarp::dev::Nav2D::navigation_status_aborted
@ navigation_status_aborted
Definition: INavigation2D.h:38
yarp::dev::Nav2D::Map2DLocation
Definition: Map2DLocation.h:30
yarp::dev::Nav2D::INavigation2DTargetActions::gotoTargetByAbsoluteLocation
virtual bool gotoTargetByAbsoluteLocation(yarp::dev::Nav2D::Map2DLocation loc)=0
Ask the robot to reach a position defined in the world reference frame.
yarp::dev::Nav2D::INavigation2D::getNameOfCurrentTarget
virtual bool getNameOfCurrentTarget(std::string &location_name)=0
Gets the name of the current target, if available (set by gotoTargetByLocationName)
yarp::dev::Nav2D::INavigation2DControlActions
Definition: INavigation2D.h:130
Map2DPath.h
contains the definition of a Map2DPath type
yarp::dev::Nav2D::INavigation2D::checkNearToLocation
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.
yarp::dev::Nav2D::navigation_status_waiting_obstacle
@ navigation_status_waiting_obstacle
Definition: INavigation2D.h:36
VOCAB_NAV_RESUME
constexpr yarp::conf::vocab32_t VOCAB_NAV_RESUME
Definition: INavigation2D.h:309
yarp::dev::Nav2D::local_map
@ local_map
Definition: INavigation2D.h:48
yarp::dev::Nav2D::INavigation2D::getLocationsList
virtual bool getLocationsList(std::vector< std::string > &locations)=0
Get a list of all stored locations.
yarp::dev::Nav2D::NavigationMapTypeEnum
NavigationMapTypeEnum
Definition: INavigation2D.h:46
yarp::dev::Nav2D::INavigation2DControlActions::getAllNavigationWaypoints
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.
yarp::dev::Nav2D::INavigation2DHelpers::statusToString
std::string statusToString(NavigationStatusEnum status)
Definition: INavigation2D.cpp:11
VOCAB_NAV_STOP
constexpr yarp::conf::vocab32_t VOCAB_NAV_STOP
Definition: INavigation2D.h:307
yarp::dev::Nav2D::INavigation2DTargetActions::getRelativeLocationOfCurrentTarget
virtual bool getRelativeLocationOfCurrentTarget(double &x, double &y, double &theta)=0
Gets the last navigation target in the robot reference frame.
yarp::dev::Nav2D::INavigation2D::checkInsideArea
virtual bool checkInsideArea(std::string area_name)=0
Check if the robot is currently inside the specified area.
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::conf::vocab32_t
std::int32_t vocab32_t
Definition: numeric.h:52
Vocab.h
yarp::dev::Nav2D::INavigation2DControlActions::getCurrentNavigationWaypoint
virtual bool getCurrentNavigationWaypoint(yarp::dev::Nav2D::Map2DLocation &curr_waypoint)=0
Returns the current waypoint pursued by the navigation algorithm.
yarp::dev::Nav2D::navigation_status_error
@ navigation_status_error
Definition: INavigation2D.h:42
yarp::dev::Nav2D::Map2DArea
Definition: Map2DArea.h:30
yarp::dev::Nav2D::INavigation2DControlActions::recomputeCurrentNavigationPath
virtual bool recomputeCurrentNavigationPath()=0
Forces the navigation system to recompute the path from the current robot position to the current goa...
yarp::dev::Nav2D::INavigation2DControlActions::getCurrentNavigationMap
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.
yarp::dev::Nav2D::INavigation2D::deleteLocation
virtual bool deleteLocation(std::string location_name)=0
Delete a location.
api.h
yarp::dev::Nav2D::INavigation2D::getLocation
virtual bool getLocation(std::string location_name, Nav2D::Map2DLocation &loc)=0
Retrieves a location previously stored by the user.
yarp::dev::Nav2D::INavigation2DControlActions::~INavigation2DControlActions
virtual ~INavigation2DControlActions()
Destructor.
Definition: INavigation2D.h:135
yarp::dev::Nav2D::navigation_status_preparing_before_move
@ navigation_status_preparing_before_move
Definition: INavigation2D.h:34
yarp::dev::Nav2D::INavigation2D::getArea
virtual bool getArea(std::string area_name, Nav2D::Map2DArea &area)=0
Retrieves an area previously stored by the user.