YARP
Yet Another Robot Platform
fakeIMU.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#include <string>
11#include <yarp/os/Stamp.h>
12#include <yarp/math/Math.h>
13
30class fakeIMU :
38{
39public:
40 fakeIMU();
41 fakeIMU(const fakeIMU&) = delete;
42 fakeIMU(fakeIMU&&) = delete;
43 fakeIMU& operator=(const fakeIMU&) = delete;
45
46 ~fakeIMU() override;
47
48 // Device Driver interface
49 bool open(yarp::os::Searchable &config) override;
50 bool close() override;
51
52 // IGenericSensor interface.
53 bool read(yarp::sig::Vector &out) override;
54 bool getChannels(int *nc) override;
55 bool calibrate(int ch, double v) override;
56
57 /* IThreeAxisGyroscopes methods */
58 size_t getNrOfThreeAxisGyroscopes() const override;
59 yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override;
60 bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override;
61 bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override;
62 bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
63
64 /* IThreeAxisLinearAccelerometers methods */
65 size_t getNrOfThreeAxisLinearAccelerometers() const override;
66 yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override;
67 bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override;
68 bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override;
69 bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
70
71 /* IThreeAxisMagnetometers methods */
72 size_t getNrOfThreeAxisMagnetometers() const override;
73 yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override;
74 bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override;
75 bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override;
76 bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
77
78 /* IOrientationSensors methods */
79 size_t getNrOfOrientationSensors() const override;
80 yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
81 bool getOrientationSensorName(size_t sens_index, std::string &name) const override;
82 bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override;
83 bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& rpy, double& timestamp) const override;
84
85private:
86 yarp::dev::MAS_status genericGetStatus(size_t sens_index) const;
87 bool genericGetSensorName(size_t sens_index, std::string &name) const;
88 bool genericGetFrameName(size_t sens_index, std::string &frameName) const;
89
90 bool threadInit() override;
91 void run() override;
92
94 yarp::sig::Vector gravity;
96 yarp::sig::Vector accels;
97
98 unsigned int nchannels;
99 double dummy_value;
100 yarp::os::Stamp lastStamp;
101 std::string m_sensorName;
102 std::string m_frameName;
103 bool constantValue;
104};
fakeIMU : fake device implementing the device interface typically implemented by an Inertial Measurem...
Definition: fakeIMU.h:38
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
Definition: fakeIMU.cpp:298
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:199
bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: fakeIMU.cpp:270
fakeIMU(const fakeIMU &)=delete
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: fakeIMU.cpp:194
bool close() override
Close the DeviceDriver.
Definition: fakeIMU.cpp:72
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: fakeIMU.cpp:56
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: fakeIMU.cpp:189
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of magnetometers exposed by this device.
Definition: fakeIMU.cpp:260
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:237
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: fakeIMU.cpp:265
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double &timestamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
Definition: fakeIMU.cpp:318
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:313
fakeIMU & operator=(fakeIMU &&)=delete
bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: fakeIMU.cpp:280
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: fakeIMU.cpp:227
bool getChannels(int *nc) override
Get the number of channels of the sensor.
Definition: fakeIMU.cpp:113
~fakeIMU() override
Definition: fakeIMU.cpp:51
fakeIMU(fakeIMU &&)=delete
bool read(yarp::sig::Vector &out) override
Read a vector from the sensor.
Definition: fakeIMU.cpp:78
fakeIMU()
This device implements a fake analog sensor emulating an IMU.
Definition: fakeIMU.cpp:37
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the specified sensor.
Definition: fakeIMU.cpp:242
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
Definition: fakeIMU.cpp:222
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the gyroscope.
Definition: fakeIMU.cpp:204
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: fakeIMU.cpp:308
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: fakeIMU.cpp:232
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: fakeIMU.cpp:303
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:275
fakeIMU & operator=(const fakeIMU &)=delete
bool calibrate(int ch, double v) override
Calibrate the sensor, single channel.
Definition: fakeIMU.cpp:119
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes exposed by this sensor.
Definition: fakeIMU.cpp:184
Interface implemented by all device drivers.
Definition: DeviceDriver.h:30
A generic interface to sensors – gyro, a/d converters etc.
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
Device interface to one or multiple three axis gyroscopes.
Device interface to one or multiple three axis linear accelerometers.
Device interface to one or multiple three axis magnetometers.
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
A class for a Matrix.
Definition: Matrix.h:39
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.