YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Navigation2D_nwc_yarp.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef YARP_DEV_NAVIGATION2D_NWC_YARP_H
7#define YARP_DEV_NAVIGATION2D_NWC_YARP_H
8
9#include <yarp/os/Network.h>
12#include <yarp/sig/Vector.h>
13#include <yarp/os/Time.h>
14#include <yarp/dev/PolyDriver.h>
16#include <yarp/dev/Map2DPath.h>
17#include "IMap2DMsgs.h"
18#include "ILocalization2DMsgs.h"
19#include "INavigation2DMsgs.h"
20
21#include <mutex>
22#include <string>
24
25#define DEFAULT_THREAD_PERIOD 20 //ms
26
27
43{
44protected:
45 //thrift stuff
49
50protected:
51 std::mutex m_mutex;
56
57public:
58
59 /* DeviceDriver methods */
60 bool open(yarp::os::Searchable& config) override;
61 bool close() override;
62
63 /* RPC responder */
65 virtual bool read(yarp::os::ConnectionReader& connection) override;
66
67 /* The following methods belong to INavigation2D interface */
68 // subcategory: INavigation2DExtraActions
70 bool checkInsideArea(std::string area_name) override;
71 bool checkNearToLocation(yarp::dev::Nav2D::Map2DLocation loc, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) override;
72 bool checkNearToLocation(std::string location_name, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) override;
73 bool storeCurrentPosition(std::string location_name) override;
74 // subcategory: INavigation2DControlActions
76 bool recomputeCurrentNavigationPath() override;
77 bool stopNavigation() override;
78 bool suspendNavigation(const double time_s) override;
79 bool resumeNavigation() override;
83 // subcategory: INavigation2DTargetActions
85 bool gotoTargetByLocationName(std::string location_name) override;
86 bool gotoTargetByRelativeLocation(double x, double y, double theta) override;
87 bool gotoTargetByRelativeLocation(double x, double y) override;
88 bool followPath(const yarp::dev::Nav2D::Map2DPath& locs) override;
90 bool getNameOfCurrentTarget(std::string& location_name) override;
91 bool getRelativeLocationOfCurrentTarget(double& x, double& y, double& theta) override;
92 // subcategory: INavigation2DVelocityActions
93 bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout = 0.1) override;
94 bool getLastVelocityCommand(double& x_vel, double& y_vel, double& theta_vel) override;
95
96 /* The following methods belong to INavigation2D, inherited from ILocalization2D interface */
99 bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc) override;
101 bool getEstimatedPoses(std::vector<yarp::dev::Nav2D::Map2DLocation>& poses) override;
102 bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc, const yarp::sig::Matrix& cov) override;
104 bool startLocalizationService() override;
105 bool stopLocalizationService() override;
106
107 /* The following methods belong to INavigation2D, inherited from IMap2D interface */
108 bool storeLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation loc) override;
109 bool storeArea(std::string location_name, yarp::dev::Nav2D::Map2DArea area) override;
110 bool storePath(std::string path_name, yarp::dev::Nav2D::Map2DPath path) override;
111
112 bool getLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation& loc) override;
113 bool getArea(std::string location_name, yarp::dev::Nav2D::Map2DArea& area) override;
114 bool getPath(std::string path_name, yarp::dev::Nav2D::Map2DPath& path) override;
115
116 bool renameLocation(std::string original_name, std::string new_name) override;
117 bool renameArea(std::string original_name, std::string new_name) override;
118 bool renamePath(std::string original_name, std::string new_name) override;
119
120 bool deleteLocation(std::string location_name) override;
121 bool deleteArea(std::string location_name) override;
122 bool deletePath(std::string path_name) override;
123
124 bool getLocationsList(std::vector<std::string>& locations) override;
125 bool getAreasList(std::vector<std::string>& locations) override;
126 bool getPathsList(std::vector<std::string>& paths) override;
127
128 bool getAllLocations(std::vector<yarp::dev::Nav2D::Map2DLocation>& locations) override;
129 bool getAllAreas(std::vector<yarp::dev::Nav2D::Map2DArea>& areas) override;
130 bool getAllPaths(std::vector<yarp::dev::Nav2D::Map2DPath>& paths) override;
131
132 bool clearAllLocations() override;
133 bool clearAllAreas() override;
134 bool clearAllPaths() override;
135
136 bool clearAllMaps() override;
137 bool remove_map(std::string map_name) override;
138 bool store_map(const yarp::dev::Nav2D::MapGrid2D& map) override;
139 bool get_map(std::string map_name, yarp::dev::Nav2D::MapGrid2D& map) override;
140 bool get_map_names(std::vector<std::string>& map_names) override;
141
142 bool clearAllMapsTemporaryFlags() override;
143 bool clearMapTemporaryFlags(std::string map_name) override;
144
145 bool saveMapsCollection(std::string maps_collection_file) override;
146 bool loadMapsCollection(std::string maps_collection_file) override;
147 bool saveLocationsAndExtras(std::string locations_collection_file) override;
148 bool loadLocationsAndExtras(std::string locations_collection_file) override;
149
150 bool saveMapToDisk(std::string map_name, std::string file_name) override;
151 bool loadMapFromDisk(std::string file_name) override;
152
153 bool enableMapsCompression(bool enable) override;
154};
155
156#endif // YARP_DEV_NAVIGATION2D_NWC_YARP_H
define control board standard interfaces
contains the definition of a Map2DPath type
contains the definition of a Vector type
This class is the parameters parser for class Navigation2D_nwc_yarp.
navigation2D_nwc_yarp: A device which allows a client application to perform navigation tasks,...
yarp::os::Port m_rpc_port_user_commands
bool gotoTargetByRelativeLocation(double x, double y, double theta) override
Ask the robot to reach a position defined in the robot reference frame.
bool getLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation &loc) override
Retrieves a location specified by the user in the world reference frame.
bool getPathsList(std::vector< std::string > &paths) override
Get a list of the names of all stored paths.
bool store_map(const yarp::dev::Nav2D::MapGrid2D &map) override
Stores a map into the map server.
bool storePath(std::string path_name, yarp::dev::Nav2D::Map2DPath path) override
Store a path.
bool loadLocationsAndExtras(std::string locations_collection_file) override
Load a collection of locations/areas/paths etc from disk.
bool renameLocation(std::string original_name, std::string new_name) override
Searches for a location and renames it.
bool loadMapsCollection(std::string maps_collection_file) override
Load a collection of maps from disk.
bool enableMapsCompression(bool enable) override
99999999999
bool getPath(std::string path_name, yarp::dev::Nav2D::Map2DPath &path) override
Retrieves a path.
bool startLocalizationService() override
Starts the localization service.
bool remove_map(std::string map_name) override
Removes a map from the map server.
bool recomputeCurrentNavigationPath() override
Forces the navigation system to recompute the path from the current robot position to the current goa...
bool stopNavigation() override
Terminates the current navigation task.
bool getAbsoluteLocationOfCurrentTarget(yarp::dev::Nav2D::Map2DLocation &loc) override
Gets the last navigation target in the world reference frame.
bool getAllLocations(std::vector< yarp::dev::Nav2D::Map2DLocation > &locations) override
Get a list of all stored locations.
bool getLocationsList(std::vector< std::string > &locations) override
Get a list of the names of all stored locations.
bool getAreasList(std::vector< std::string > &locations) override
Get a list of the names of all stored areas.
bool gotoTargetByAbsoluteLocation(yarp::dev::Nav2D::Map2DLocation loc) override
Ask the robot to reach a position defined in the world reference frame.
bool parse_respond_string(const yarp::os::Bottle &command, yarp::os::Bottle &reply)
bool renameArea(std::string original_name, std::string new_name) override
Searches for an area and renames it.
bool storeLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation loc) override
Store a location specified by the user in the world reference frame.
ILocalization2DMsgs m_loc_RPC
bool get_map_names(std::vector< std::string > &map_names) override
Gets a list containing the names of all registered maps.
bool clearAllPaths() override
Delete all stored paths.
bool deletePath(std::string path_name) override
Delete a path.
bool gotoTargetByLocationName(std::string location_name) override
Ask the robot to reach a previously stored location/area.
bool getAllAreas(std::vector< yarp::dev::Nav2D::Map2DArea > &areas) override
Get a list of all stored areas.
bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout=0.1) override
Apply a velocity command.
yarp::os::Port m_rpc_port_to_localization_server
bool renamePath(std::string original_name, std::string new_name) override
Searches for a path and renames it.
bool checkInsideArea(yarp::dev::Nav2D::Map2DArea area) override
Check if the robot is currently inside the specified area.
bool saveLocationsAndExtras(std::string locations_collection_file) override
Save a collection of locations/area/paths etc to disk.
bool clearMapTemporaryFlags(std::string map_name) override
Clear all temporary flags from a specific map.
bool getAllPaths(std::vector< yarp::dev::Nav2D::Map2DPath > &paths) override
Get a list of all stored paths.
bool getNavigationStatus(yarp::dev::Nav2D::NavigationStatusEnum &status) override
Gets the current status of the navigation task.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool getCurrentNavigationWaypoint(yarp::dev::Nav2D::Map2DLocation &curr_waypoint) override
Returns the current waypoint pursued by the navigation algorithm.
bool resumeNavigation() override
Resume a previously suspended navigation task.
bool getNameOfCurrentTarget(std::string &location_name) override
Gets the name of the current target, if available (set by gotoTargetByLocationName)
bool deleteLocation(std::string location_name) override
Delete a location.
bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation &loc) override
Sets the initial pose for the localization algorithm which estimates the current position of the robo...
bool saveMapsCollection(std::string maps_collection_file) override
Save a collection of maps to disk.
bool loadMapFromDisk(std::string file_name) override
Load a map from disk.
bool getCurrentPosition(yarp::dev::Nav2D::Map2DLocation &loc) override
Gets the current position of the robot w.r.t world reference frame.
bool getEstimatedOdometry(yarp::dev::OdometryData &odom) override
Gets the estimated odometry the robot, including its velocity expressed in the world and in the local...
bool deleteArea(std::string location_name) override
Delete an area.
bool suspendNavigation(const double time_s) override
Ask to the robot to suspend the current navigation task for a defined amount of time.
bool getLocalizationStatus(yarp::dev::Nav2D::LocalizationStatusEnum &status) override
Gets the current status of the localization task.
virtual bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool saveMapToDisk(std::string map_name, std::string file_name) override
Save a map to disk.
bool storeArea(std::string location_name, yarp::dev::Nav2D::Map2DArea area) override
Store an area.
bool getCurrentNavigationMap(yarp::dev::Nav2D::NavigationMapTypeEnum map_type, yarp::dev::Nav2D::MapGrid2D &map) override
Returns the current navigation map processed by the navigation algorithm.
bool getAllNavigationWaypoints(yarp::dev::Nav2D::TrajectoryTypeEnum trajectory_type, yarp::dev::Nav2D::Map2DPath &waypoints) override
Returns the list of waypoints generated by the navigation algorithm.
bool storeCurrentPosition(std::string location_name) override
Store the current location of the robot.
bool checkNearToLocation(yarp::dev::Nav2D::Map2DLocation loc, double linear_tolerance, double angular_tolerance=std::numeric_limits< double >::infinity()) override
Check if the robot is currently near to the specified area.
bool getEstimatedPoses(std::vector< yarp::dev::Nav2D::Map2DLocation > &poses) override
Gets a set of pose estimates computed by the localization algorithm.
yarp::os::Port m_rpc_port_to_Map2DServer
bool clearAllAreas() override
Delete all stored areas.
bool clearAllLocations() override
Delete all stored locations.
bool getLastVelocityCommand(double &x_vel, double &y_vel, double &theta_vel) override
Returns the last applied velocity command.
bool stopLocalizationService() override
Stops the localization service.
bool clearAllMapsTemporaryFlags() override
Clear all temporary flags from all stored maps.
bool getRelativeLocationOfCurrentTarget(double &x, double &y, double &theta) override
Gets the last navigation target in the robot reference frame.
bool get_map(std::string map_name, yarp::dev::Nav2D::MapGrid2D &map) override
Gets a map from the map server.
bool getArea(std::string location_name, yarp::dev::Nav2D::Map2DArea &area) override
Retrieves an area.
yarp::os::Port m_rpc_port_to_navigation_server
bool clearAllMaps() override
Removes all the registered maps from the server.
bool followPath(const yarp::dev::Nav2D::Map2DPath &locs) override
Ask the robot to navigate through a set of locations defined in the world reference frame.
Interface implemented by all device drivers.
An interface to control the navigation of a mobile robot in a 2D environment.
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
An interface for reading from a network connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
A mini-server for network communication.
Definition Port.h:46
A base class for nested structures that can be searched.
Definition Searchable.h:31
A class for a Matrix.
Definition Matrix.h:39