YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Map2DObject.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_MAP2DOBJECT_H
7#define YARP_DEV_MAP2DOBJECT_H
8
9#include <sstream>
10#include <string>
11
12//#include <yarp/math/Vec2D.h>
13#include <yarp/dev/api.h>
14#include <yarp/dev/NavTypes.h>
17
21namespace yarp::dev::Nav2D {
23{
31 Map2DObject(const std::string& map_name, const double& inX, const double& inY, const double& inZ, const double& inr=0,const double& inp=0,const double& iny=0, const std::string& desc = "")
32 {
33 map_id = map_name;
34 x = inX;
35 y = inY;
36 z = inZ;
37 roll = inr;
38 pitch = inp;
39 yaw = iny;
40 description = desc;
41 }
42
51 Map2DObject(const std::string& map_name, const yarp::dev::Nav2D::XYWorld& object, const std::string& desc = "")
52 {
53 map_id = map_name;
54 x = object.x;
55 y = object.y;
56 z = 0;
57 roll = 0;
58 pitch = 0;
59 yaw = 0;
60 description = desc;
61 }
62
67 {
68 map_id = "";
69 description = "";
70 x = 0;
71 y = 0;
72 z = 0;
73 roll = 0;
74 pitch = 0;
75 yaw = 0;
76 }
77
82 std::string toString() const
83 {
84 std::ostringstream stringStream;
85 stringStream.precision(-1);
86 stringStream.width(-1);
87 stringStream << std::string("map_id:") << map_id << std::string(" x:") << x << std::string(" y:") << y << std::string(" z:") << z;
88 stringStream << std::string(" roll:") << roll << std::string(" pitch:") << pitch << std::string(" yaw:") << yaw << " ";
89 stringStream << std::string("desc:") << description;
90 return stringStream.str();
91 }
92
97 inline bool operator!=(const Map2DObject& r) const
98 {
99 if (
100 map_id != r.map_id || x != r.x || y != r.y || z != r.z ||
101 roll != r.roll || pitch != r.pitch || yaw != r.yaw) {
102 return true;
103 }
104 return false;
105 }
106
111 inline bool operator==(const Map2DObject& r) const
112 {
113 if (
114 map_id == r.map_id && x == r.x && y == r.y && z == r.z &&
115 roll == r.roll && pitch == r.pitch && yaw == r.yaw) {
116 return true;
117 }
118 return false;
119 }
120
125 bool is_near_to(const Map2DObject& other_loc, double linear_tolerance) const;
126 bool is_near_to(const Map2DLocation& other_loc, double linear_tolerance) const;
127
131 bool read(yarp::os::idl::WireReader& reader) override
132 {
133 return Map2DObjectData::read(reader);
134 }
135 bool write(const yarp::os::idl::WireWriter& writer) const override
136 {
137 return Map2DObjectData::write(writer);
138 }
139 bool read(yarp::os::ConnectionReader& reader) override
140 {
141 return Map2DObjectData::read(reader);
142 }
143 bool write(yarp::os::ConnectionWriter& writer) const override
144 {
145 return Map2DObjectData::write(writer);
146 }
147};
148} // namespace yarp::dev::Nav2D
149
150#endif // YARP_DEV_MAP2DLOCATION_H
contains the definition of a Map2DLocation type
contains definitions for common types used in navigation interfaces
double yaw
orientation [deg] in the map reference frame
double y
y position of the location [m], expressed in the map reference frame
double pitch
orientation [deg] in the map reference frame
double roll
orientation [deg] in the map reference frame
std::string map_id
name of the map
double z
z position of the location [m], expressed in the map reference frame
double x
x position of the location [m], expressed in the map reference frame
An interface for reading from a network connection.
An interface for writing to a network connection.
IDL-friendly connection reader.
Definition WireReader.h:27
IDL-friendly connection writer.
Definition WireWriter.h:28
bool write(const yarp::os::idl::WireWriter &writer) const override
std::string toString() const
Returns text representation of the object.
Definition Map2DObject.h:82
bool read(yarp::os::ConnectionReader &reader) override
Read this object from a network connection.
bool read(yarp::os::idl::WireReader &reader) override
Serialization methods.
Map2DObject(const std::string &map_name, const double &inX, const double &inY, const double &inZ, const double &inr=0, const double &inp=0, const double &iny=0, const std::string &desc="")
Constructor.
Definition Map2DObject.h:31
Map2DObject(const std::string &map_name, const yarp::dev::Nav2D::XYWorld &object, const std::string &desc="")
A constructor which accepts a yarp::math::Vec2D, defining the object by its x,y coordinates.
Definition Map2DObject.h:51
bool operator!=(const Map2DObject &r) const
Compares two Map2DObjects.
Definition Map2DObject.h:97
Map2DObject()
Default constructor: the map name is empty, coordinates are set to zero.
Definition Map2DObject.h:66
bool operator==(const Map2DObject &r) const
Compares two Map2DObjects.
bool write(yarp::os::ConnectionWriter &writer) const override
Write this object to a network connection.
#define YARP_dev_API
Definition api.h:18