28 constexpr
int DEFAULT_NCHANNELS = 12;
29 constexpr
double DEFAULT_DUMMY_VALUE = 0.0;
30 constexpr const
char* DEFAULT_SENSOR_NAME = "sensorName";
31 constexpr const
char* DEFAULT_FRAME_NAME = "frameName";
33 constexpr
double EARTH_GRAVITY = -9.81;
43 gravity({0.0, 0.0, EARTH_GRAVITY, 0.0}),
45 accels({0.0, 0.0, 0.0, 0.0}),
46 nchannels(DEFAULT_NCHANNELS),
47 dummy_value(DEFAULT_DUMMY_VALUE),
48 m_sensorName(DEFAULT_SENSOR_NAME),
49 m_frameName(DEFAULT_FRAME_NAME)
62 if( config.
check(
"period")) {
69 constantValue = config.
check(
"constantValue");
83 if(out.
size() != nchannels)
89 for(
unsigned int i=0; i<3; i++)
95 for(
unsigned int i=0; i<3; i++)
101 for(
unsigned int i=0; i<3; i++)
103 out[6+i] = dummy_value;
107 for(
unsigned int i=0; i<3; i++)
109 out[9+i] = dummy_value;
123 yCWarning(FAKEIMU,
"Not implemented yet");
127 bool fakeIMU::threadInit()
136 static double count=10;
139 rpy[1] = count * 3.14/180;
143 accels = gravity * dcm;
148 if (!constantValue) {
170 bool fakeIMU::genericGetSensorName(
size_t sens_index, std::string &name)
const
180 bool fakeIMU::genericGetFrameName(
size_t sens_index, std::string &frameName)
const
186 frameName = m_frameName;
197 return genericGetStatus(sens_index);
202 return genericGetSensorName(sens_index, name);
207 return genericGetFrameName(sens_index, frameName);
217 out[0] = dummy_value;
218 out[1] = dummy_value;
219 out[2] = dummy_value;
223 timestamp = copyStamp.
getTime();
235 return genericGetStatus(sens_index);
240 return genericGetSensorName(sens_index, name);
245 return genericGetFrameName(sens_index, frameName);
261 timestamp = copyStamp.
getTime();
273 return genericGetStatus(sens_index);
278 return genericGetSensorName(sens_index, name);
283 return genericGetFrameName(sens_index, frameName);
293 out[0] = dummy_value;
294 out[1] = dummy_value;
295 out[2] = dummy_value;
299 timestamp = copyStamp.
getTime();
311 return genericGetStatus(sens_index);
316 return genericGetSensorName(sens_index, name);
321 return genericGetFrameName(sens_index, frameName);
331 rpy_out[0] = dummy_value;
332 rpy_out[1] = dummy_value;
333 rpy_out[2] = dummy_value;
337 timestamp = copyStamp.
getTime();
fakeIMU : fake device implementing the device interface typically implemented by an Inertial Measurem...
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
bool getThreeAxisGyroscopeFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getThreeAxisMagnetometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisGyroscopeName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::MAS_status getThreeAxisGyroscopeStatus(size_t sens_index) const override
Get the status of the specified sensor.
size_t getNrOfThreeAxisMagnetometers() const override
Get the number of magnetometers exposed by this device.
bool getThreeAxisLinearAccelerometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::MAS_status getThreeAxisMagnetometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &rpy, double ×tamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool getThreeAxisMagnetometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
yarp::dev::MAS_status getThreeAxisLinearAccelerometerStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getChannels(int *nc) override
Get the number of channels of the sensor.
bool read(yarp::sig::Vector &out) override
Read a vector from the sensor.
bool getThreeAxisLinearAccelerometerMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the specified sensor.
size_t getNrOfThreeAxisLinearAccelerometers() const override
Get the number of three axis linear accelerometers exposed by this device.
bool getThreeAxisGyroscopeMeasure(size_t sens_index, yarp::sig::Vector &out, double ×tamp) const override
Get the last reading of the gyroscope.
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool getThreeAxisLinearAccelerometerName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getThreeAxisMagnetometerFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
bool calibrate(int ch, double v) override
Calibrate the sensor, single channel.
size_t getNrOfThreeAxisGyroscopes() const override
Get the number of three axis gyroscopes exposed by this sensor.
An abstraction for a periodic thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
An abstraction for a time stamp and/or sequence number.
double getTime() const
Get the time stamp.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
void resize(size_t size) override
Resize the vector.
void zero()
Zero the elements of the vector.
#define yCInfo(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_ERROR
The sensor is in generic error state.
@ MAS_OK
The sensor is working correctly.
yarp::sig::Matrix rpy2dcm(const yarp::sig::Vector &rpy)
Converts roll-pitch-yaw angles in the corresponding dcm (direction cosine matrix) rotation matrix (de...
An interface to the operating system, including Port based communication.