YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
FakePositionSensor.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#ifndef YARP_DEVICE_FAKE_POSITIONSENSOR
7#define YARP_DEVICE_FAKE_POSITIONSENSOR
8
10
11#include <yarp/dev/all.h>
13
14#include <mutex>
15
17
33{
34private:
35
36 mutable std::mutex m_mutex;
37 unsigned int m_channelsNum;
38
39 struct myfakesensor
40 {
41 std::string m_name = "mySensor";
42 std::string m_framename = "myFrame";
44 double m_timestamp = 0.0;
45 yarp::sig::Vector m_data;
46
47 myfakesensor()
48 {
49 m_data.resize(3);
50 m_data[0] = 1.0;
51 m_data[1] = 2.0;
52 m_data[2] = 3.0;
53 }
54 };
55
56 std::vector<myfakesensor> m_position_sensors;
57 std::vector<myfakesensor> m_orientation_sensors;
58
59public:
60 FakePositionSensor(double period = 0.05);
61
63
64 bool open(yarp::os::Searchable& config) override;
65 bool close() override;
66
67 //Interfaces
68 yarp::dev::ReturnValue getNrOfPositionSensors(size_t& num) const override;
69 yarp::dev::MAS_status getPositionSensorStatus(size_t sens_index) const override;
70 yarp::dev::ReturnValue getPositionSensorName(size_t sens_index, std::string& name) const override;
71 yarp::dev::ReturnValue getPositionSensorFrameName(size_t sens_index, std::string& frameName) const override;
72 yarp::dev::ReturnValue getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
73
74 yarp::dev::ReturnValue getNrOfOrientationSensors(size_t& num) const override;
75 yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override;
76 yarp::dev::ReturnValue getOrientationSensorName(size_t sens_index, std::string& name) const override;
77 yarp::dev::ReturnValue getOrientationSensorFrameName(size_t sens_index, std::string& frameName) const override;
78 yarp::dev::ReturnValue getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector& xyz, double& timestamp) const override;
79
80 // RateThread interface
81 void run() override;
82 bool threadInit() override;
83 void threadRelease() override;
84};
85
86
87#endif // YARP_DEVICE_FAKE_POSITIONSENSOR
This class is the parameters parser for class FakePositionSensor.
fakePositionSensor: Fake position sensor device for testing purpose and reference for new similar dev...
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.
yarp::dev::MAS_status getOrientationSensorStatus(size_t sens_index) const override
Get the status of the specified sensor.
void run() override
Loop function.
yarp::dev::ReturnValue getOrientationSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
yarp::dev::ReturnValue getNrOfOrientationSensors(size_t &num) const override
Get the number of orientation sensors exposed by this device.
yarp::dev::ReturnValue getPositionSensorName(size_t sens_index, std::string &name) const override
Get the name of the specified sensor.
bool threadInit() override
Initialization method.
yarp::dev::ReturnValue getOrientationSensorMeasureAsRollPitchYaw(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const override
Get the last reading of the orientation sensor as roll pitch yaw.
yarp::dev::ReturnValue getOrientationSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
void threadRelease() override
Release method.
yarp::dev::ReturnValue getPositionSensorMeasure(size_t sens_index, yarp::sig::Vector &xyz, double &timestamp) const override
Get the last reading of the position sensor as x y z.
yarp::dev::ReturnValue getPositionSensorFrameName(size_t sens_index, std::string &frameName) const override
Get the name of the frame of the specified sensor.
yarp::dev::ReturnValue getNrOfPositionSensors(size_t &num) const override
Get the number of position sensors exposed by this device.
Interface implemented by all device drivers.
Device interface to one or multiple orientation sensors, such as IMUs with on board estimation algori...
Device interface to one or multiple position sensors, such as UWB localization sensors.
An abstraction for a periodic thread.
A base class for nested structures that can be searched.
Definition Searchable.h:31
void resize(size_t size)
Resize the vector.
Definition VectorBase.h:106
MAS_status
Status of a given analog sensor exposed by a multiple analog sensors interface.
@ MAS_OK
The sensor is working correctly.