iCub-main
Loading...
Searching...
No Matches
embObjPOS.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 iCub Tech - Istituto Italiano di Tecnologia
3 * Author: Marco Accame
4 * email: marco.accame@iit.it
5*/
6
7
8#ifndef __embObjPOS_h__
9#define __embObjPOS_h__
10
11#include <string>
12#include <mutex>
13#include <yarp/dev/DeviceDriver.h>
14#include <yarp/sig/Vector.h>
15#include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
16
17
19
20#include "serviceParser.h"
21
22
23namespace yarp {
24 namespace dev {
25 class embObjPOS;
26 }
27}
28
29
30
31class yarp::dev::embObjPOS: public yarp::dev::DeviceDriver,
32 public yarp::dev::IEncoderArrays,
34{
35
36public:
37
38 embObjPOS();
39 ~embObjPOS();
40
41 bool open(yarp::os::Searchable &config);
42 bool close();
43
44 // IEncoderArrays interface
45 virtual size_t getNrOfEncoderArrays() const override; // this should return the number of enabledSensor, i.e. 2 or 4, depending on the device
46
47 // This should be the status of the actuator at index sens_index.
48 virtual yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override;
49
50 // This should be the name of the actuator at index sens_index, i.e. serviceConfig.idList[sens_index].
51 virtual bool getEncoderArrayName(size_t sens_index, std::string &name) const override;
52
53 // In this case, if we keep the analysis done around this service, out element should contain the position of the actuator at sens_index, i.e. m_data[sens_index].
54 // Thus, it is actually a single value, not a vector of 2 or 4 elements.
55 virtual bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
56
57 // I think this cannot return 2 or 4, i.e. the number of enabled-sensors, which is the size of m_data, but it should return 1, as the encoder array is a single entity.
58 // Otherwise, it won't make sense to have the API getNrOfEncoderArrays(), which return the number of enabled sensors.
59 // So, I think that in this case we have a number of encoder arrays equal to the number of enabled sensors, and each one of these arrays has a size equal to 1.
60 virtual size_t getEncoderArraySize(size_t sens_index) const override; // this should return the size of data at index sens_index, which should actually be 1.
61
62
63
64 // IethResource interface
65 virtual bool initialised();
66 virtual eth::iethresType_t type();
67 virtual bool update(eOprotID32_t id32, double timestamp, void* rxdata);
68
69private:
70
71 servConfigPOS_t serviceConfig;
73 mutable std::mutex m_mutex;
74 yarp::sig::Vector m_data; //this should be a vector of 2 or 4 elements, depending on the device, if related to abduction or open-close. Each number is the position of the actuator.
75
76
77private:
78
79 bool fromConfig(yarp::os::Searchable &config, servConfigPOS_t &serviceConfig);
80 bool sendConfig2boards(servConfigPOS_t &serviceConfig);
81 bool sendStart2boards(void);
82 bool initRegulars(void);
83 void cleanup(void);
84
85 void helper_remapperFromSensorToDataIndex(const uint32_t sensorId, uint32_t &dataIndex) const;
86
87
88};
89
90
91#endif
92
virtual bool getEncoderArrayName(size_t sens_index, std::string &name) const override
virtual size_t getEncoderArraySize(size_t sens_index) const override
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)
virtual eth::iethresType_t type()
virtual bool initialised()
Definition embObjPOS.cpp:77
virtual bool getEncoderArrayMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
virtual yarp::dev::MAS_status getEncoderArrayStatus(size_t sens_index) const override
virtual size_t getNrOfEncoderArrays() const override
bool open(yarp::os::Searchable &config)
Definition embObjPOS.cpp:83
iethresType_t
Copyright (C) 2008 RobotCub Consortium.
out
Definition sine.m:8