YARP
Yet Another Robot Platform
Odometry2D_nws_ros.h
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
6#ifndef YARP_ODOMETRY2D_NWS_YARP_H
7#define YARP_ODOMETRY2D_NWS_YARP_H
8
9#include <yarp/os/Node.h>
11#include <yarp/os/Publisher.h>
12#include <yarp/os/Stamp.h>
13
17
21
22#ifndef _USE_MATH_DEFINES
23#define _USE_MATH_DEFINES
24#endif
25
26#define DEG2RAD M_PI/180.0
27#define DEFAULT_THREAD_PERIOD 0.02 //s
28
95// public yarp::os::PortReader
96{
97public:
100
101 // DeviceDriver
102 bool open(yarp::os::Searchable &params) override;
103 bool close() override;
104
105 // WrapperSingle
106 bool attach(yarp::dev::PolyDriver* driver) override;
107 bool detach() override;
108
109 // PeriodicThread
110 bool threadInit() override;
111 void threadRelease() override;
112 void run() override;
113
114
115private:
116 // parameters from configuration
117 std::string m_topicName;
118 std::string m_nodeName;
119 std::string m_odomFrame;
120 std::string m_baseFrame;
121 bool m_enable_publish_tf = true;
122
123 // timestamp
124 yarp::os::Stamp m_lastStateStamp;
125
126 // period for thread
127 double m_period{DEFAULT_THREAD_PERIOD};
128
129 //ros node
130 yarp::os::Node* m_node;
131
132 //interfaces
133 yarp::dev::PolyDriver m_driver;
134 yarp::dev::Nav2D::IOdometry2D *m_odometry2D_interface{nullptr};
137
138};
139
140#endif // YARP_ODOMETRY2D_NWS_YARP_H
#define DEFAULT_THREAD_PERIOD
Odometry2D_nws_ros: A ros nws to get odometry and publish it on a ros topic. The attached device must...
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
bool threadInit() override
Initialization method.
void run() override
Loop function.
void threadRelease() override
Release method.
bool attach(yarp::dev::PolyDriver *driver) override
Attach to another object.
bool close() override
Close the DeviceDriver.
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
IOdometry2D interface.
Definition: IOdometry2D.h:22
A container for a device driver.
Definition: PolyDriver.h:23
Helper interface for an object that can wrap/or "attach" to a single other device.
Definition: WrapperSingle.h:31
The Node class.
Definition: Node.h:23
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition: Searchable.h:63
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:21