iCub-main
iCubSimulationIMU.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <string>
10 #include <mutex>
11 #include <yarp/dev/DeviceDriver.h>
12 #include <yarp/dev/IGenericSensor.h>
13 #include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
14 #include <yarp/os/Stamp.h>
15 #include <yarp/dev/IPreciselyTimed.h>
16 
17 
18 
19 #ifndef __iCubSimulationIMUh__
20 #define __iCubSimulationIMUh__
21 
23  public yarp::dev::DeviceDriver,
24  public yarp::dev::IThreeAxisGyroscopes,
25  public yarp::dev::IThreeAxisLinearAccelerometers,
26  public yarp::dev::IThreeAxisMagnetometers,
27  public yarp::dev::IOrientationSensors
28 {
29 public:
31  virtual ~iCubSimulationIMU();
32 
33  // Device Driver interface
34  bool open(yarp::os::Searchable &config) override;
35  bool close() override;
36 
37  /* IThreeAxisGyroscopes methods */
38  size_t getNrOfThreeAxisGyroscopes() const override;
39  yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override;
40  bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override;
41  bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override;
42  bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
43 
44  /* IThreeAxisLinearAccelerometers methods */
45  size_t getNrOfThreeAxisLinearAccelerometers() const override;
46  yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override;
47  bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override;
48  bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override;
49  bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
50 
51  /* IThreeAxisMagnetometers methods */
52  size_t getNrOfThreeAxisMagnetometers() const override;
53  yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override;
54  bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override;
55  bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override;
56  bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
57 
58  /* IOrientationSensors methods */
59  size_t getNrOfOrientationSensors() const override;
60  yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
61  bool getOrientationSensorName(size_t sens_index, std::string &name) const override;
62  bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override;
63  bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& rpy, double& timestamp) const override;
64 
65  void updateIMUData(const yarp::os::Bottle& imuData);
66 
67  yarp::sig::Vector gyro, rpy, magn, accels;
68 
69 private:
70  yarp::dev::MAS_status genericGetStatus(size_t sens_index) const;
71  bool genericGetSensorName(size_t sens_index, std::string &name) const;
72  bool genericGetFrameName(size_t sens_index, std::string &frameName) const;
73 
74  yarp::os::Stamp lastStamp;
75  std::string m_sensorName;
76  std::string m_frameName;
77  mutable std::mutex m_mutex;
78 
79 };
80 
81 #endif // __iCubSimulationIMUh__
size_t getNrOfThreeAxisLinearAccelerometers() const override
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
out
Definition: sine.m:8
yarp::sig::Vector gyro
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
yarp::sig::Vector magn
void updateIMUData(const yarp::os::Bottle &imuData)
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
bool close() override
bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double &timestamp) const override
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
yarp::sig::Vector accels
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
size_t getNrOfOrientationSensors() const override
size_t getNrOfThreeAxisMagnetometers() const override
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
size_t getNrOfThreeAxisGyroscopes() const override
yarp::sig::Vector rpy
bool open(yarp::os::Searchable &config) override
bool getOrientationSensorName(size_t sens_index, std::string &name) const override