42 m_remote_name.clear();
47 if (m_local_name ==
"")
49 yCError(LOCALIZATION2DCLIENT,
"open() error you have to provide a valid 'local' param");
53 if (m_remote_name ==
"")
55 yCError(LOCALIZATION2DCLIENT,
"open() error you have to provide valid 'remote' param");
62 remote_streaming_name,
65 local_rpc = m_local_name +
"/localization/rpc";
66 remote_rpc = m_remote_name +
"/rpc";
67 remote_streaming_name = m_remote_name +
"/stream:o";
68 local_streaming_name = m_local_name +
"/stream:i";
70 if (!m_rpc_port_localization_server.open(local_rpc))
72 yCError(LOCALIZATION2DCLIENT,
"open() error could not open rpc port %s, check network", local_rpc.c_str());
87 ok = Network::connect(local_rpc, remote_rpc);
90 yCError(LOCALIZATION2DCLIENT,
"open() error could not connect to %s", remote_rpc.c_str());
109 bool ret = m_rpc_port_localization_server.write(b, resp);
114 yCError(LOCALIZATION2DCLIENT) <<
"setInitialPose() received error from localization server";
120 yCError(LOCALIZATION2DCLIENT) <<
"setInitialPose() error on writing on rpc port";
128 if (cov.
rows() != 3 || cov.
cols() != 3)
130 yCError(LOCALIZATION2DCLIENT) <<
"Covariance matrix is expected to have size (3,3)";
143 for (
size_t i = 0; i < 3; i++) {
for (
size_t j = 0; j < 3; j++) { mc.
addFloat64(cov[i][j]); }}
145 bool ret = m_rpc_port_localization_server.write(b, resp);
150 yCError(LOCALIZATION2DCLIENT) <<
"setInitialPose() received error from localization server";
156 yCError(LOCALIZATION2DCLIENT) <<
"setInitialPose() error on writing on rpc port";
170 bool ret = m_rpc_port_localization_server.write(b, resp);
175 yCError(LOCALIZATION2DCLIENT) <<
"getEstimatedOdometry() received error from localization server";
194 yCError(LOCALIZATION2DCLIENT) <<
"getEstimatedOdometry() error on writing on rpc port";
208 bool ret = m_rpc_port_localization_server.write(b, resp);
213 yCError(LOCALIZATION2DCLIENT) <<
"getCurrentPosition() received error from localization server";
227 yCError(LOCALIZATION2DCLIENT) <<
"getCurrentPosition() error on writing on rpc port";
241 bool ret = m_rpc_port_localization_server.write(b, resp);
246 yCError(LOCALIZATION2DCLIENT) <<
"getCurrentPosition() received error from localization server";
251 if (cov.
rows() != 3 || cov.
cols() != 3)
253 yCDebug(LOCALIZATION2DCLIENT) <<
"Performance warning: covariance matrix is not (3,3), resizing...";
261 if (mc ==
nullptr)
return false;
262 for (
size_t i = 0; i < 3; i++) {
for (
size_t j = 0; j < 3; j++) { cov[i][j] = mc->
get(i*3+j).
asFloat64(); } }
268 yCError(LOCALIZATION2DCLIENT) <<
"getCurrentPosition() error on writing on rpc port";
282 bool ret = m_rpc_port_localization_server.write(b, resp);
287 yCError(LOCALIZATION2DCLIENT) <<
"getEstimatedPoses() received error from localization server";
294 for (
int i = 0; i < nposes; i++)
308 yCError(LOCALIZATION2DCLIENT) <<
"getEstimatedPoses() parsing error";
311 poses.push_back(loc);
318 yCError(LOCALIZATION2DCLIENT) <<
"getEstimatedPoses() error on writing on rpc port";
332 bool ret = m_rpc_port_localization_server.write(b, resp);
337 yCError(LOCALIZATION2DCLIENT) <<
"getLocalizationStatus() received error from localization server";
348 yCError(LOCALIZATION2DCLIENT) <<
"getLocalizationStatus() error on writing on rpc port";
362 bool ret = m_rpc_port_localization_server.write(b, resp);
367 yCError(LOCALIZATION2DCLIENT) <<
"startLocalizationService() received error from navigation server";
373 yCError(LOCALIZATION2DCLIENT) <<
"startLocalizationService() error on writing on rpc port";
387 bool ret = m_rpc_port_localization_server.write(b, resp);
392 yCError(LOCALIZATION2DCLIENT) <<
"stopLocalizationService() received error from navigation server";
398 yCError(LOCALIZATION2DCLIENT) <<
"stopLocalizationService() error on writing on rpc port";
406 m_rpc_port_localization_server.close();
constexpr yarp::conf::vocab32_t VOCAB_OK
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_LOCALIZER_POSES
constexpr yarp::conf::vocab32_t VOCAB_INAVIGATION
constexpr yarp::conf::vocab32_t VOCAB_NAV_LOCALIZATION_STOP
constexpr yarp::conf::vocab32_t VOCAB_NAV_SET_INITIAL_POSCOV
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_CURRENT_POS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_LOCALIZER_STATUS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_ESTIMATED_ODOM
constexpr yarp::conf::vocab32_t VOCAB_NAV_SET_INITIAL_POS
constexpr yarp::conf::vocab32_t VOCAB_NAV_GET_CURRENT_POSCOV
constexpr yarp::conf::vocab32_t VOCAB_NAV_LOCALIZATION_START
bool getEstimatedOdometry(yarp::dev::OdometryData &odom) override
Gets the estimated odometry the robot, including its velocity expressed in the world and in the local...
bool startLocalizationService() override
Starts the localization service.
bool getLocalizationStatus(yarp::dev::Nav2D::LocalizationStatusEnum &status) override
Gets the current status of the localization task.
bool close() override
Close the DeviceDriver.
bool getCurrentPosition(yarp::dev::Nav2D::Map2DLocation &loc) override
Gets the current position of the robot w.r.t world reference frame.
bool setInitialPose(const yarp::dev::Nav2D::Map2DLocation &loc) override
Sets the initial pose for the localization algorithm which estimates the current position of the robo...
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool stopLocalizationService() override
Stops the localization service.
bool getEstimatedPoses(std::vector< yarp::dev::Nav2D::Map2DLocation > &poses) override
Gets a set of pose estimates computed by the localization algorithm.
double base_vel_x
velocity of the robot [m/s] expressed in the robot reference frame
double odom_vel_y
velocity of the robot [m/s] expressed in the world reference frame
double base_vel_theta
angular velocity of the robot [deg/s] expressed in the robot reference frame
double odom_vel_theta
angular velocity of the robot [deg/s] expressed in the world reference frame
double base_vel_y
velocity of the robot [m/s] expressed in the robot reference frame
double odom_x
position of the robot [m], expressed in the world reference frame
double odom_y
position of the robot [m], expressed in the world reference frame
double odom_theta
orientation the robot [deg], expressed in the world reference frame
double odom_vel_x
velocity of the robot [m/s] expressed in the world reference frame
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
virtual std::string asString() const
Get string value.
void resize(size_t r, size_t c)
Resize the matrix, if matrix is not empty preserve old content.
size_t cols() const
Return number of columns.
size_t rows() const
Return number of rows.
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
An interface to the operating system, including Port based communication.