YARP
Yet Another Robot Platform
ServerInertial.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_DEV_SERVERINERTIAL_SERVERINERTIAL_H
8#define YARP_DEV_SERVERINERTIAL_SERVERINERTIAL_H
9
10#include <cstdio>
11
13#include <yarp/dev/PolyDriver.h>
15#include <yarp/os/Time.h>
16#include <yarp/os/Network.h>
17#include <yarp/os/Thread.h>
18#include <yarp/os/Vocab.h>
19#include <yarp/os/Bottle.h>
21#include <yarp/dev/IWrapper.h>
23
24// ROS state publisher
25#include <yarp/os/Node.h>
26#include <yarp/os/Publisher.h>
29
30
107 public yarp::dev::IWrapper,
109 private yarp::os::Thread,
112{
113private:
114 bool spoke;
115 std::string partName;
116 yarp::dev::PolyDriver *IMU_polydriver;
117 yarp::dev::IGenericSensor *IMU; //The inertial device
119 double period;
122 int prev_timestamp_counter;
123 int curr_timestamp_counter;
124 int trap;
125 bool strict;
126
127 // ROS data
128 ROSTopicUsageType useROS; // decide if open ROS topic or not
129 std::string frame_id; // name of the frame measures are referred to
130 std::string rosNodeName; // name of the rosNode
131 std::string rosTopicName; // name of the rosTopic
132 yarp::os::Node *rosNode; // add a ROS node
133 yarp::os::NetUint32 rosMsgCounter; // incremental counter in the ROS message
134 yarp::os::Publisher<yarp::rosmsg::sensor_msgs::Imu> rosPublisherPort; // Dedicated ROS topic publisher
135 std::vector<yarp::os::NetFloat64> covariance; // empty matrix to store covariance data needed by ROS msg
136
137 bool checkROSParams(yarp::os::Searchable &config);
138 bool initialize_ROS();
139 bool initialize_YARP(yarp::os::Searchable &prop);
140
141public:
147 ~ServerInertial() override;
148
154 bool open(yarp::os::Searchable& config) override;
155
156 bool close() override;
157
158 virtual bool getInertial(yarp::os::Bottle &bot);
159
160 void run() override;
161
162 bool read(yarp::os::ConnectionReader& connection) override;
163
164 bool read(yarp::sig::Vector &out) override;
165
166 bool getChannels(int *nc) override;
167
168 bool calibrate(int ch, double v) override;
169
175 bool attach(yarp::dev::PolyDriver *poly) override;
176 bool detach() override;
177
183 bool attachAll(const yarp::dev::PolyDriverList &p) override;
184 bool detachAll() override;
185
186private:
187
188 bool ownDevices;
189 yarp::dev::PolyDriver *subDeviceOwned;
190
191 // Open the wrapper only, the attach method needs to be called before using it
192 bool openDeferredAttach(yarp::os::Property& prop);
193
194 // If a subdevice parameter is given to the wrapper, it will open it as well
195 // and attach to it immediately.
196 bool openAndAttachSubDevice(yarp::os::Property& prop);
197};
198
199
200#endif // YARP_DEV_SERVERINERTIAL_SERVERINERTIAL_H
inertial deprecated: Export an inertial sensor.
bool attach(yarp::dev::PolyDriver *poly) override
IWrapper interface Attach to another object.
bool close() override
Close the DeviceDriver.
ServerInertial & operator=(ServerInertial &&)=delete
ServerInertial & operator=(const ServerInertial &)=delete
bool open(yarp::os::Searchable &config) override
Open the device driver.
bool detach() override
Detach the object (you must have first called attach).
ServerInertial(ServerInertial &&)=delete
virtual bool getInertial(yarp::os::Bottle &bot)
bool calibrate(int ch, double v) override
Calibrate the sensor, single channel.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
void run() override
Main body of the new thread.
~ServerInertial() override
ServerInertial(const ServerInertial &)=delete
bool attachAll(const yarp::dev::PolyDriverList &p) override
IMultipleWrapper interface Attach to a list of objects.
ServerInertial()
Constructor.
bool getChannels(int *nc) override
Get the number of channels of the sensor.
bool detachAll() override
Detach the object (you must have first called attach).
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
A generic interface to sensors – gyro, a/d converters etc.
Interface for an object that can wrap/attach to to another.
Interface for an object that can wrap/or "attach" to another.
Definition: IWrapper.h:25
A container for a device driver.
Definition: PolyDriver.h:23
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:64
An interface for reading from a network connection.
The Node class.
Definition: Node.h:23
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:24
A mini-server for network communication.
Definition: Port.h:46
A class for storing options and configuration information.
Definition: Property.h:33
A base class for nested structures that can be searched.
Definition: Searchable.h:63
An abstraction for a thread of execution.
Definition: Thread.h:21
std::uint32_t NetUint32
Definition of the NetUint32 type.
Definition: NetUint32.h:29
ROSTopicUsageType
Definition: yarpRosHelper.h:16