YARP
Yet Another Robot Platform
FrameTransformGet_nwc_ros.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_FRAMETRANSFORMGETNWCROS_H
7 #define YARP_DEV_FRAMETRANSFORMGETNWCROS_H
8 
9 
10 #include <yarp/os/Network.h>
11 #include <yarp/os/Node.h>
12 #include <yarp/os/PeriodicThread.h>
13 #include <yarp/os/Publisher.h>
14 #include <yarp/os/Subscriber.h>
15 
16 #include <yarp/sig/Vector.h>
17 
19 #include <yarp/dev/PolyDriver.h>
20 #include <yarp/dev/WrapperSingle.h>
21 
23 
26 
28 #include <map>
29 #include <mutex>
30 
31 #define ROSNODENAME "/tfNodeGet"
32 #define ROSTOPICNAME_TF "/tf"
33 #define ROSTOPICNAME_TF_STATIC "/tf_static"
34 
72 {
73 public:
74  FrameTransformGet_nwc_ros(double tperiod=0.010);
76 
77  //DeviceDriver
78  bool open(yarp::os::Searchable& config) override;
79  bool close() override;
80 
81  //periodicThread
82  void run() override;
83 
84  //IFrameTransformStorageGet interface
85  bool getTransforms(std::vector<yarp::math::FrameTransform>& transforms) const override;
86 
87  //own
90  double yarpStampFromROS(const yarp::rosmsg::TickTime& rosTime);
91 
92 private:
93  mutable std::mutex m_trf_mutex;
94  std::string m_nodeName{ROSNODENAME};
95  std::string m_topic{ROSTOPICNAME_TF};
96  std::string m_topic_static{ROSTOPICNAME_TF_STATIC};
97  double m_period{0.01};
98  double m_refreshInterval{0.1};
99  yarp::os::Node* m_rosNode{nullptr};
100  yarp::os::Subscriber<yarp::rosmsg::tf2_msgs::TFMessage> m_rosSubscriberPort_tf_timed;
101  yarp::os::Subscriber<yarp::rosmsg::tf2_msgs::TFMessage> m_rosSubscriberPort_tf_static;
102  FrameTransformContainer m_ftContainer;
103 };
104 
105 #endif // YARP_DEV_FRAMETRANSFORMGETNWCROS_H
#define ROSNODENAME
#define ROSTOPICNAME_TF
#define ROSTOPICNAME_TF_STATIC
contains the definition of a Vector type
FrameTransformContainer: A class that contains a vector of frame transformations and exposes yarp::de...
frameTransformGet_nwc_ros: A ros network wrapper client that receives frame transforms from a ros top...
~FrameTransformGet_nwc_ros()=default
bool getTransforms(std::vector< yarp::math::FrameTransform > &transforms) const override
Obtains all frame transforms saved in a storage.
void rosTransformToYARPTransform(const yarp::rosmsg::geometry_msgs::TransformStamped &input, yarp::math::FrameTransform &output, bool isStatic)
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool close() override
Close the DeviceDriver.
double yarpStampFromROS(const yarp::rosmsg::TickTime &rosTime)
FrameTransformGet_nwc_ros(double tperiod=0.010)
void run() override
Loop function.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
The Node class.
Definition: Node.h:24
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition: Searchable.h:66