24constexpr
double DEFAULT_PERIOD = 0.01;
25constexpr
int DEFAULT_NCHANNELS = 12;
26constexpr
double DEFAULT_DUMMY_VALUE = 0.0;
27constexpr const
char* DEFAULT_SENSOR_NAME = "sensorName";
28constexpr const
char* DEFAULT_FRAME_NAME = "frameName";
30constexpr
double EARTH_GRAVITY = -9.81;
40 gravity({0.0, 0.0, EARTH_GRAVITY, 0.0}),
42 accels({0.0, 0.0, 0.0, 0.0}),
43 nchannels(DEFAULT_NCHANNELS),
44 dummy_value(DEFAULT_DUMMY_VALUE),
45 m_sensorName(DEFAULT_SENSOR_NAME),
46 m_frameName(DEFAULT_FRAME_NAME)
59 if( config.
check(
"period")) {
63 yCInfo(FAKEIMU) <<
"Using default period of " << DEFAULT_PERIOD <<
" s";
66 constantValue = config.
check(
"constantValue");
80 if (out.
size() != nchannels) {
87 for(
unsigned int i=0; i<3; i++)
93 for(
unsigned int i=0; i<3; i++)
99 for(
unsigned int i=0; i<3; i++)
101 out[6+i] = dummy_value;
105 for(
unsigned int i=0; i<3; i++)
107 out[9+i] = dummy_value;
121 yCWarning(FAKEIMU,
"Not implemented yet");
125bool fakeIMU::threadInit()
134 static double count=10;
137 rpy[1] = count * 3.14/180;
141 accels = gravity * dcm;
146 if (!constantValue) {
164bool fakeIMU::genericGetSensorName(
size_t sens_index, std::string &name)
const
174bool fakeIMU::genericGetFrameName(
size_t sens_index, std::string &frameName)
const
180 frameName = m_frameName;
191 return genericGetStatus(sens_index);
196 return genericGetSensorName(sens_index, name);
201 return genericGetFrameName(sens_index, frameName);
211 out[0] = dummy_value;
212 out[1] = dummy_value;
213 out[2] = dummy_value;
217 timestamp = copyStamp.
getTime();
229 return genericGetStatus(sens_index);
234 return genericGetSensorName(sens_index, name);
239 return genericGetFrameName(sens_index, frameName);
255 timestamp = copyStamp.
getTime();
267 return genericGetStatus(sens_index);
272 return genericGetSensorName(sens_index, name);
277 return genericGetFrameName(sens_index, frameName);
287 out[0] = dummy_value;
288 out[1] = dummy_value;
289 out[2] = dummy_value;
293 timestamp = copyStamp.
getTime();
305 return genericGetStatus(sens_index);
310 return genericGetSensorName(sens_index, name);
315 return genericGetFrameName(sens_index, frameName);
325 rpy_out[0] = dummy_value;
326 rpy_out[1] = dummy_value;
327 rpy_out[2] = dummy_value;
331 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.
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.
bool setPeriod(double period)
Set the (new) period of the thread.
bool start()
Call this to start the 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 bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
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,...)
For streams capable of holding different kinds of content, check what they actually have.
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.