YARP
Yet Another Robot Platform
Map2DArea.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_MAP2DAREA_H
10 #define YARP_DEV_MAP2DAREA_H
11 
12 #include <yarp/os/Portable.h>
13 #include <yarp/math/Vec2D.h>
14 #include <yarp/dev/api.h>
15 #include <yarp/dev/Map2DLocation.h>
16 #include <sstream>
17 #include <string>
18 #include <vector>
19 
23 namespace yarp
24 {
25  namespace dev
26  {
27  namespace Nav2D
28  {
30  {
31  private:
32  yarp::dev::Nav2D::Map2DLocation helper_tmp_location;
33 
34  public:
40  Map2DArea(const std::string& map_name, const std::vector<yarp::math::Vec2D<double>> area_points);
41 
47  Map2DArea(const std::string& map_name, const std::vector<yarp::dev::Nav2D::Map2DLocation> area_points);
48 
52  Map2DArea();
53 
58  std::string toString() const;
59 
64  bool operator!=(const Map2DArea& r) const;
65 
70  bool operator==(const Map2DArea& r) const;
71 
76  bool isValid() const;
77 
83  bool checkLocationInsideArea(yarp::dev::Nav2D::Map2DLocation loc);
84 
92 
98  bool getRandomLocation(yarp::dev::Nav2D::Map2DLocation& loc);
99 
105  yarp::math::Vec2D<double>& operator[](size_t index);
106 
110  void clear();
111 
112  public:
113  std::string map_id;
114  std::vector<yarp::math::Vec2D<double>> points;
115 
116  public:
117  /*
118  * Read a map2DArea from a connection.
119  * return true iff a map2DArea was read correctly
120  */
121  bool read(yarp::os::ConnectionReader& connection) override;
122 
127  bool write(yarp::os::ConnectionWriter& connection) const override;
128  };
129  }
130  }
131 }
132 
133 #endif // YARP_DEV_MAP2DAREA_H
yarp::os::Portable
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:29
yarp::dev::Nav2D::Map2DArea::map_id
std::string map_id
Definition: Map2DArea.h:113
yarp::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:827
yarp::os::Time::isValid
bool isValid()
Check if time is valid (non-zero).
Definition: Time.cpp:317
Portable.h
yarp::math::Vec2D< double >
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::dev::Nav2D::Map2DArea::points
std::vector< yarp::math::Vec2D< double > > points
Definition: Map2DArea.h:114
Map2DLocation.h
contains the definition of a Map2DLocation type
YARP_dev_API
#define YARP_dev_API
Definition: api.h:19
yarp::dev::Nav2D::Map2DLocation
Definition: Map2DLocation.h:30
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
toString
std::string toString(const T &value)
convert an arbitrary type to string.
Definition: fakeMotionControl.cpp:121
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
Vec2D.h
yarp::dev::Nav2D::Map2DArea
Definition: Map2DArea.h:30
yarp::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:971
api.h