YARP
Yet Another Robot Platform
map2DStorage.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 
6 #include <sstream>
7 #include <limits>
8 #include "map2DStorage.h"
9 #include <yarp/dev/IMap2D.h>
10 #include <yarp/dev/INavigation2D.h>
11 #include <yarp/dev/GenericVocabs.h>
12 #include <yarp/math/Math.h>
13 #include <yarp/os/Log.h>
14 #include <yarp/os/LogComponent.h>
15 #include <yarp/os/LogStream.h>
16 #include <mutex>
17 #include <cstdlib>
18 #include <fstream>
19 
20 using namespace yarp::sig;
21 using namespace yarp::dev;
22 using namespace yarp::dev::Nav2D;
23 using namespace yarp::os;
24 
25 namespace {
26 YARP_LOG_COMPONENT(MAP2DSTORAGE, "yarp.device.map2DStorage")
27 }
28 
34 {
35 }
36 
37 Map2DStorage::~Map2DStorage() = default;
38 
39 bool Map2DStorage::saveMapsCollection(std::string mapsfile)
40 {
41  //check if the storage is not empty
42  if (m_maps_storage.size() == 0)
43  {
44  yCError(MAP2DSTORAGE) << "Map storage is empty";
45  return false;
46  }
47 
48  //open the map collection file
49  std::ofstream file;
50  file.open(mapsfile.c_str());
51  if (!file.is_open())
52  {
53  yCError(MAP2DSTORAGE) << "Sorry unable to open" << mapsfile;
54  return false;
55  }
56 
57  bool ret = true;
58  //for each map...
59  for (auto& it : m_maps_storage)
60  {
61  //add an entry to the map collection file
62  std::string map_filename = it.first + ".map";
63  file << "mapfile: ";
64  file << map_filename;
65  file << '\n';
66 
67  //save each individual map to a file
68  ret &= it.second.saveToFile(map_filename);
69  }
70 
71  file.close();
72  return ret;
73 }
74 
75 bool Map2DStorage::loadMapsCollection(std::string mapsfile)
76 {
77  bool ret = true;
78  std::ifstream file;
79  file.open(mapsfile.c_str());
80  if (!file.is_open())
81  {
82  yCError(MAP2DSTORAGE) << "loadMaps() Unable to open:" << mapsfile;
83  return false;
84  }
85  while (!file.eof())
86  {
87  std::string dummy;
88  std::string buffer;
89  std::getline(file, buffer);
90  std::istringstream iss(buffer);
91  iss >> dummy;
92  if (dummy == "") {
93  break;
94  }
95  if (dummy == "mapfile:")
96  {
97  std::string mapfilename;
98  iss >> mapfilename;
99  std::string option;
100  iss >> option;
101  std::string mapfilenameWithPath = m_rf_mapCollection.findFile(mapfilename);
102 
103  //open the individual map file
104  MapGrid2D map;
105  bool r = map.loadFromFile(mapfilenameWithPath);
106  if (r)
107  {
108  std::string map_name= map.getMapName();
109  auto p = m_maps_storage.find(map_name);
110  if (p == m_maps_storage.end())
111  {
112  if (option == "crop") {
113  map.crop(-1, -1, -1, -1);
114  }
115  m_maps_storage[map_name] = map;
116  }
117  else
118  {
119  yCError(MAP2DSTORAGE) << "A map with the same name '" << map_name << "'was found, skipping...";
120  ret = false;
121  }
122  }
123  else
124  {
125  yCError(MAP2DSTORAGE) << "Problems opening map file" << mapfilenameWithPath;
126  ret = false;
127  }
128  }
129  else
130  {
131  yCError(MAP2DSTORAGE) << "Invalid syntax, missing mapfile tag";
132  ret = false;
133  }
134  }
135  file.close();
136  return ret;
137 }
138 
140 {
141  Property params;
142  params.fromString(config.toString());
143 
144  std::string collection_file_name="maps_collection.ini";
145  std::string locations_file_name="locations.ini";
146  if (config.check("mapCollectionFile"))
147  {
148  collection_file_name= config.find("mapCollectionFile").asString();
149  }
150 
151  if (config.check("mapCollectionContext"))
152  {
153  std::string collection_context_name= config.find("mapCollectionContext").asString();
154  m_rf_mapCollection.setDefaultContext(collection_context_name.c_str());
155  std::string collection_file_with_path = m_rf_mapCollection.findFile(collection_file_name);
156  std::string locations_file_with_path = m_rf_mapCollection.findFile(locations_file_name);
157 
158  if (collection_file_with_path=="")
159  {
160  yCInfo(MAP2DSTORAGE) << "No locations loaded";
161  }
162  else
163  {
164  bool ret = loadLocationsAndExtras(locations_file_with_path);
165  if (ret) { yCInfo(MAP2DSTORAGE) << "Location file" << locations_file_with_path << "successfully loaded."; }
166  else { yCError(MAP2DSTORAGE) << "Problems opening file" << locations_file_with_path; }
167  }
168 
169  if (collection_file_with_path=="")
170  {
171  yCError(MAP2DSTORAGE) << "Unable to find file" << collection_file_name << "within the specified context:" << collection_context_name;
172  return false;
173  }
174  if (loadMapsCollection(collection_file_with_path))
175  {
176  yCInfo(MAP2DSTORAGE) << "Map collection file:" << collection_file_with_path << "successfully loaded.";
177  if (m_maps_storage.size() > 0)
178  {
179  yCInfo(MAP2DSTORAGE) << "Available maps are:";
180  for (auto& it : m_maps_storage)
181  {
182  yCInfo(MAP2DSTORAGE) << it.first;
183  }
184  }
185  else
186  {
187  yCInfo(MAP2DSTORAGE) << "No maps available";
188  }
189  if (m_locations_storage.size() > 0)
190  {
191  yCInfo(MAP2DSTORAGE) << "Available Locations are:";
192  for (auto& it : m_locations_storage)
193  {
194  yCInfo(MAP2DSTORAGE) << it.first;
195  }
196  }
197  else
198  {
199  yCInfo(MAP2DSTORAGE) << "No locations available";
200  }
201 
202  if (m_areas_storage.size() > 0)
203  {
204  yCInfo(MAP2DSTORAGE) << "Available areas are:";
205  for (auto& it : m_areas_storage)
206  {
207  yCInfo(MAP2DSTORAGE) << it.first;
208  }
209  }
210  else
211  {
212  yCInfo(MAP2DSTORAGE) << "No areas available";
213  }
214  }
215  else
216  {
217  yCError(MAP2DSTORAGE) << "Unable to load map collection file:" << collection_file_with_path;
218  return false;
219  }
220  }
221 
222  if (!config.check("name"))
223  {
224  m_rpcPortName = "/map2DStorage/rpc";
225  }
226  else
227  {
228  m_rpcPortName = config.find("name").asString();
229  }
230 
231  //open rpc port
232  if (!m_rpcPort.open(m_rpcPortName))
233  {
234  yCError(MAP2DSTORAGE, "Failed to open port %s", m_rpcPortName.c_str());
235  return false;
236  }
237  m_rpcPort.setReader(*this);
238 
239  return true;
240 }
241 
243 {
244  yCTrace(MAP2DSTORAGE, "Close");
245  return true;
246 }
247 
248 bool Map2DStorage::priv_load_locations_and_areas_v1(std::ifstream& file)
249 {
250  std::string buffer;
251  std::getline(file, buffer);
252  if (buffer != "Locations:")
253  {
254  yCError(MAP2DSTORAGE) << "Unable to parse Locations section!";
255  return false;
256  }
257 
258  while (1)
259  {
260  std::getline(file, buffer);
261  if (buffer == "Areas:") {
262  break;
263  }
264  if (file.eof())
265  {
266  yCError(MAP2DSTORAGE) << "Unexpected End Of File";
267  return false;
268  }
269  Bottle b;
270  b.fromString(buffer);
271  size_t bot_size = b.size();
272  if (bot_size != 5)
273  {
274  yCError(MAP2DSTORAGE) << "Unable to parse contents of Areas section!";
275  return false;
276  }
277  Map2DLocation location;
278  std::string name = b.get(0).asString();
279  location.map_id = b.get(1).asString();
280  location.x = b.get(2).asFloat64();
281  location.y = b.get(3).asFloat64();
282  location.theta = b.get(4).asFloat64();
283  m_locations_storage[name] = location;
284  }
285 
286  if (buffer != "Areas:")
287  {
288  yCError(MAP2DSTORAGE) << "Unable to parse Areas section!";
289  return false;
290  }
291 
292  while (1)
293  {
294  Map2DArea area;
295  std::getline(file, buffer);
296  if (file.eof()) {
297  break;
298  }
299 
300  Bottle b;
301  b.fromString(buffer);
302  size_t bot_size = b.size();
303  std::string name = b.get(0).asString();
304  area.map_id = b.get(1).asString();
305  size_t area_size = b.get(2).asInt32();
306  if (area_size <= 0 || bot_size != area_size * 2 + 3)
307  {
308  yCError(MAP2DSTORAGE) << "Unable to parse contents of Areas section!";
309  return false;
310  }
311  for (size_t ai = 3; ai < bot_size; ai += 2)
312  {
313  double xpos = b.get(ai).asFloat64();
314  double ypos = b.get(ai + 1).asFloat64();
315  area.points.push_back(yarp::math::Vec2D<double>(xpos, ypos));
316  }
317  m_areas_storage[name] = area;
318  }
319  return true;
320 }
321 
322 bool Map2DStorage::priv_load_locations_and_areas_v2(std::ifstream& file)
323 {
324  std::string buffer;
325  std::getline(file, buffer);
326  if (buffer != "Locations:")
327  {
328  yCError(MAP2DSTORAGE) << "Unable to parse Locations section!";
329  return false;
330  }
331 
332  while (1)
333  {
334  std::getline(file, buffer);
335  if (buffer == "Areas:") {
336  break;
337  }
338  if (file.eof())
339  {
340  yCError(MAP2DSTORAGE) << "Unexpected End Of File";
341  return false;
342  }
343  Bottle b;
344  b.fromString(buffer);
345  size_t bot_size = b.size();
346  if (bot_size != 5)
347  {
348  yCError(MAP2DSTORAGE) << "Unable to parse contents of Areas section!";
349  return false;
350  }
351  Map2DLocation location;
352  std::string name = b.get(0).asString();
353  location.map_id = b.get(1).asString();
354  location.x = b.get(2).asFloat64();
355  location.y = b.get(3).asFloat64();
356  location.theta = b.get(4).asFloat64();
357  m_locations_storage[name] = location;
358  }
359 
360  if (buffer != "Areas:")
361  {
362  yCError(MAP2DSTORAGE) << "Unable to parse Areas section!";
363  return false;
364  }
365 
366  while (1)
367  {
368  Map2DArea area;
369  std::getline(file, buffer);
370  if (buffer == "Paths:") {
371  break;
372  }
373  if (file.eof()) {
374  break;
375  }
376 
377  Bottle b;
378  b.fromString(buffer);
379  size_t bot_size = b.size();
380  std::string name = b.get(0).asString();
381  area.map_id = b.get(1).asString();
382  size_t area_size = b.get(2).asInt32();
383  if (area_size <= 0 || bot_size != area_size * 2 + 3)
384  {
385  yCError(MAP2DSTORAGE) << "Unable to parse contents of Areas section!";
386  return false;
387  }
388  for (size_t ai = 3; ai < bot_size; ai += 2)
389  {
390  double xpos = b.get(ai).asFloat64();
391  double ypos = b.get(ai + 1).asFloat64();
392  area.points.push_back(yarp::math::Vec2D<double>(xpos, ypos));
393  }
394  m_areas_storage[name] = area;
395  }
396 
397  if (buffer != "Paths:")
398  {
399  yCError(MAP2DSTORAGE) << "Unable to parse Paths section!";
400  return false;
401  }
402 
403  while (1)
404  {
405  Map2DPath path;
406  std::getline(file, buffer);
407  if (file.eof()) {
408  break;
409  }
410 
411  Bottle b;
412  b.fromString(buffer);
413  size_t bot_size = b.size();
414  YARP_UNUSED(bot_size);
415  std::string name = b.get(0).asString();
416  size_t i = 1;
417  do
418  {
419  if (b.get(i).isList())
420  {
421  Bottle* ll = b.get(i).asList();
422  if (ll && ll->size() == 4)
423  {
424  Map2DLocation loc;
425  loc.map_id = ll->get(0).asString();
426  loc.x = ll->get(1).asFloat64();
427  loc.y = ll->get(2).asFloat64();
428  loc.theta = ll->get(3).asFloat64();
429  path.push_back(loc);
430  }
431  else
432  {
433  yCError(MAP2DSTORAGE) << "Unable to parse contents of Paths section!";
434  return false;
435  }
436  }
437  else
438  {
439  break;
440  }
441  i++;
442  } while (1);
443  m_paths_storage[name] = path;
444  }
445 
446  return true;
447 }
448 
449 bool Map2DStorage::loadLocationsAndExtras(std::string locations_file)
450 {
451  std::ifstream file;
452  file.open (locations_file.c_str());
453 
454  if(!file.is_open())
455  {
456  yCError(MAP2DSTORAGE) << "Unable to open" << locations_file << "locations file.";
457  return false;
458  }
459 
460  std::string buffer;
461 
462  std::getline(file, buffer);
463  if (buffer != "Version:")
464  {
465  yCError(MAP2DSTORAGE) << "Unable to parse Version section!";
466  file.close();
467  return false;
468  }
469  std::getline(file, buffer);
470  int version = atoi(buffer.c_str());
471 
472  if (version == 1)
473  {
474  if (!priv_load_locations_and_areas_v1(file))
475  {
476  yCError(MAP2DSTORAGE) << "Call to load_locations_and_areas_v1 failed";
477  file.close();
478  return false;
479  }
480  }
481  else if (version == 2)
482  {
483  if (!priv_load_locations_and_areas_v2(file))
484  {
485  yCError(MAP2DSTORAGE) << "Call to load_locations_and_areas_v2 failed";
486  file.close();
487  return false;
488  }
489  }
490  else
491  {
492  yCError(MAP2DSTORAGE) << "Only versions 1,2 supported!";
493  file.close();
494  return false;
495  }
496 
497  //on success
498  file.close();
499  yCDebug(MAP2DSTORAGE) << "Locations file" << locations_file << "loaded, "
500  << m_locations_storage.size() << "locations and "
501  << m_areas_storage.size() << " areas and "
502  << m_paths_storage.size() << " paths available";
503  return true;
504 }
505 
506 bool Map2DStorage::saveLocationsAndExtras(std::string locations_file)
507 {
508  std::ofstream file;
509  file.open (locations_file.c_str());
510 
511  if(!file.is_open())
512  {
513  yCError(MAP2DSTORAGE) << "Unable to open" << locations_file << "locations file.";
514  return false;
515  }
516 
517  std::string s;
518  Map2DLocation loc;
519  Map2DArea area;
520  s = " ";
521 
522  file << "Version:\n";
523  file << "2\n";
524 
525  {
526  file << "Locations:\n";
527  std::map<std::string, Map2DLocation>::iterator it;
528  for (it = m_locations_storage.begin(); it != m_locations_storage.end(); ++it)
529  {
530  loc = it->second;
531  file << it->first << s << loc.map_id << s << loc.x << s << loc.y << s << loc.theta << "\n";
532  }
533  }
534 
535  {
536  file << "Areas:\n";
537  std::map<std::string, Map2DArea>::iterator it2;
538  for (it2 = m_areas_storage.begin(); it2 != m_areas_storage.end(); ++it2)
539  {
540  area = it2->second;
541  file << it2->first << s << area.map_id << s << area.points.size() << s;
542  for (size_t i = 0; i < area.points.size(); i++)
543  {
544  file << area.points[i].x << s;
545  file << area.points[i].y << s;
546  }
547  file << "\n";
548  }
549  }
550 
551  {
552  file << "Paths:\n";
553  std::map<std::string, Map2DPath>::iterator it3;
554  for (it3 = m_paths_storage.begin(); it3 != m_paths_storage.end(); ++it3)
555  {
556  file << it3->first << " "; // the name of the path
557  for (size_t i=0; i<it3->second.size(); i++)
558  {
559  loc = it3->second[i];
560  file << "( " <<loc.map_id << s << loc.x << s << loc.y << s << loc.theta << ") ";
561  }
562  file << "\n";
563  }
564  }
565 
566  file.close();
567  yCDebug(MAP2DSTORAGE) << "Locations file" << locations_file << "saved.";
568  return true;
569 }
570 
571 
573 {
574  m_maps_storage.clear();
575  return true;
576 }
577 
579 {
580  std::string map_name = map.getMapName();
581  auto it = m_maps_storage.find(map_name);
582  if (it == m_maps_storage.end())
583  {
584  //add a new map
585  m_maps_storage[map_name] = map;
586  }
587  else
588  {
589  //the map already exists
590  m_maps_storage[map_name] = map;
591  }
592  return true;
593 }
594 
595 bool Map2DStorage::get_map(std::string map_name, yarp::dev::Nav2D::MapGrid2D& map)
596 {
597  auto it = m_maps_storage.find(map_name);
598  if (it != m_maps_storage.end())
599  {
600  map=it->second;
601  return true;
602  }
603  return false;
604 }
605 
606 bool Map2DStorage::get_map_names(std::vector<std::string>& map_names)
607 {
608  map_names.clear();
609  for (auto& it : m_maps_storage)
610  {
611  map_names.push_back(it.first);
612  }
613  return true;
614 }
615 
616 bool Map2DStorage::remove_map(std::string map_name)
617 {
618  size_t rem = m_maps_storage.erase(map_name);
619  if (rem == 0)
620  {
621  return false;
622  }
623  else
624  {
625  return true;
626  }
627 }
628 
630 {
631  m_locations_storage.insert(std::pair<std::string, Map2DLocation>(location_name, loc));
632  return true;
633 }
634 
635 bool Map2DStorage::storeArea(std::string area_name, yarp::dev::Nav2D::Map2DArea area)
636 {
637  m_areas_storage.insert(std::pair<std::string, Map2DArea>(area_name, area));
638  return true;
639 }
640 
641 bool Map2DStorage::storePath(std::string path_name, yarp::dev::Nav2D::Map2DPath path)
642 {
643  m_paths_storage.insert(std::pair<std::string, Map2DPath>(path_name, path));
644  return true;
645 }
646 
647 bool Map2DStorage::getLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation& loc)
648 {
649  auto it = m_locations_storage.find(location_name);
650  if (it != m_locations_storage.end())
651  {
652  loc = it->second;
653  return true;
654  }
655  return false;
656 }
657 
658 bool Map2DStorage::getArea(std::string area_name, yarp::dev::Nav2D::Map2DArea& area)
659 {
660  auto it = m_areas_storage.find(area_name);
661  if (it != m_areas_storage.end())
662  {
663  area = it->second;
664  return true;
665  }
666  return false;
667 }
668 
669 bool Map2DStorage::getPath(std::string path_name, yarp::dev::Nav2D::Map2DPath& path)
670 {
671  auto it = m_paths_storage.find(path_name);
672  if (it != m_paths_storage.end())
673  {
674  path = it->second;
675  return true;
676  }
677  return false;
678 }
679 
680 bool Map2DStorage::getLocationsList(std::vector<std::string>& locations)
681 {
682  locations.clear();
683  for (auto& it : m_locations_storage)
684  {
685  locations.push_back(it.first);
686  }
687  return true;
688 }
689 
690 bool Map2DStorage::getAreasList(std::vector<std::string>& areas)
691 {
692  areas.clear();
693  for (auto& it : m_areas_storage)
694  {
695  areas.push_back(it.first);
696  }
697  return true;
698 }
699 
700 bool Map2DStorage::getPathsList(std::vector<std::string>& paths)
701 {
702  paths.clear();
703  for (auto& it : m_paths_storage)
704  {
705  paths.push_back(it.first);
706  }
707  return true;
708 }
709 
710 bool Map2DStorage::renameLocation(std::string original_name, std::string new_name)
711 {
712  std::map<std::string, Map2DLocation>::iterator orig_it;
713  orig_it = m_locations_storage.find(original_name);
714  std::map<std::string, Map2DLocation>::iterator new_it;
715  new_it = m_locations_storage.find(new_name);
716 
717  if (orig_it != m_locations_storage.end() &&
718  new_it == m_locations_storage.end())
719  {
720  auto loc = orig_it->second;
721  m_locations_storage.erase(orig_it);
722  m_locations_storage.insert(std::pair<std::string, Map2DLocation>(new_name, loc));
723  return true;
724  }
725  return false;
726 }
727 
728 bool Map2DStorage::deleteLocation(std::string location_name)
729 {
730  std::map<std::string, Map2DLocation>::iterator it;
731  it = m_locations_storage.find(location_name);
732  if (it != m_locations_storage.end())
733  {
734  m_locations_storage.erase(it);
735  return true;
736  }
737  return false;
738 }
739 
740 bool Map2DStorage::deleteArea(std::string area_name)
741 {
742  std::map<std::string, Map2DArea>::iterator it;
743  it = m_areas_storage.find(area_name);
744  if (it != m_areas_storage.end())
745  {
746  m_areas_storage.erase(it);
747  return true;
748  }
749  return false;
750 }
751 
752 bool Map2DStorage::deletePath(std::string path_name)
753 {
754  std::map<std::string, Map2DPath>::iterator it;
755  it = m_paths_storage.find(path_name);
756  if (it != m_paths_storage.end())
757  {
758  m_paths_storage.erase(it);
759  return true;
760  }
761  return false;
762 }
763 
764 bool Map2DStorage::renameArea(std::string original_name, std::string new_name)
765 {
766 
767  std::map<std::string, Map2DArea>::iterator orig_it;
768  orig_it = m_areas_storage.find(original_name);
769  std::map<std::string, Map2DArea>::iterator new_it;
770  new_it = m_areas_storage.find(new_name);
771 
772  if (orig_it != m_areas_storage.end() &&
773  new_it == m_areas_storage.end())
774  {
775  auto area = orig_it->second;
776  m_areas_storage.erase(orig_it);
777  m_areas_storage.insert(std::pair<std::string, Map2DArea>(new_name, area));
778  return true;
779  }
780  return false;
781 }
782 
783 bool Map2DStorage::renamePath(std::string original_name, std::string new_name)
784 {
785 
786  std::map<std::string, Map2DPath>::iterator orig_it;
787  orig_it = m_paths_storage.find(original_name);
788  std::map<std::string, Map2DPath>::iterator new_it;
789  new_it = m_paths_storage.find(new_name);
790 
791  if (orig_it != m_paths_storage.end() &&
792  new_it == m_paths_storage.end())
793  {
794  auto area = orig_it->second;
795  m_paths_storage.erase(orig_it);
796  m_paths_storage.insert(std::pair<std::string, Map2DPath>(new_name, area));
797  return true;
798  }
799  return false;
800 }
801 
802 
803 
805 {
806  m_locations_storage.clear();
807  return true;
808 }
809 
811 {
812  m_areas_storage.clear();
813  return true;
814 }
815 
817 {
818  m_paths_storage.clear();
819  return true;
820 }
821 
823 {
824  for (auto it = m_maps_storage.begin(); it != m_maps_storage.end(); it++)
825  {
826  it->second.clearMapTemporaryFlags();
827  }
828  return true;
829 }
830 
831 bool Map2DStorage::clearMapTemporaryFlags(std::string map_name)
832 {
833  auto it = m_maps_storage.find(map_name);
834  if (it != m_maps_storage.end())
835  {
836  it->second.clearMapTemporaryFlags();
837  return true;
838  }
839  else
840  {
841  return false;
842  }
843 }
844 
845 bool Map2DStorage::read(yarp::os::ConnectionReader& connection)
846 {
847  yCWarning(MAP2DSTORAGE) << "not yet implemented";
848 
849  std::lock_guard<std::mutex> lock(m_mutex);
850  yarp::os::Bottle in;
851  yarp::os::Bottle out;
852  bool ok = in.read(connection);
853  if (!ok) {
854  return false;
855  }
856 
857  //parse string command
858  if (in.get(0).isString())
859  {
860  //parse_string_command(in, out);
861  }
862  // parse vocab command
863  else if (in.get(0).isVocab32())
864  {
865  //parse_vocab_command(in, out);
866  }
867 
868  yarp::os::ConnectionWriter* returnToSender = connection.getWriter();
869  if (returnToSender != nullptr)
870  {
871  out.write(*returnToSender);
872  }
873  else
874  {
875  yCError(MAP2DSTORAGE) << "Invalid return to sender";
876  }
877  return true;
878 }
bool ret
bool getLocationsList(std::vector< std::string > &locations) override
Get a list of all stored locations.
bool renamePath(std::string original_name, std::string new_name) override
Searches for a path and renames it.
bool deleteArea(std::string area_name) override
Delete an area.
bool saveLocationsAndExtras(std::string locations_file) override
Save a collection of locations/area/paths etc.
bool getPath(std::string path_name, yarp::dev::Nav2D::Map2DPath &path) override
Retrieves a path.
bool close() override
Close the DeviceDriver.
bool clearAllLocations() override
Delete all stored locations.
bool deleteLocation(std::string location_name) override
Delete a location.
bool clearMapTemporaryFlags(std::string map_name) override
Clear all temporary flags from a specific map.
bool storeLocation(std::string location_name, yarp::dev::Nav2D::Map2DLocation loc) override
Store a location specified by the user in the world reference frame.
bool store_map(const yarp::dev::Nav2D::MapGrid2D &map) override
Stores a map into the map server.
bool getAreasList(std::vector< std::string > &areas) override
Get a list of all stored areas.
bool renameLocation(std::string original_name, std::string new_name) override
Searches for a location and renames it.
bool deletePath(std::string path_name) override
Delete a path.
bool saveMapsCollection(std::string maps_collection_file) override
Save a collection of maps.
bool get_map(std::string map_name, yarp::dev::Nav2D::MapGrid2D &map) override
Gets a map from the map server.
Map2DStorage()
Map2DStorage.
bool renameArea(std::string original_name, std::string new_name) override
Searches for an area and renames it.
bool remove_map(std::string map_name) override
Removes a map from the map server.
bool loadMapsCollection(std::string maps_collection_file) override
Load a collection of maps.
bool get_map_names(std::vector< std::string > &map_names) override
Gets a list containing the names of all registered maps.
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 clearAllAreas() override
Delete all stored areas.
bool clearAllPaths() override
Delete all stored paths.
bool storePath(std::string path_name, yarp::dev::Nav2D::Map2DPath path) override
Store a path.
bool clearAllMaps() override
Removes all the registered maps from the server.
bool storeArea(std::string area_name, yarp::dev::Nav2D::Map2DArea area) override
Store an area.
bool getPathsList(std::vector< std::string > &paths) override
Get a list of all stored paths.
bool clearAllMapsTemporaryFlags() override
Clear all temporary flags from all stored maps.
bool getArea(std::string area_name, yarp::dev::Nav2D::Map2DArea &area) override
Retrieves an area.
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
bool loadLocationsAndExtras(std::string locations_file) override
Load a collection of locations/areas/paths etc.
std::vector< yarp::math::Vec2D< double > > points
Definition: Map2DArea.h:111
void push_back(yarp::dev::Nav2D::Map2DLocation loc)
Inserts a new location into the path @loc the location to be inserted.
Definition: Map2DPath.cpp:127
std::string getMapName() const
Retrieves the map name.
Definition: MapGrid2D.cpp:1085
bool crop(int left, int top, int right, int bottom)
Modifies the map, cropping pixels at the boundaries.
Definition: MapGrid2D.cpp:707
bool loadFromFile(std::string map_filename)
Loads a yarp map file from disk.
Definition: MapGrid2D.cpp:556
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
void fromString(const std::string &text)
Initializes bottle from a string.
Definition: Bottle.cpp:204
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:251
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Definition: Bottle.cpp:240
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:246
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
Definition: Bottle.cpp:230
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
A class for storing options and configuration information.
Definition: Property.h:34
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1063
A base class for nested structures that can be searched.
Definition: Searchable.h:66
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition: Value.cpp:222
virtual bool isString() const
Checks if value is a string.
Definition: Value.cpp:156
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:204
virtual bool isList() const
Checks if value is a list.
Definition: Value.cpp:162
virtual Bottle * asList() const
Get list value.
Definition: Value.cpp:240
virtual bool isVocab32() const
Checks if value is a vocabulary identifier.
Definition: Value.cpp:174
virtual std::string asString() const
Get string value.
Definition: Value.cpp:234
#define yCInfo(component,...)
Definition: LogComponent.h:132
#define yCError(component,...)
Definition: LogComponent.h:154
#define yCTrace(component,...)
Definition: LogComponent.h:85
#define yCWarning(component,...)
Definition: LogComponent.h:143
#define yCDebug(component,...)
Definition: LogComponent.h:109
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:77
An interface for the device drivers.
An interface to the operating system, including Port based communication.
Signal processing.
Definition: Image.h:22
#define YARP_UNUSED(var)
Definition: api.h:162