YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
Odometry2D_nws_ros2.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_ROS2_ODOMETRY2D_NWS_ROS2_H
7#define YARP_ROS2_ODOMETRY2D_NWS_ROS2_H
8#include <rclcpp/rclcpp.hpp>
9#include <nav_msgs/msg/odometry.hpp>
10
13#include <yarp/os/Stamp.h>
16#include <tf2_msgs/msg/tf_message.hpp>
17
19
20#ifndef _USE_MATH_DEFINES
21#define _USE_MATH_DEFINES
22#endif
23
24#define DEG2RAD M_PI/180.0
25#define DEFAULT_THREAD_PERIOD 0.02 //s
26
87{
88public:
91
92 // DeviceDriver
93 bool open(yarp::os::Searchable &params) override;
94 bool close() override;
95
96 // WrapperSingle
97 bool attach(yarp::dev::PolyDriver* driver) override;
98 bool detach() override;
99
100 // PeriodicThread
101 bool threadInit() override;
102 void threadRelease() override;
103 void run() override;
104
105
106private:
107 // stamp count for timestamp
108 yarp::os::Stamp m_timeStamp;
109
110 //ros2 node
111 rclcpp::Node::SharedPtr m_node;
112 rclcpp::Publisher<nav_msgs::msg::Odometry>::SharedPtr m_ros2Publisher_odometry;
113 rclcpp::Publisher<tf2_msgs::msg::TFMessage>::SharedPtr m_publisher_tf;
114
115 //interfaces
116 yarp::dev::PolyDriver m_driver;
117 yarp::dev::Nav2D::IOdometry2D *m_odometry2D_interface{nullptr};
118};
119
120#endif // YARP_ROS2_ODOMETRY2D_NWS_ROS2_H
This class is the parameters parser for class Odometry2D_nws_ros2.
Odometry2D_nws_ros2: A ros2 nws to get odometry and publish it on a ros2 topic. The attached device m...
void run() override
Loop function.
bool threadInit() override
Initialization method.
bool close() override
Close the DeviceDriver.
bool attach(yarp::dev::PolyDriver *driver) override
Attach to another object.
void threadRelease() override
Release method.
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
bool detach() override
Detach the object (you must have first called attach).
Interface implemented by all device drivers.
IOdometry2D interface.
Definition IOdometry2D.h:23
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.
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition Searchable.h:31
An abstraction for a time stamp and/or sequence number.
Definition Stamp.h:21