YARP
Yet Another Robot Platform
FrameTransformSet_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_FRAMETRANSFORMSETNWCROS_H
7 #define YARP_DEV_FRAMETRANSFORMSETNWCROS_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 "/tfNodeSet"
32 #define ROSTOPICNAME_TF "/tf"
33 #define ROSTOPICNAME_TF_STATIC "/tf_static"
34 
74 {
75 public:
76  FrameTransformSet_nwc_ros(double tperiod=0.010);
78 
79  //DeviceDriver
80  bool open(yarp::os::Searchable& config) override;
81  bool close() override;
82 
83  //periodicThread
84  void run() override;
85 
86  //IFrameTransformStorageSet interface
87  bool setTransforms(const std::vector<yarp::math::FrameTransform>& transforms) override;
88  bool setTransform(const yarp::math::FrameTransform& transform) override;
89  bool deleteTransform(std::string t1, std::string t2) override;
90  bool clearAll() override;
91 
92  //own
93  void publishFrameTransforms(const std::vector<yarp::math::FrameTransform>& transforms);
95 
96 private:
97  mutable std::mutex m_trf_mutex;
98  std::string m_nodeName{ROSNODENAME};
99  std::string m_topic{ROSTOPICNAME_TF};
100  std::string m_topic_static{ROSTOPICNAME_TF_STATIC};
101  double m_period{0.01};
102  double m_refreshInterval{0.1};
103  bool m_asynchPub{true};
104  yarp::os::Node* m_rosNode{nullptr};
105  yarp::os::Publisher<yarp::rosmsg::tf2_msgs::TFMessage> m_rosPublisherPort_tf_timed;
106  yarp::os::Publisher<yarp::rosmsg::tf2_msgs::TFMessage> m_rosPublisherPort_tf_static;
107  FrameTransformContainer m_ftContainer;
108 };
109 
110 #endif // YARP_DEV_FRAMETRANSFORMSETNWCROS_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...
frameTransformSet_nwc_ros: A network wrapper client which publishes the transforms received on the ya...
~FrameTransformSet_nwc_ros()=default
bool close() override
Close the DeviceDriver.
bool clearAll() override
Delete all transforms in a storage.
void publishFrameTransforms(const std::vector< yarp::math::FrameTransform > &transforms)
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
void run() override
Loop function.
bool setTransform(const yarp::math::FrameTransform &transform) override
Save a frame transform in a storage.
bool setTransforms(const std::vector< yarp::math::FrameTransform > &transforms) override
Save some frame transforms in a storage.
bool deleteTransform(std::string t1, std::string t2) override
Delete a single transform in the storage.
void yarpTransformToROSTransform(const yarp::math::FrameTransform &input, yarp::rosmsg::geometry_msgs::TransformStamped &output)
FrameTransformSet_nwc_ros(double tperiod=0.010)
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