36 fprintf(stderr,
"%s\n", config.
toString().c_str());
40 yCError(FAKE_POSITION_SENSOR) <<
"Insufficient parameters to FakePositionSensor\n";
44 if (config.
check(
"sensor_period"))
51 this->m_channelsNum = 1;
52 m_orientation_sensors.resize(m_channelsNum);
53 m_position_sensors.resize(m_channelsNum);
55 return PeriodicThread::start();
62 PeriodicThread::stop();
80 for (
size_t i = 0; i < m_position_sensors.size(); i++)
82 m_position_sensors[i].m_timestamp = timeNow;
84 for (
auto it= m_position_sensors[i].m_data.begin(); it != m_position_sensors[i].m_data.end(); it++)
89 for (
size_t i = 0; i < m_orientation_sensors.size(); i++)
91 m_orientation_sensors[i].m_timestamp = timeNow;
93 for (
auto it = m_orientation_sensors[i].m_data.begin(); it != m_orientation_sensors[i].m_data.end(); it++)
110 std::lock_guard<std::mutex> myLockGuard(m_mutex);
111 return m_position_sensors.size();
116 std::lock_guard<std::mutex> myLockGuard (m_mutex);
118 return m_position_sensors[sens_index].m_status;
123 std::lock_guard<std::mutex> myLockGuard(m_mutex);
124 if (sens_index >= m_position_sensors.size())
return false;
125 name = m_position_sensors[sens_index].m_name;
131 std::lock_guard<std::mutex> myLockGuard(m_mutex);
132 if (sens_index >= m_position_sensors.size())
return false;
133 frameName = m_position_sensors[sens_index].m_framename;
139 std::lock_guard<std::mutex> myLockGuard(m_mutex);
140 if (sens_index >= m_position_sensors.size())
return false;
141 timestamp = m_position_sensors[sens_index].m_timestamp;
142 xyz = m_position_sensors[sens_index].m_data;
148 std::lock_guard<std::mutex> myLockGuard(m_mutex);
149 return m_orientation_sensors.size();
154 std::lock_guard<std::mutex> myLockGuard(m_mutex);
156 return m_orientation_sensors[sens_index].m_status;
161 std::lock_guard<std::mutex> myLockGuard(m_mutex);
162 if (sens_index >= m_orientation_sensors.size())
return false;
163 name = m_orientation_sensors[sens_index].m_name;
169 std::lock_guard<std::mutex> myLockGuard(m_mutex);
170 if (sens_index >= m_orientation_sensors.size())
return false;
171 frameName = m_orientation_sensors[sens_index].m_framename;
177 std::lock_guard<std::mutex> myLockGuard(m_mutex);
178 if (sens_index >= m_orientation_sensors.size())
return false;
179 timestamp = m_orientation_sensors[sens_index].m_timestamp;
180 xyz = m_orientation_sensors[sens_index].m_data;
FakePositionSensor(double period=0.05)
bool getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool close() override
Close the DeviceDriver.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
bool getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &xyz, double ×tamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
bool getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double ×tamp) const override
Get the last reading of the position sensor as x y z.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
void run() override
Loop function.
bool getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
bool threadInit() override
Initialization method.
size_t getNrOfOrientationSensors() const override
Get the number of orientation sensors exposed by this device.
void threadRelease() override
Release method.
bool getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
size_t getNrOfPositionSensors() const override
Get the number of position sensors exposed by this device.
bool getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool setPeriod(double period)
Set the (new) period of the thread.
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 std::string toString() const =0
Return a standard text representation of the content of the object.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual yarp::conf::float32_t asFloat32() const
Get 32-bit floating point value.
#define yCError(component,...)
#define yCTrace(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_UNKNOWN
The sensor is in an unknown state.
@ MAS_OK
The sensor is working correctly.
double now()
Return the current time in seconds, relative to an arbitrary starting point.