YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Navigation2D_nwc_yarp_iMap2D.cpp
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
8#include <yarp/os/Log.h>
10#include <yarp/os/LogStream.h>
11#include <mutex>
12#include <cmath>
13
16using namespace yarp::dev;
17using namespace yarp::dev::Nav2D;
18using namespace yarp::os;
19using namespace yarp::sig;
20
21namespace {
22YARP_LOG_COMPONENT(NAVIGATION2D_NWC, "yarp.device.navigation2D_nwc_yarp")
23}
24
25//------------------------------------------------------------------------------------------------------------------------------
26
28{
29 std::lock_guard <std::mutex> lg(m_mutex);
30 return m_map_RPC.store_map_RPC(map);
31}
32
34{
35 std::lock_guard <std::mutex> lg(m_mutex);
36 auto ret = m_map_RPC.get_map_RPC(map_name);
37 if (!ret.retval)
38 {
39 yCError(NAVIGATION2D_NWC, "Unable to get_map");
40 return ret.retval;
41 }
42 map = ret.themap;
43 return ret.retval;
44}
45
47{
48 std::lock_guard <std::mutex> lg(m_mutex);
50}
51
52ReturnValue Navigation2D_nwc_yarp::get_map_names(std::vector<std::string>& map_names)
53{
54 std::lock_guard <std::mutex> lg(m_mutex);
56 if (!ret.retval)
57 {
58 yCError(NAVIGATION2D_NWC, "Unable to get_map_names");
59 return ret.retval;
60 }
61 map_names = ret.map_names;
62 return ret.retval;
63}
64
66{
67 std::lock_guard <std::mutex> lg(m_mutex);
68 return m_map_RPC.remove_map_RPC(map_name);
69}
70
72{
73 std::lock_guard <std::mutex> lg(m_mutex);
74 return m_map_RPC.store_location_RPC(location_name, loc);
75}
76
78{
79 std::lock_guard <std::mutex> lg(m_mutex);
80 return m_map_RPC.store_area_RPC(area_name, area);
81}
82
84{
85 std::lock_guard <std::mutex> lg(m_mutex);
86 return m_map_RPC.store_path_RPC(path_name, path);
87}
88
89ReturnValue Navigation2D_nwc_yarp::getLocationsList(std::vector<std::string>& locations)
90{
91 std::lock_guard <std::mutex> lg(m_mutex);
93 if (!ret.retval)
94 {
95 yCError(NAVIGATION2D_NWC, "Unable to getLocationsList");
96 return ret.retval;
97 }
98 locations = ret.locations;
99 return ret.retval;
100}
101
102ReturnValue Navigation2D_nwc_yarp::getAreasList(std::vector<std::string>& areas)
103{
104 std::lock_guard <std::mutex> lg(m_mutex);
106 if (!ret.retval)
107 {
108 yCError(NAVIGATION2D_NWC, "Unable to getAreasList");
109 return ret.retval;
110 }
111 areas = ret.areas;
112 return ret.retval;
113}
114
115ReturnValue Navigation2D_nwc_yarp::getPathsList(std::vector<std::string>& paths)
116{
117 std::lock_guard <std::mutex> lg(m_mutex);
119 if (!ret.retval)
120 {
121 yCError(NAVIGATION2D_NWC, "Unable to getPathsList");
122 return ret.retval;
123 }
124 paths = ret.paths;
125 return ret.retval;
126}
127
128ReturnValue Navigation2D_nwc_yarp::getAllLocations(std::vector<yarp::dev::Nav2D::Map2DLocation>& locations)
129{
130 std::lock_guard <std::mutex> lg(m_mutex);
132 if (!ret.retval)
133 {
134 yCError(NAVIGATION2D_NWC, "Unable to getAllLocations");
135 return ret.retval;
136 }
137 locations = ret.locations;
138 return ret.retval;
139}
140
141ReturnValue Navigation2D_nwc_yarp::getAllAreas(std::vector<yarp::dev::Nav2D::Map2DArea>& areas)
142{
143 std::lock_guard <std::mutex> lg(m_mutex);
145 if (!ret.retval)
146 {
147 yCError(NAVIGATION2D_NWC, "Unable to getAllAreas");
148 return ret.retval;
149 }
150 areas = ret.areas;
151 return ret.retval;
152}
153
154ReturnValue Navigation2D_nwc_yarp::getAllPaths(std::vector<yarp::dev::Nav2D::Map2DPath>& paths)
155{
156 std::lock_guard <std::mutex> lg(m_mutex);
158 if (!ret.retval)
159 {
160 yCError(NAVIGATION2D_NWC, "Unable to getAllPaths");
161 return ret.retval;
162 }
163 paths = ret.paths;
164 return ret.retval;
165}
166
168{
169 std::lock_guard <std::mutex> lg(m_mutex);
170 auto ret = m_map_RPC.get_location_RPC(location_name);
171 if (!ret.retval)
172 {
173 yCError(NAVIGATION2D_NWC, "Unable to getLocation");
174 return ret.retval;
175 }
176 loc = ret.loc;
177 return ret.retval;
178}
179
181{
182 std::lock_guard <std::mutex> lg(m_mutex);
183 auto ret = m_map_RPC.get_area_RPC(area_name);
184 if (!ret.retval)
185 {
186 yCError(NAVIGATION2D_NWC, "Unable to getArea");
187 return ret.retval;
188 }
189 area = ret.area;
190 return ret.retval;
191}
192
194{
195 std::lock_guard <std::mutex> lg(m_mutex);
196 auto ret = m_map_RPC.get_path_RPC(path_name);
197 if (!ret.retval)
198 {
199 yCError(NAVIGATION2D_NWC, "Unable to getPath");
200 return ret.retval;
201 }
202 path = ret.path;
203 return ret.retval;
204}
205
207{
208 std::lock_guard <std::mutex> lg(m_mutex);
209 return m_map_RPC.delete_location_RPC(location_name);
210}
211
212ReturnValue Navigation2D_nwc_yarp::renameLocation(std::string original_name, std::string new_name)
213{
214 std::lock_guard <std::mutex> lg(m_mutex);
215 return m_map_RPC.rename_location_RPC(original_name, new_name);
216}
217
219{
220 std::lock_guard <std::mutex> lg(m_mutex);
221 return m_map_RPC.delete_area_RPC(location_name);
222}
223
225{
226 std::lock_guard <std::mutex> lg(m_mutex);
227 return m_map_RPC.delete_path_RPC(path_name);
228}
229
230ReturnValue Navigation2D_nwc_yarp::renameArea(std::string original_name, std::string new_name)
231{
232 std::lock_guard <std::mutex> lg(m_mutex);
233 return m_map_RPC.rename_area_RPC(original_name, new_name);
234}
235
236ReturnValue Navigation2D_nwc_yarp::renamePath(std::string original_name, std::string new_name)
237{
238 std::lock_guard <std::mutex> lg(m_mutex);
239 return m_map_RPC.rename_path_RPC(original_name, new_name);
240}
241
243{
244 std::lock_guard <std::mutex> lg(m_mutex);
246}
247
249{
250 std::lock_guard <std::mutex> lg(m_mutex);
252}
253
259
261{
262 std::lock_guard <std::mutex> lg(m_mutex);
264}
265
267{
268 std::lock_guard <std::mutex> lg(m_mutex);
270}
271
277
283
289
295
296ReturnValue Navigation2D_nwc_yarp::saveMapToDisk(std::string map_name, std::string file_name)
297{
298 std::lock_guard <std::mutex> lg(m_mutex);
299 return m_map_RPC.save_map_to_disk_RPC(map_name, file_name);
300}
301
303{
304 std::lock_guard <std::mutex> lg(m_mutex);
305 return m_map_RPC.load_map_from_disk_RPC(file_name);
306}
307
309{
310 std::lock_guard <std::mutex> lg(m_mutex);
312}
bool ret
virtual return_get_map_names get_map_names_RPC()
virtual yarp::dev::ReturnValue save_map_to_disk_RPC(const std::string &map_name, const std::string &file_name)
virtual yarp::dev::ReturnValue save_maps_collection_RPC(const std::string &maps_collection_file)
virtual yarp::dev::ReturnValue remove_map_RPC(const std::string &map_name)
virtual yarp::dev::ReturnValue clear_all_areas_RPC()
virtual yarp::dev::ReturnValue enable_maps_compression_RPC(const bool enable_compression)
virtual yarp::dev::ReturnValue store_area_RPC(const std::string &area_name, const yarp::dev::Nav2D::Map2DArea &area)
virtual yarp::dev::ReturnValue rename_path_RPC(const std::string &original_name, const std::string &new_name)
virtual yarp::dev::ReturnValue delete_path_RPC(const std::string &path_name)
virtual return_get_all_areas get_all_areas_RPC()
virtual yarp::dev::ReturnValue store_map_RPC(const yarp::dev::Nav2D::MapGrid2D &themap)
virtual yarp::dev::ReturnValue rename_location_RPC(const std::string &original_name, const std::string &new_name)
virtual return_get_location get_location_RPC(const std::string &location_name)
virtual return_get_areas_list get_areas_list_RPC()
virtual yarp::dev::ReturnValue load_map_from_disk_RPC(const std::string &file_name)
virtual return_get_path get_path_RPC(const std::string &path_name)
virtual yarp::dev::ReturnValue store_path_RPC(const std::string &path_name, const yarp::dev::Nav2D::Map2DPath &path)
virtual yarp::dev::ReturnValue clear_all_locations_RPC()
virtual yarp::dev::ReturnValue rename_area_RPC(const std::string &original_name, const std::string &new_name)
virtual yarp::dev::ReturnValue clear_all_maps_RPC()
virtual yarp::dev::ReturnValue delete_location_RPC(const std::string &location_name)
virtual yarp::dev::ReturnValue load_locations_and_extras_RPC(const std::string &locations_collection_file)
virtual yarp::dev::ReturnValue load_maps_collection_RPC(const std::string &maps_collection_file)
virtual yarp::dev::ReturnValue delete_area_RPC(const std::string &area_name)
virtual yarp::dev::ReturnValue store_location_RPC(const std::string &location_name, const yarp::dev::Nav2D::Map2DLocation &loc)
virtual return_get_area get_area_RPC(const std::string &area_name)
virtual return_get_all_paths get_all_paths_RPC()
virtual return_get_map get_map_RPC(const std::string &map_name)
virtual yarp::dev::ReturnValue save_locations_and_extras_RPC(const std::string &locations_collection_file)
virtual yarp::dev::ReturnValue clear_all_maps_temporary_flags_RPC()
virtual return_get_paths_list get_paths_list_RPC()
virtual yarp::dev::ReturnValue clear_all_paths_RPC()
virtual return_get_locations_list get_locations_list_RPC()
virtual return_get_all_locations get_all_locations_RPC()
virtual yarp::dev::ReturnValue clear_map_temporary_flags_RPC(const std::string &map_name)
yarp::dev::ReturnValue clearAllMaps() override
Removes all the registered maps from the server.
yarp::dev::ReturnValue loadMapFromDisk(std::string file_name) override
Load a map from disk.
yarp::dev::ReturnValue clearAllMapsTemporaryFlags() override
Clear all temporary flags from all stored maps.
yarp::dev::ReturnValue deleteLocation(std::string location_name) override
Delete a location.
yarp::dev::ReturnValue getAllPaths(std::vector< yarp::dev::Nav2D::Map2DPath > &paths) override
Get a list of all stored paths.
yarp::dev::ReturnValue getAreasList(std::vector< std::string > &locations) override
Get a list of the names of all stored areas.
yarp::dev::ReturnValue clearAllLocations() override
Delete all stored locations.
yarp::dev::ReturnValue getAllLocations(std::vector< yarp::dev::Nav2D::Map2DLocation > &locations) override
Get a list of all stored locations.
yarp::dev::ReturnValue enableMapsCompression(bool enable) override
Enable/disables maps compression over the network.
yarp::dev::ReturnValue getPathsList(std::vector< std::string > &paths) override
Get a list of the names of all stored paths.
yarp::dev::ReturnValue storeLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation loc) override
Store a location specified by the user in the world reference frame.
yarp::dev::ReturnValue loadLocationsAndExtras(std::string locations_collection_file) override
Load a collection of locations/areas/paths etc from disk.
yarp::dev::ReturnValue getLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation &loc) override
Retrieves a location specified by the user in the world reference frame.
yarp::dev::ReturnValue loadMapsCollection(std::string maps_collection_file) override
Load a collection of maps from disk.
yarp::dev::ReturnValue saveLocationsAndExtras(std::string locations_collection_file) override
Save a collection of locations/area/paths etc to disk.
yarp::dev::ReturnValue deletePath(std::string path_name) override
Delete a path.
yarp::dev::ReturnValue deleteArea(std::string location_name) override
Delete an area.
yarp::dev::ReturnValue clearAllAreas() override
Delete all stored areas.
yarp::dev::ReturnValue renamePath(std::string original_name, std::string new_name) override
Searches for a path and renames it.
yarp::dev::ReturnValue saveMapsCollection(std::string maps_collection_file) override
Save a collection of maps to disk.
yarp::dev::ReturnValue saveMapToDisk(std::string map_name, std::string file_name) override
Save a map to disk.
yarp::dev::ReturnValue getAllAreas(std::vector< yarp::dev::Nav2D::Map2DArea > &areas) override
Get a list of all stored areas.
yarp::dev::ReturnValue getPath(std::string path_name, yarp::dev::Nav2D::Map2DPath &path) override
Retrieves a path.
yarp::dev::ReturnValue getArea(std::string location_name, yarp::dev::Nav2D::Map2DArea &area) override
Retrieves an area.
yarp::dev::ReturnValue getLocationsList(std::vector< std::string > &locations) override
Get a list of the names of all stored locations.
yarp::dev::ReturnValue storePath(std::string path_name, yarp::dev::Nav2D::Map2DPath path) override
Store a path.
yarp::dev::ReturnValue clearAllPaths() override
Delete all stored paths.
yarp::dev::ReturnValue store_map(const yarp::dev::Nav2D::MapGrid2D &map) override
Stores a map into the map server.
yarp::dev::ReturnValue get_map_names(std::vector< std::string > &map_names) override
Gets a list containing the names of all registered maps.
yarp::dev::ReturnValue remove_map(std::string map_name) override
Removes a map from the map server.
yarp::dev::ReturnValue storeArea(std::string location_name, yarp::dev::Nav2D::Map2DArea area) override
Store an area.
yarp::dev::ReturnValue renameLocation(std::string original_name, std::string new_name) override
Searches for a location and renames it.
yarp::dev::ReturnValue get_map(std::string map_name, yarp::dev::Nav2D::MapGrid2D &map) override
Gets a map from the map server.
yarp::dev::ReturnValue renameArea(std::string original_name, std::string new_name) override
Searches for an area and renames it.
yarp::dev::ReturnValue clearMapTemporaryFlags(std::string map_name) override
Clear all temporary flags from a specific map.
A mini-server for performing network communication in the background.
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.