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>
13 #include <yarp/math/Math.h>
14 
31 class fakeIMU :
40 {
41 public:
42  fakeIMU();
43  fakeIMU(const fakeIMU&) = delete;
44  fakeIMU(fakeIMU&&) = delete;
45  fakeIMU& operator=(const fakeIMU&) = delete;
46  fakeIMU& operator=(fakeIMU&&) = delete;
47 
48  ~fakeIMU() override;
49 
50  // Device Driver interface
51  bool open(yarp::os::Searchable &config) override;
52  bool close() override;
53 
54  // IGenericSensor interface.
55  bool read(yarp::sig::Vector &out) override;
56  bool getChannels(int *nc) override;
57  bool calibrate(int ch, double v) override;
58 
59  // IPreciselyTimed interface
61 
62  /* IThreeAxisGyroscopes methods */
63  size_t getNrOfThreeAxisGyroscopes() const override;
64  yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override;
65  bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override;
66  bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override;
67  bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
68 
69  /* IThreeAxisLinearAccelerometers methods */
70  size_t getNrOfThreeAxisLinearAccelerometers() const override;
71  yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override;
72  bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override;
73  bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override;
74  bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
75 
76  /* IThreeAxisMagnetometers methods */
77  size_t getNrOfThreeAxisMagnetometers() const override;
78  yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override;
79  bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override;
80  bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override;
81  bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
82 
83  /* IOrientationSensors methods */
84  size_t getNrOfOrientationSensors() const override;
85  yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
86  bool getOrientationSensorName(size_t sens_index, std::string &name) const override;
87  bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override;
88  bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& rpy, double& timestamp) const override;
89 
90 private:
91  yarp::dev::MAS_status genericGetStatus(size_t sens_index) const;
92  bool genericGetSensorName(size_t sens_index, std::string &name) const;
93  bool genericGetFrameName(size_t sens_index, std::string &frameName) const;
94 
95  bool threadInit() override;
96  void run() override;
97 
99  yarp::sig::Vector gravity;
100  yarp::sig::Matrix dcm;
101  yarp::sig::Vector accels;
102 
103  unsigned int nchannels;
104  double dummy_value;
105  yarp::os::Stamp lastStamp;
106  std::string m_sensorName;
107  std::string m_frameName;
108  bool constantValue;
109 };
fakeIMU : fake device implementing the device interface typically implemented by an Inertial Measurem...
Definition: fakeIMU.h:40
fakeIMU & operator=(const fakeIMU &)=delete
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
Definition: fakeIMU.cpp:303
fakeIMU & operator=(fakeIMU &&)=delete
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:204
bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: fakeIMU.cpp:275
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:199
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:194
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of magnetometers exposed by this device.
Definition: fakeIMU.cpp:265
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:242
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: fakeIMU.cpp:270
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:323
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:318
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:285
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: fakeIMU.cpp:232
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:247
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
Definition: fakeIMU.cpp:227
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last reading of the gyroscope.
Definition: fakeIMU.cpp:209
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: fakeIMU.cpp:313
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
Definition: fakeIMU.cpp:237
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
Definition: fakeIMU.cpp:308
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
Definition: fakeIMU.cpp:280
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
Definition: fakeIMU.cpp:155
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:189
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
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:66
An abstraction for a time stamp and/or sequence number.
Definition: Stamp.h:22
A class for a Matrix.
Definition: Matrix.h:43
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.