YARP
Yet Another Robot Platform
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 "IMap2DMsgs.h"
17#include "ILocalization2DMsgs.h"
18#include "INavigation2DMsgs.h"
19
20#include <mutex>
21#include <string>
22
23#define DEFAULT_THREAD_PERIOD 20 //ms
24
25
46{
47protected:
48 //thrift stuff
52
53protected:
54 std::mutex m_mutex;
59 std::string m_local_name;
64
65public:
66
67 /* DeviceDriver methods */
68 bool open(yarp::os::Searchable& config) override;
69 bool close() override;
70
71 /* RPC responder */
73 virtual bool read(yarp::os::ConnectionReader& connection) override;
74
75 /* The following methods belong to INavigation2D interface */
76 // subcategory: INavigation2DExtraActions
78 bool checkInsideArea(std::string area_name) override;
79 bool checkNearToLocation(yarp::dev::Nav2D::Map2DLocation loc, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) override;
80 bool checkNearToLocation(std::string location_name, double linear_tolerance, double angular_tolerance = std::numeric_limits<double>::infinity()) override;
81 bool storeCurrentPosition(std::string location_name) override;
82 // subcategory: INavigation2DControlActions
84 bool recomputeCurrentNavigationPath() override;
85 bool stopNavigation() override;
86 bool suspendNavigation(const double time_s) override;
87 bool resumeNavigation() override;
91 // subcategory: INavigation2DTargetActions
93 bool gotoTargetByLocationName(std::string location_name) override;
94 bool gotoTargetByRelativeLocation(double x, double y, double theta) override;
95 bool gotoTargetByRelativeLocation(double x, double y) override;
97 bool getNameOfCurrentTarget(std::string& location_name) override;
98 bool getRelativeLocationOfCurrentTarget(double& x, double& y, double& theta) override;
99 // subcategory: INavigation2DVelocityActions
100 bool applyVelocityCommand(double x_vel, double y_vel, double theta_vel, double timeout = 0.1) override;
101 bool getLastVelocityCommand(double& x_vel, double& y_vel, double& theta_vel) override;
102
103 /* The following methods belong to INavigation2D, inherited from ILocalization2D interface */
106 bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc) override;
108 bool getEstimatedPoses(std::vector<yarp::dev::Nav2D::Map2DLocation>& poses) override;
109 bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation& loc, const yarp::sig::Matrix& cov) override;
111 bool startLocalizationService() override;
112 bool stopLocalizationService() override;
113
114 /* The following methods belong to INavigation2D, inherited from IMap2D interface */
115 bool storeLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation loc) override;
116 bool storeArea(std::string location_name, yarp::dev::Nav2D::Map2DArea area) override;
117 bool storePath(std::string path_name, yarp::dev::Nav2D::Map2DPath path) override;
118
119 bool getLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation& loc) override;
120 bool getArea(std::string location_name, yarp::dev::Nav2D::Map2DArea& area) override;
121 bool getPath(std::string path_name, yarp::dev::Nav2D::Map2DPath& path) override;
122
123 bool renameLocation(std::string original_name, std::string new_name) override;
124 bool renameArea(std::string original_name, std::string new_name) override;
125 bool renamePath(std::string original_name, std::string new_name) override;
126
127 bool deleteLocation(std::string location_name) override;
128 bool deleteArea(std::string location_name) override;
129 bool deletePath(std::string path_name) override;
130
131 bool getLocationsList(std::vector<std::string>& locations) override;
132 bool getAreasList(std::vector<std::string>& locations) override;
133 bool getPathsList(std::vector<std::string>& paths) override;
134
135 bool getAllLocations(std::vector<yarp::dev::Nav2D::Map2DLocation>& locations) override;
136 bool getAllAreas(std::vector<yarp::dev::Nav2D::Map2DArea>& areas) override;
137 bool getAllPaths(std::vector<yarp::dev::Nav2D::Map2DPath>& paths) override;
138
139 bool clearAllLocations() override;
140 bool clearAllAreas() override;
141 bool clearAllPaths() override;
142
143 bool clearAllMaps() override;
144 bool remove_map(std::string map_name) override;
145 bool store_map(const yarp::dev::Nav2D::MapGrid2D& map) override;
146 bool get_map(std::string map_name, yarp::dev::Nav2D::MapGrid2D& map) override;
147 bool get_map_names(std::vector<std::string>& map_names) override;
148
149 bool clearAllMapsTemporaryFlags() override;
150 bool clearMapTemporaryFlags(std::string map_name) override;
151
152 bool saveMapsCollection(std::string maps_collection_file) override;
153 bool loadMapsCollection(std::string maps_collection_file) override;
154 bool saveLocationsAndExtras(std::string locations_collection_file) override;
155 bool loadLocationsAndExtras(std::string locations_collection_file) override;
156
157 bool saveMapToDisk(std::string map_name, std::string file_name) override;
158 bool loadMapFromDisk(std::string file_name) override;
159
160 bool enableMapsCompression(bool enable) override;
161};
162
163#endif // YARP_DEV_NAVIGATION2D_NWC_YARP_H
define control board standard interfaces
contains the definition of a Vector type
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
INavigation2DMsgs m_nav_RPC
bool getPath(std::string path_name, yarp::dev::Nav2D::Map2DPath &path) override
Retrieves a path.
std::string m_map_locations_server_name
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.
std::string m_localization_server_name
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.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
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:56
A class for a Matrix.
Definition: Matrix.h:39