YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ILocalization2DServerImpl.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
7#include <yarp/os/LogStream.h>
10
13using namespace yarp::os;
14using namespace yarp::dev;
15using namespace yarp::dev::Nav2D;
16using namespace std;
17
18#define DEFAULT_THREAD_PERIOD 0.01
19
20#ifndef M_PI
21#define M_PI 3.14159265358979323846
22#endif
23
24namespace {
25YARP_LOG_COMPONENT(LOCALIZATION2DSERVER, "yarp.device.localization2DServer")
26}
27
28#define CHECK_POINTER(xxx) {if (xxx==nullptr) {yCError(LOCALIZATION2DSERVER, "Invalid interface"); return false;}}
29
31{
32 std::lock_guard <std::mutex> lg(m_mutex);
33
34 auto ret = m_iLoc->startLocalizationService();
35 if (!ret)
36 {
37 yCError(LOCALIZATION2DSERVER, "Unable to startLocalizationService");
38 }
39 return ret;
40}
41
43{
44 std::lock_guard <std::mutex> lg(m_mutex);
45
46 auto ret = m_iLoc->stopLocalizationService();
47 if (!ret)
48 {
49 yCError(LOCALIZATION2DSERVER, "Unable to stopLocalizationService");
50 }
51 return ret;
52}
53
55{
56 std::lock_guard <std::mutex> lg(m_mutex);
57
60 {
61 ret.ret = ReturnValue::return_code::return_value_ok;
63 return ret;
64 }
65
67 ret.ret = m_iLoc->getLocalizationStatus(status);
68 if (!ret.ret)
69 {
70 yCError(LOCALIZATION2DSERVER, "Unable to getLocalizationStatus");
72 }
73 else
74 {
76 }
77 return ret;
78}
79
81{
82 std::lock_guard <std::mutex> lg(m_mutex);
83
85 std::vector<yarp::dev::Nav2D::Map2DLocation> poses;
86 ret.ret = m_iLoc->getEstimatedPoses(poses);
87 if (ret.ret)
88 {
89 yCError(LOCALIZATION2DSERVER, "Unable to getEstimatedPoses");
90 }
91 else
92 {
93 ret.poses=poses;
94 }
95 return ret;
96}
97
99{
100 std::lock_guard <std::mutex> lg(m_mutex);
101
104 {
105 ret.ret = ReturnValue::return_code::return_value_ok;
106 ret.loc = this->m_current_position;
107 return ret;
108 }
109
111 ret.ret = m_iLoc->getCurrentPosition(pos);
112 if (!ret.ret)
113 {
114 yCError(LOCALIZATION2DSERVER, "Unable to getCurrentPosition");
115 }
116 else
117 {
118 ret.loc = pos;
119 }
120 return ret;
121}
122
124{
125 std::lock_guard <std::mutex> lg(m_mutex);
126
130 ret.ret = m_iLoc->getCurrentPosition(pos, cov);
131 if (ret.ret)
132 {
133 yCError(LOCALIZATION2DSERVER, "Unable to getCurrentPosition");
134 }
135 else
136 {
137 ret.loc=pos;
138 ret.cov=cov;
139 }
140 return ret;
141}
142
144{
145 std::lock_guard <std::mutex> lg(m_mutex);
146
149 {
150 ret.ret = ReturnValue::return_code::return_value_ok;
151 ret.odom = this->m_current_odometry;
152 return ret;
153 }
154
156 ret.ret = m_iLoc->getEstimatedOdometry(odom);
157 if (!ret.ret)
158 {
159 yCError(LOCALIZATION2DSERVER, "Unable to getEstimatedOdometry");
160 }
161 else
162 {
163 ret.odom = odom;
164 }
165 return ret;
166}
167
169{
170 std::lock_guard <std::mutex> lg(m_mutex);
171
172 auto ret = m_iLoc->setInitialPose(loc);
173 if (!ret)
174 {
175 yCError(LOCALIZATION2DSERVER, "Unable to setInitialPose");
176 }
177 return ret;
178}
179
181{
182 std::lock_guard <std::mutex> lg(m_mutex);
183
184 auto ret = m_iLoc->setInitialPose(loc,cov);
185 if (!ret)
186 {
187 yCError(LOCALIZATION2DSERVER, "Unable to setInitialPose");
188 }
189 return ret;
190}
bool ret
yarp::dev::OdometryData m_current_odometry
return_get_current_position1 get_current_position1_RPC() override
return_get_current_position2 get_current_position2_RPC() override
yarp::dev::ReturnValue stop_localization_service_RPC() override
yarp::dev::ReturnValue set_initial_pose1_RPC(const yarp::dev::Nav2D::Map2DLocation &loc) override
yarp::dev::Nav2D::LocalizationStatusEnum m_current_status
yarp::dev::ReturnValue start_localization_service_RPC() override
return_get_estimated_odometry get_estimated_odometry_RPC() override
return_get_localization_status get_localization_status_RPC() override
yarp::dev::ReturnValue set_initial_pose2_RPC(const yarp::dev::Nav2D::Map2DLocation &loc, const yarp::sig::Matrix &cov) override
yarp::dev::Nav2D::Map2DLocation m_current_position
return_get_estimated_poses get_estimated_poses_RPC() override
virtual yarp::dev::ReturnValue stopLocalizationService()=0
Stops the localization service.
virtual yarp::dev::ReturnValue getLocalizationStatus(LocalizationStatusEnum &status)=0
Gets the current status of the localization task.
virtual yarp::dev::ReturnValue setInitialPose(const yarp::dev::Nav2D::Map2DLocation &loc)=0
Sets the initial pose for the localization algorithm which estimates the current position of the robo...
virtual yarp::dev::ReturnValue getCurrentPosition(yarp::dev::Nav2D::Map2DLocation &loc)=0
Gets the current position of the robot w.r.t world reference frame.
virtual yarp::dev::ReturnValue startLocalizationService()=0
Starts the localization service.
virtual yarp::dev::ReturnValue getEstimatedPoses(std::vector< yarp::dev::Nav2D::Map2DLocation > &poses)=0
Gets a set of pose estimates computed by the localization algorithm.
virtual yarp::dev::ReturnValue getEstimatedOdometry(yarp::dev::OdometryData &odom)=0
Gets the estimated odometry the robot, including its velocity expressed in the world and in the local...
A mini-server for performing network communication in the background.
A class for a Matrix.
Definition Matrix.h:39
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
STL namespace.
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.