YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Map2DLocation.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_DEV_MAP2DLOCATION_H
7#define YARP_DEV_MAP2DLOCATION_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>
16
20namespace yarp::dev::Nav2D {
22{
30 Map2DLocation(const std::string& map_name, const double& inX, const double& inY, const double& inT, const std::string& desc = "")
31 {
32 map_id = map_name;
33 x = inX;
34 y = inY;
35 theta = inT;
36 description = desc;
37 }
38
47 Map2DLocation(const std::string& map_name, const yarp::dev::Nav2D::XYWorld& location, const std::string& desc = "")
48 {
49 map_id = map_name;
50 x = location.x;
51 y = location.y;
52 theta = 0;
53 description = desc;
54 }
55
60 {
61 map_id = "";
62 description = "";
63 x = 0;
64 y = 0;
65 theta = 0;
66 }
67
72 std::string toString() const
73 {
74 std::ostringstream stringStream;
75 stringStream.precision(-1);
76 stringStream.width(-1);
77 stringStream << std::string("map_id:") << map_id << std::string(" x:") << x << std::string(" y:") << y << std::string(" theta:") << theta;
78 stringStream << std::string("desc:") << description;
79 return stringStream.str();
80 }
81
86 inline bool operator!=(const Map2DLocation& r) const
87 {
88 if (
89 map_id != r.map_id || x != r.x || y != r.y || theta != r.theta) {
90 return true;
91 }
92 return false;
93 }
94
99 inline bool operator==(const Map2DLocation& r) const
100 {
101 if (
102 map_id == r.map_id && x == r.x && y == r.y && theta == r.theta) {
103 return true;
104 }
105 return false;
106 }
107
112 bool is_near_to(const Map2DLocation& other_loc, double linear_tolerance, double angular_tolerance) const;
113
117 bool read(yarp::os::idl::WireReader& reader) override
118 {
119 return Map2DLocationData::read(reader);
120 }
121 bool write(const yarp::os::idl::WireWriter& writer) const override
122 {
123 return Map2DLocationData::write(writer);
124 }
125 bool read(yarp::os::ConnectionReader& reader) override
126 {
127 return Map2DLocationData::read(reader);
128 }
129 bool write(yarp::os::ConnectionWriter& writer) const override
130 {
131 return Map2DLocationData::write(writer);
132 }
133};
134} // namespace yarp::dev::Nav2D
135
136#endif // YARP_DEV_MAP2DLOCATION_H
contains definitions for common types used in navigation interfaces
std::string map_id
name of the map
double theta
orientation [deg] in the map reference frame
double y
y 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
bool write(yarp::os::ConnectionWriter &writer) const override
Write this object to a network connection.
bool operator==(const Map2DLocation &r) const
Compares two Map2DLocations.
Map2DLocation(const std::string &map_name, const yarp::dev::Nav2D::XYWorld &location, const std::string &desc="")
A constructor which accepts a yarp::math::Vec2D, defining the location by its x,y coordinates.
bool read(yarp::os::ConnectionReader &reader) override
Read this object from a network connection.
Map2DLocation(const std::string &map_name, const double &inX, const double &inY, const double &inT, const std::string &desc="")
Constructor.
std::string toString() const
Returns text representation of the location.
Map2DLocation()
Default constructor: the map name is empty, coordinates are set to zero.
bool operator!=(const Map2DLocation &r) const
Compares two Map2DLocations.
bool read(yarp::os::idl::WireReader &reader) override
Serialization methods.
#define YARP_dev_API
Definition api.h:18