YARP
Yet Another Robot Platform
Localization2DServer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <yarp/os/Network.h>
20 #include <yarp/os/RFModule.h>
21 #include <yarp/os/Time.h>
22 #include <yarp/os/Port.h>
23 #include <yarp/os/LogComponent.h>
24 #include <yarp/os/LogStream.h>
25 #include <yarp/dev/PolyDriver.h>
26 #include <yarp/os/Bottle.h>
27 #include <yarp/sig/Vector.h>
28 #include <yarp/dev/IMap2D.h>
31 #include <yarp/math/Math.h>
32 #include "Localization2DServer.h"
33 
34 #include <cmath>
35 
38 using namespace yarp::os;
39 using namespace yarp::dev;
40 using namespace yarp::dev::Nav2D;
41 using namespace std;
42 
43 #define DEFAULT_THREAD_PERIOD 0.01
44 
45 #ifndef M_PI
46 #define M_PI 3.14159265358979323846
47 #endif
48 
49 namespace {
50 YARP_LOG_COMPONENT(LOCALIZATION2DSERVER, "yarp.device.localization2DServer")
51 }
52 
53 //------------------------------------------------------------------------------------------------------------------------------
54 
56 {
57  m_ros_node = nullptr;
61  iLoc = nullptr;
65 }
66 
68 {
69  if (device2attach.size() != 1)
70  {
71  yCError(LOCALIZATION2DSERVER, "Cannot attach more than one device");
72  return false;
73  }
74 
75  yarp::dev::PolyDriver * Idevice2attach = device2attach[0]->poly;
76 
77  if (Idevice2attach->isValid())
78  {
79  Idevice2attach->view(iLoc);
80  }
81 
82  if (nullptr == iLoc)
83  {
84  yCError(LOCALIZATION2DSERVER, "Subdevice passed to attach method is invalid");
85  return false;
86  }
87 
88  //initialize m_current_position and m_current_status, if available
89  bool ret = true;
91  Map2DLocation loc;
92  ret &= iLoc->getLocalizationStatus(status);
93  ret &= iLoc->getCurrentPosition(loc);
94  if (ret)
95  {
96  m_current_status = status;
97  m_current_position = loc;
98  }
99  else
100  {
101  yCWarning(LOCALIZATION2DSERVER) << "Localization data not yet available during server initialization";
102  }
103 
104  PeriodicThread::setPeriod(m_period);
105  return PeriodicThread::start();
106 }
107 
109 {
110  if (PeriodicThread::isRunning())
111  {
112  PeriodicThread::stop();
113  }
114  iLoc = nullptr;
115  return true;
116 }
117 
119 {
120  Property params;
121  params.fromString(config.toString().c_str());
122  yCDebug(LOCALIZATION2DSERVER) << "Configuration: \n" << config.toString().c_str();
123 
124  if (config.check("GENERAL") == false)
125  {
126  yCWarning(LOCALIZATION2DSERVER) << "Missing GENERAL group, assuming default options";
127  }
128 
129  Bottle& general_group = config.findGroup("GENERAL");
130  if (!general_group.check("period"))
131  {
132  yCInfo(LOCALIZATION2DSERVER) << "Missing 'period' parameter. Using default value: " << DEFAULT_THREAD_PERIOD;
134  }
135  else
136  {
137  m_period = general_group.find("period").asFloat64();
138  yCInfo(LOCALIZATION2DSERVER) << "Period requested: " << m_period;
139  }
140 
141  if (!general_group.check("retrieve_position_periodically"))
142  {
143  yCInfo(LOCALIZATION2DSERVER) << "Missing 'retrieve_position_periodically' parameter. Using default value: true. Period:" << m_period ;
145  }
146  else
147  {
148  m_getdata_using_periodic_thread = general_group.find("retrieve_position_periodically").asBool();
150  { yCInfo(LOCALIZATION2DSERVER) << "retrieve_position_periodically requested, Period:" << m_period; }
151  else
152  { yCInfo(LOCALIZATION2DSERVER) << "retrieve_position_periodically NOT requested. Localization data obtained asynchronously."; }
153  }
154 
155 
156  m_local_name = "/localizationServer";
157  if (!general_group.check("name"))
158  {
159  yCInfo(LOCALIZATION2DSERVER) << "Missing 'name' parameter. Using default value: /localizationServer";
160  }
161  else
162  {
163  m_local_name = general_group.find("name").asString();
164  if (m_local_name.c_str()[0] != '/') { yCError(LOCALIZATION2DSERVER) << "Missing '/' in name parameter" ; return false; }
165  yCInfo(LOCALIZATION2DSERVER) << "Using local name:" << m_local_name;
166  }
167 
168  m_rpcPortName = m_local_name + "/rpc";
169  m_2DLocationPortName = m_local_name + "/streaming:o";
170  m_odometryPortName = m_local_name + "/odometry:o";
171 
172  if (config.check("subdevice"))
173  {
174  Property p;
175  PolyDriverList driverlist;
176  p.fromString(config.toString(), false);
177  p.put("device", config.find("subdevice").asString());
178 
179  if (!pLoc.open(p) || !pLoc.isValid())
180  {
181  yCError(LOCALIZATION2DSERVER) << "Failed to open subdevice.. check params";
182  return false;
183  }
184 
185  driverlist.push(&pLoc, "1");
186  if (!attachAll(driverlist))
187  {
188  yCError(LOCALIZATION2DSERVER) << "Failed to open subdevice.. check params";
189  return false;
190  }
191  }
192  else
193  {
194  yCInfo(LOCALIZATION2DSERVER) << "Waiting for device to attach";
195  }
197 
198  if (!initialize_YARP(config))
199  {
200  yCError(LOCALIZATION2DSERVER) << "Error initializing YARP ports";
201  return false;
202  }
203 
204  if (!initialize_ROS(config))
205  {
206  yCError(LOCALIZATION2DSERVER) << "Error initializing ROS system";
207  return false;
208  }
209 
210  return true;
211 }
212 
214 {
215  if (params.check("ROS"))
216  {
217  Bottle& ros_group = params.findGroup("ROS");
218  if (ros_group.check("publish_tf"))
219  {
221  }
222  if (ros_group.check("publish_odom"))
223  {
225  }
226 
227  if (!ros_group.check("parent_frame_id"))
228  {
229  yCError(LOCALIZATION2DSERVER) << "Missing 'parent_frame_id' parameter";
230  //return false;
231  }
232  else
233  {
234  m_parent_frame_id = ros_group.find("parent_frame_id").asString();
235  }
236  if (!ros_group.check("child_frame_id"))
237  {
238  yCError(LOCALIZATION2DSERVER) << "Missing 'child_frame_id' parameter";
239  //return false;
240  }
241  else
242  {
243  m_child_frame_id = ros_group.find("child_frame_id").asString();
244  }
245 
246  }
247  else
248  {
249  yCInfo(LOCALIZATION2DSERVER) << "ROS initialization not requested";
250  return true;
251  }
252 
253  if (m_ros_node == nullptr)
254  {
255  bool b= false;
256  m_ros_node = new yarp::os::Node(m_local_name+"_ROSnode");
257  if (m_ros_node == nullptr)
258  {
259  yCError(LOCALIZATION2DSERVER) << "Opening " << m_local_name << " Node, check your yarp-ROS network configuration";
260  }
261 
262  string ros_odom_topic = m_local_name + string("/odom");
263  b = m_odometry_publisher.topic(ros_odom_topic);
264  if (!b)
265  {
266  yCError(LOCALIZATION2DSERVER) << "Unable to publish data on" << ros_odom_topic << "topic";
267  }
268  b = m_tf_publisher.topic("/tf");
269  if (!b)
270  {
271  yCError(LOCALIZATION2DSERVER) << "Unable to publish data on /tf topic";
272  }
273  yCInfo(LOCALIZATION2DSERVER) << "ROS initialized";
274  }
275  return true;
276 }
277 
279 {
281  {
282  yCError(LOCALIZATION2DSERVER, "Failed to open port %s", m_2DLocationPortName.c_str());
283  return false;
284  }
285 
286  if (!m_odometryPort.open(m_odometryPortName.c_str()))
287  {
288  yCError(LOCALIZATION2DSERVER, "Failed to open port %s", m_odometryPortName.c_str());
289  return false;
290  }
291 
292  if (!m_rpcPort.open(m_rpcPortName.c_str()))
293  {
294  yCError(LOCALIZATION2DSERVER, "Failed to open port %s", m_rpcPortName.c_str());
295  return false;
296  }
297  m_rpcPort.setReader(*this);
298 
299  return true;
300 }
301 
303 {
304  yCTrace(LOCALIZATION2DSERVER, "Close");
305  if (PeriodicThread::isRunning())
306  {
307  PeriodicThread::stop();
308  }
309 
310  detachAll();
311 
317  m_rpcPort.close();
318 
319  if (m_ros_node)
320  {
323  delete m_ros_node;
324  m_ros_node = nullptr;
325  }
326 
327  yCDebug(LOCALIZATION2DSERVER) << "Execution terminated";
328  return true;
329 }
330 
332 {
333  yarp::os::Bottle command;
334  yarp::os::Bottle reply;
335  bool ok = command.read(connection);
336  if (!ok) return false;
337 
338  reply.clear();
339 
340  if (command.get(0).isVocab())
341  {
342  if (command.get(0).asVocab() == VOCAB_INAVIGATION && command.get(1).isVocab())
343  {
344  int request = command.get(1).asVocab();
345  if (request == VOCAB_NAV_GET_CURRENT_POS)
346  {
347  bool b = true;
349  {
350  //m_current_position is obtained by run()
351  }
352  else
353  {
354  //m_current_position is obtained by getCurrentPosition()
356  }
357  if (b)
358  {
359  reply.addVocab(VOCAB_OK);
364  }
365  else
366  {
367  reply.addVocab(VOCAB_ERR);
368  }
369  }
370  else if (request == VOCAB_NAV_GET_ESTIMATED_ODOM)
371  {
372  bool b = true;
374  {
375  //m_current_position is obtained by run()
376  }
377  else
378  {
379  //m_current_position is obtained by getCurrentPosition()
381  }
382  if (b)
383  {
384  reply.addVocab(VOCAB_OK);
394  }
395  else
396  {
397  reply.addVocab(VOCAB_ERR);
398  }
399  }
400  else if (request == VOCAB_NAV_SET_INITIAL_POS)
401  {
402  Map2DLocation init_loc;
403  init_loc.map_id = command.get(2).asString();
404  init_loc.x = command.get(3).asFloat64();
405  init_loc.y = command.get(4).asFloat64();
406  init_loc.theta = command.get(5).asFloat64();
407  iLoc->setInitialPose(init_loc);
408  reply.addVocab(VOCAB_OK);
409  }
410  else if (request == VOCAB_NAV_GET_CURRENT_POSCOV)
411  {
412  Map2DLocation init_loc;
413  yarp::sig::Matrix cov(3, 3);
414  iLoc->getCurrentPosition(init_loc, cov);
415  reply.addVocab(VOCAB_OK);
420  yarp::os::Bottle& mc = reply.addList();
421  for (size_t i = 0; i < 3; i++) { for (size_t j = 0; j < 3; j++) { mc.addFloat64(cov[i][j]); } }
422  }
423  else if (request == VOCAB_NAV_SET_INITIAL_POSCOV)
424  {
425  Map2DLocation init_loc;
426  yarp::sig::Matrix cov(3,3);
427  init_loc.map_id = command.get(2).asString();
428  init_loc.x = command.get(3).asFloat64();
429  init_loc.y = command.get(4).asFloat64();
430  init_loc.theta = command.get(5).asFloat64();
431  Bottle* mc = command.get(6).asList();
432  if (mc!=nullptr && mc->size() == 9)
433  {
434  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(); } }
435  bool ret = iLoc->setInitialPose(init_loc, cov);
436  if (ret) { reply.addVocab(VOCAB_OK); }
437  else { reply.addVocab(VOCAB_ERR); }
438  }
439  else
440  {
441  reply.addVocab(VOCAB_ERR);
442  }
443  }
444  else if (request == VOCAB_NAV_LOCALIZATION_START)
445  {
447  reply.addVocab(VOCAB_OK);
448  }
449  else if (request == VOCAB_NAV_LOCALIZATION_STOP)
450  {
452  reply.addVocab(VOCAB_OK);
453  }
454  else if (request == VOCAB_NAV_GET_LOCALIZER_STATUS)
455  {
457  {
458  //m_current_status is obtained by run()
459  reply.addVocab(VOCAB_OK);
460  reply.addVocab(m_current_status);
461  }
462  else
463  {
464  //m_current_status is obtained by getLocalizationStatus()
466  reply.addVocab(VOCAB_OK);
467  reply.addVocab(m_current_status);
468  }
469  }
470  else if (request == VOCAB_NAV_GET_LOCALIZER_POSES)
471  {
472  std::vector<Map2DLocation> poses;
473  iLoc->getEstimatedPoses(poses);
474  reply.addVocab(VOCAB_OK);
475  reply.addInt32(poses.size());
476  for (size_t i=0; i<poses.size(); i++)
477  {
478  Bottle& b = reply.addList();
479  b.addString(poses[i].map_id);
480  b.addFloat64(poses[i].x);
481  b.addFloat64(poses[i].y);
482  b.addFloat64(poses[i].theta);
483  }
484  }
485  else
486  {
487  reply.addVocab(VOCAB_ERR);
488  }
489  }
490  else
491  {
492  yCError(LOCALIZATION2DSERVER) << "Invalid vocab received";
493  reply.addVocab(VOCAB_ERR);
494  }
495  }
496  else if (command.get(0).isString() && command.get(0).asString() == "help")
497  {
498  reply.addVocab(Vocab::encode("many"));
499  reply.addString("Available commands are:");
500  reply.addString("getLoc");
501  reply.addString("initLoc <map_name> <x> <y> <angle in degrees>");
502  }
503  else if (command.get(0).isString() && command.get(0).asString() == "getLoc")
504  {
505  Map2DLocation curr_loc;
506  iLoc->getCurrentPosition(curr_loc);
507  std::string s = std::string("Current Location is: ") + curr_loc.toString();
508  reply.addString(s);
509  }
510  else if (command.get(0).isString() && command.get(0).asString() == "initLoc")
511  {
512  Map2DLocation init_loc;
513  init_loc.map_id = command.get(1).asString();
514  init_loc.x = command.get(2).asFloat64();
515  init_loc.y = command.get(3).asFloat64();
516  init_loc.theta = command.get(4).asFloat64();
517  iLoc->setInitialPose(init_loc);
518  std::string s = std::string("Localization initialized to: ") + init_loc.toString();
519  reply.addString(s);
520  }
521  else
522  {
523  yCError(LOCALIZATION2DSERVER) << "Invalid command type";
524  reply.addVocab(VOCAB_ERR);
525  }
526 
527  yarp::os::ConnectionWriter *returnToSender = connection.getWriter();
528  if (returnToSender != nullptr)
529  {
530  reply.write(*returnToSender);
531  }
532 
533  return true;
534 }
535 
537 {
538  double m_stats_time_curr = yarp::os::Time::now();
539  if (m_stats_time_curr - m_stats_time_last > 5.0)
540  {
541  yCInfo(LOCALIZATION2DSERVER) << "Running";
543  }
544 
546  {
548  if (ret == false)
549  {
550  yCError(LOCALIZATION2DSERVER) << "getLocalizationStatus() failed";
551  }
552 
554  {
555  //update the stamp
556 
557 
559  if (ret2 == false)
560  {
561  yCError(LOCALIZATION2DSERVER) << "getCurrentPosition() failed";
562  }
563  else
564  {
566  }
568  if (ret3 == false)
569  {
570  //yCError(LOCALIZATION2DSERVER) << "getEstimatedOdometry() failed";
571  }
572  else
573  {
575  }
576  }
577  else
578  {
579  yCWarning(LOCALIZATION2DSERVER, "The system is not properly localized!");
580  }
581  }
582 
583  if (1) publish_odometry_on_yarp_port();
584  if (1) publish_2DLocation_on_yarp_port();
585  if (m_ros_publish_odometry_on_topic) publish_odometry_on_ROS_topic();
586  if (m_ros_publish_odometry_on_tf) publish_odometry_on_TF_topic();
587 
588 }
589 
590 void Localization2DServer::publish_odometry_on_yarp_port()
591 {
592  if (m_odometryPort.getOutputCount() > 0)
593  {
595  odom = m_current_odometry;
596 
597  //send data to port
600  }
601 }
602 
603 void Localization2DServer::publish_2DLocation_on_yarp_port()
604 {
606  {
609  {
610  loc = m_current_position;
611  }
612  else
613  {
614  Map2DLocation temp_loc;
615  temp_loc.x = std::nan("");
616  temp_loc.y = std::nan("");
617  temp_loc.theta = std::nan("");
618  loc = temp_loc;
619  }
620 
621  //send data to port
624  }
625 }
626 
627 void Localization2DServer::publish_odometry_on_TF_topic()
628 {
631  transform.child_frame_id = m_child_frame_id;
632  transform.header.frame_id = m_parent_frame_id;
633  transform.header.seq = m_odom_stamp.getCount();
634  transform.header.stamp = m_odom_stamp.getTime();
635  double halfYaw = m_current_odometry.odom_theta / 180.0 * M_PI * 0.5;
636  double cosYaw = cos(halfYaw);
637  double sinYaw = sin(halfYaw);
638  transform.transform.rotation.x = 0;
639  transform.transform.rotation.y = 0;
640  transform.transform.rotation.z = sinYaw;
641  transform.transform.rotation.w = cosYaw;
644  transform.transform.translation.z = 0;
645  if (rosData.transforms.size() == 0)
646  {
647  rosData.transforms.push_back(transform);
648  }
649  else
650  {
651  rosData.transforms[0] = transform;
652  }
653 
655 }
656 
657 void Localization2DServer::publish_odometry_on_ROS_topic()
658 {
660  {
662  odom.clear();
664  odom.header.seq = m_odom_stamp.getCount();
665  odom.header.stamp = m_odom_stamp.getTime();
667 
670  odom.pose.pose.position.z = 0;
671  yarp::sig::Vector vecrpy(3);
672  vecrpy[0] = 0;
673  vecrpy[1] = 0;
674  vecrpy[2] = m_current_odometry.odom_theta;
675  yarp::sig::Matrix matrix = yarp::math::rpy2dcm(vecrpy);
677  odom.pose.pose.orientation.x = q.x();
678  odom.pose.pose.orientation.y = q.y();
679  odom.pose.pose.orientation.z = q.z();
680  odom.pose.pose.orientation.w = q.w();
681  //odom.pose.covariance = 0;
682 
685  odom.twist.twist.linear.z = 0;
686  odom.twist.twist.angular.x = 0;
687  odom.twist.twist.angular.y = 0;
689  //odom.twist.covariance = 0;
690 
692  }
693 }
define control board standard interfaces
constexpr yarp::conf::vocab32_t VOCAB_OK
Definition: GenericVocabs.h:18
constexpr yarp::conf::vocab32_t VOCAB_ERR
Definition: GenericVocabs.h:20
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 ret
#define DEFAULT_THREAD_PERIOD
#define M_PI
contains the definition of a Vector type
bool initialize_ROS(yarp::os::Searchable &config)
yarp::dev::Nav2D::Map2DLocation m_current_position
yarp::dev::Nav2D::ILocalization2D * iLoc
yarp::os::BufferedPort< yarp::dev::Nav2D::Map2DLocation > m_2DLocationPort
virtual bool attachAll(const yarp::dev::PolyDriverList &l) override
Attach to a list of objects.
yarp::dev::PolyDriver pLoc
virtual bool close() override
Close the DeviceDriver.
yarp::dev::Nav2D::LocalizationStatusEnum m_current_status
virtual bool detachAll() override
Detach the object (you must have first called attach).
yarp::os::BufferedPort< yarp::dev::OdometryData > m_odometryPort
yarp::os::Publisher< yarp::rosmsg::nav_msgs::Odometry > m_odometry_publisher
yarp::os::Node * m_ros_node
virtual bool open(yarp::os::Searchable &prop) override
Open the DeviceDriver.
yarp::os::Stamp m_loc_stamp
virtual void run() override
Loop function.
yarp::os::Publisher< yarp::rosmsg::tf2_msgs::TFMessage > m_tf_publisher
yarp::os::Stamp m_odom_stamp
yarp::dev::OdometryData m_current_odometry
virtual bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool initialize_YARP(yarp::os::Searchable &config)
bool view(T *&x)
Get an interface to the device driver.
Definition: DeviceDriver.h:77
virtual bool getEstimatedOdometry(yarp::dev::OdometryData &odom)=0
Gets the estimated odometry the robot, including its velocity expressed in the world and in the local...
virtual bool getCurrentPosition(yarp::dev::Nav2D::Map2DLocation &loc)=0
Gets the current position of the robot w.r.t world reference frame.
virtual bool getEstimatedPoses(std::vector< yarp::dev::Nav2D::Map2DLocation > &poses)=0
Gets a set of pose estimates computed by the localization algorithm.
virtual bool startLocalizationService()=0
Starts the localization service.
virtual bool stopLocalizationService()=0
Stops the localization service.
virtual bool 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 bool getLocalizationStatus(LocalizationStatusEnum &status)=0
Gets the current status of the localization task.
double base_vel_x
velocity of the robot [m/s] expressed in the robot reference frame
Definition: OdometryData.h:45
double odom_vel_y
velocity of the robot [m/s] expressed in the world reference frame
Definition: OdometryData.h:61
double base_vel_theta
angular velocity of the robot [deg/s] expressed in the robot reference frame
Definition: OdometryData.h:53
double odom_vel_theta
angular velocity of the robot [deg/s] expressed in the world reference frame
Definition: OdometryData.h:65
double base_vel_y
velocity of the robot [m/s] expressed in the robot reference frame
Definition: OdometryData.h:49
double odom_x
position of the robot [m], expressed in the world reference frame
Definition: OdometryData.h:33
double odom_y
position of the robot [m], expressed in the world reference frame
Definition: OdometryData.h:37
double odom_theta
orientation the robot [deg], expressed in the world reference frame
Definition: OdometryData.h:41
double odom_vel_x
velocity of the robot [m/s] expressed in the world reference frame
Definition: OdometryData.h:57
void push(PolyDriver *p, const char *k)
A container for a device driver.
Definition: PolyDriver.h:27
bool isValid() const
Check if device is valid.
Definition: PolyDriver.cpp:199
bool open(const std::string &txt)
Construct and configure a device by its common name.
Definition: PolyDriver.cpp:143
void fromRotationMatrix(const yarp::sig::Matrix &R)
Converts a rotation matrix to a quaternion.
Definition: Quaternion.cpp:154
double x() const
Definition: Quaternion.cpp:75
double z() const
Definition: Quaternion.cpp:85
double w() const
Definition: Quaternion.cpp:70
double y() const
Definition: Quaternion.cpp:80
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
Definition: Bottle.cpp:185
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:254
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Definition: Bottle.cpp:243
void addFloat64(yarp::conf::float64_t x)
Places a 64-bit floating point number in the bottle, at the end of the list.
Definition: Bottle.cpp:161
void addVocab(int x)
Places a vocabulary item in the bottle, at the end of the list.
Definition: Bottle.cpp:167
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Definition: Bottle.cpp:280
void clear()
Empties the bottle of any objects it contains.
Definition: Bottle.cpp:124
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
Definition: Bottle.cpp:233
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
Definition: Bottle.cpp:143
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition: Bottle.cpp:173
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Bottle.cpp:290
void close() override
Stop port activity.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void interrupt() override
Interrupt any current reads or writes attached to the port.
int getOutputCount() override
Determine how many output connections this port has.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
An interface for reading from a network connection.
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
An interface for writing to a network connection.
The Node class.
Definition: Node.h:27
An abstraction for a periodic thread.
int getOutputCount() override
Determine how many output connections this port has.
Definition: Port.cpp:561
void setReader(PortReader &reader) override
Set an external reader for port data.
Definition: Port.cpp:505
void interrupt() override
Interrupt any current reads or writes attached to the port.
Definition: Port.cpp:377
void close() override
Stop port activity.
Definition: Port.cpp:357
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:82
A class for storing options and configuration information.
Definition: Property.h:37
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
Definition: Property.cpp:1046
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition: Property.cpp:998
void close() override
Stop port activity.
Definition: Publisher.h:88
bool topic(const std::string &name)
Set topic to publish to.
Definition: Publisher.h:67
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::Publisher::write.
Definition: Publisher.h:127
void write(bool forceStrict=false)
Write the current object being returned by Publisher::prepare.
Definition: Publisher.h:152
Port & asPort() override
Get the concrete Port being used for communication.
Definition: Publisher.h:172
A base class for nested structures that can be searched.
Definition: Searchable.h:69
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
Definition: Stamp.cpp:113
double getTime() const
Get the time stamp.
Definition: Stamp.cpp:37
int getCount() const
Get the sequence number.
Definition: Stamp.cpp:32
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition: Value.cpp:225
virtual bool isString() const
Checks if value is a string.
Definition: Value.cpp:159
virtual bool isVocab() const
Checks if value is a vocabulary identifier.
Definition: Value.cpp:177
virtual bool asBool() const
Get boolean value.
Definition: Value.cpp:189
virtual Bottle * asList() const
Get list value.
Definition: Value.cpp:243
virtual std::int32_t asVocab() const
Get vocabulary identifier as an integer.
Definition: Value.cpp:231
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
yarp::conf::float64_t y
Definition: Point.h:36
yarp::conf::float64_t x
Definition: Point.h:35
yarp::conf::float64_t z
Definition: Point.h:37
yarp::rosmsg::geometry_msgs::Point position
Definition: Pose.h:36
yarp::rosmsg::geometry_msgs::Quaternion orientation
Definition: Pose.h:37
yarp::rosmsg::geometry_msgs::Transform transform
yarp::rosmsg::geometry_msgs::Quaternion rotation
Definition: Transform.h:38
yarp::rosmsg::geometry_msgs::Vector3 translation
Definition: Transform.h:37
yarp::rosmsg::geometry_msgs::Vector3 angular
Definition: Twist.h:36
yarp::rosmsg::geometry_msgs::Vector3 linear
Definition: Twist.h:35
yarp::conf::float64_t y
Definition: Vector3.h:41
yarp::conf::float64_t z
Definition: Vector3.h:42
yarp::conf::float64_t x
Definition: Vector3.h:40
yarp::rosmsg::geometry_msgs::PoseWithCovariance pose
Definition: Odometry.h:43
yarp::rosmsg::std_msgs::Header header
Definition: Odometry.h:41
yarp::rosmsg::geometry_msgs::TwistWithCovariance twist
Definition: Odometry.h:44
yarp::rosmsg::TickTime stamp
Definition: Header.h:48
std::vector< yarp::rosmsg::geometry_msgs::TransformStamped > transforms
Definition: TFMessage.h:33
A class for a Matrix.
Definition: Matrix.h:46
#define yCInfo(component,...)
Definition: LogComponent.h:135
#define yCError(component,...)
Definition: LogComponent.h:157
#define yCTrace(component,...)
Definition: LogComponent.h:88
#define yCWarning(component,...)
Definition: LogComponent.h:146
#define yCDebug(component,...)
Definition: LogComponent.h:112
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:80
@ localization_status_not_yet_localized
An interface for the device drivers.
yarp::sig::Matrix rpy2dcm(const yarp::sig::Vector &rpy)
Converts roll-pitch-yaw angles in the corresponding dcm (direction cosine matrix) rotation matrix (de...
Definition: math.cpp:818
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition: Time.cpp:124
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition: Vocab.cpp:14
An interface to the operating system, including Port based communication.
std::string toString() const
Returns text representation of the location.
Definition: Map2DLocation.h:77