YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Map2DObject.cpp
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
7#include <yarp/os/Log.h>
9#include <yarp/os/LogStream.h>
10#include <math.h>
11
12using namespace yarp::dev::Nav2D;
13
14YARP_LOG_COMPONENT(MAP2DOBJECT, "yarp.Map2DObject")
15
16bool Map2DObject::is_near_to(const Map2DObject& other_loc, double linear_tolerance) const
17{
18 if (linear_tolerance < 0) {
19 return false;
20 }
21
22 yCAssert(MAP2DOBJECT, linear_tolerance >= 0);
23
24 if (this->map_id != other_loc.map_id)
25 {
26 return false;
27 }
28 if (sqrt(pow((this->x - other_loc.x), 2) +
29 pow((this->y - other_loc.y), 2) +
30 pow((this->z - other_loc.z), 2)) > linear_tolerance)
31 {
32 return false;
33 }
34
35 return true;
36}
37
38bool Map2DObject::is_near_to(const Map2DLocation& other_loc, double linear_tolerance) const
39{
40 if (linear_tolerance < 0) {
41 return false;
42 }
43
44 yCAssert(MAP2DOBJECT, linear_tolerance >= 0);
45
46 if (this->map_id != other_loc.map_id)
47 {
48 return false;
49 }
50 if (sqrt(pow((this->x - other_loc.x), 2) +
51 pow((this->y - other_loc.y), 2)) > linear_tolerance)
52 {
53 return false;
54 }
55
56 return true;
57}
const yarp::os::LogComponent & MAP2DOBJECT()
contains the definition of a Map2DObject type
std::string map_id
name of the map
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
double y
y position of the location [m], expressed in the map reference frame
std::string map_id
name of the map
double x
x position of the location [m], expressed in the map reference frame
#define yCAssert(component, x)
#define YARP_LOG_COMPONENT(name,...)
bool is_near_to(const Map2DObject &other_loc, double linear_tolerance) const
Compares two Map2DObjects.