YARP
Yet Another Robot Platform
Odometry2D_nws_yarp.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_ODOMETRY2D_NWS_YARP_H
7#define YARP_ODOMETRY2D_NWS_YARP_H
8
10#include <yarp/os/Stamp.h>
11
16#include <yarp/os/RpcServer.h>
17
18#define DEFAULT_THREAD_PERIOD 0.02 //s
19
81{
82public:
85
86 // DeviceDriver
87 bool open(yarp::os::Searchable &params) override;
88 bool close() override;
89
90 // WrapperSingle
91 bool attach(yarp::dev::PolyDriver* driver) override;
92 bool detach() override;
93
94 // PeriodicThread
95 bool threadInit() override;
96 void threadRelease() override;
97 void run() override;
98
99private:
100 //thrift
101 IOdometry2DRPCd m_RPC;
102
103 //rpc port
104 bool read(yarp::os::ConnectionReader& connection) override;
105
106 //buffered ports
110 yarp::os::RpcServer m_rpcPort;
111
112 //yarp streaming data
113 std::string m_local_name = "/odometry2D_nws_yarp";
114 std::string m_odometerStreamingPortName;
115 std::string m_odometryStreamingPortName;
116 std::string m_velocityStreamingPortName;
117 std::string m_rpcPortName;
118 std::string m_deviceName;
119 size_t m_stampCount{0};
120 yarp::dev::OdometryData m_oldOdometryData{0,0,0,0,0,0,0,0,0};
121
122 // thread
123 double m_period{DEFAULT_THREAD_PERIOD};
124
125 // timestamp
126 yarp::os::Stamp m_lastStateStamp;
127
128 //interfaces
129 yarp::dev::PolyDriver m_driver;
130 yarp::dev::Nav2D::IOdometry2D *m_odometry2D_interface{nullptr};
131
132};
133
134#endif // YARP_ODOMETRY2D_NWS_YARP_H
#define DEFAULT_THREAD_PERIOD
Odometry2D_nws_yarp: A yarp nws to get the odometry and publish it on 3 yarp ports:
bool close() override
Close the DeviceDriver.
bool attach(yarp::dev::PolyDriver *driver) override
Attach to another object.
bool detach() override
Detach the object (you must have first called attach).
void run() override
Loop function.
bool threadInit() override
Initialization method.
bool open(yarp::os::Searchable &params) override
Open the DeviceDriver.
void threadRelease() override
Release method.
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
An interface for reading from a network connection.
An abstraction for a periodic thread.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:24
A port that is specialized as an RPC server.
Definition: RpcServer.h:23
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