iCub-main
Loading...
Searching...
No Matches
embObjSkin.h
Go to the documentation of this file.
1// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2
3
4/* Copyright (C) 2026 Mesh Facility, Istituto Italiano di Tecnologia
5 * Author: Alberto Cardellino, Jacopo Losi
6 * email: alberto.cardellino@iit.it, jacopo.losi@iit.it
7 * Permission is granted to copy, distribute, and/or modify this program
8 * under the terms of the GNU General Public License, version 2 or any
9 * later version published by the Free Software Foundation.
10 *
11 * A copy of the license can be found at
12 * http://www.robotcub.org/icub/license/gpl.txt
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details
18 */
19
20
21#ifndef __EMBOBJSKIN_H__
22#define __EMBOBJSKIN_H__
23
24#include <string>
25#include <mutex>
26#include <optional>
27
28#include <yarp/os/PeriodicThread.h>
29#include <yarp/dev/ControlBoardInterfaces.h>
30#include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
31#include <yarp/dev/PolyDriver.h>
32
33
34#include "IethResource.h"
35#include <ethManager.h>
36#include <abstractEthResource.h>
37
38
39#include "SkinConfigReader.h"
40#include <SkinDiagnostics.h>
41#include "serviceParser.h"
42
43using namespace yarp::os;
44using namespace yarp::dev;
45using namespace yarp::os::impl;
46using namespace yarp::sig;
47
48
49
51{
52public:
54 eOcanport_t canport; // so far a patch contains addresses of a unique canport
55 eOprotIndex_t indexNv;
56 std::vector <int> cardAddrList;
57 size_t taxelsOffset{0};
58 size_t taxelsSize{0}; // number of taxels per patch
59 size_t boardsOffset{0};
60 std::optional<size_t> checkCardAddrIsInList(int cardAddr);
61};
62
64{
65 public:
67 std::vector<SkinPatchInfo> patchInfoList;
68 uint8_t numOfPatches;
69};
70
71
72// -- class EmbObjSkin
73
74class EmbObjSkin : public ISkinPatches,
75 public DeviceDriver,
77{
78protected:
79
81 string boardName;
82 eOipv4addr_t ipv4addr;
83
86
87 mutable std::mutex mtx;
88 size_t sensorsNum;
90 Vector skindata;
93 bool _newCfg;
96
97 void cleanup(void);
98 bool init();
99 bool fromConfig(yarp::os::Searchable& config);
100 bool initWithSpecialConfig(yarp::os::Searchable& config);
101 bool start();
102 bool configPeriodicMessage(void);
103 eOprotIndex_t convertIdPatch2IndexNv(int idPatch)
104 {
105 /*in xml file idPatch are number of ems canPort identified with numer 1 or 2 on electronic schematics.
106 * in ethernet protocol the patch number is the index part of network variable identifier, that starts from 0 */
107 if(_skCfg.numOfPatches == 1)
108 return(0);
109 else
110 return(idPatch-1);
111 }
112
113
114private:
115 bool opened;
116 std::string boardInfo() const;
117
118 ServiceParser *parser;
119 eOmn_serv_parameter_t ethservice;
120
121 bool verbosewhenok;
122
123 /****************** diagnostic********************************/
124 bool _isDiagnosticPresent; // is the diagnostic available from the firmware
125 /*************************************************************/
126
128 std::vector<iCub::skin::diagnostics::DetectedError> errors;
129
130public:
131
132 EmbObjSkin();
133 ~EmbObjSkin();
134
135 // DeviceDriver interface
136 virtual bool open(yarp::os::Searchable& config);
137 virtual bool close();
138
139 // ISkinPatches interface
141 virtual size_t getNrOfSkinPatches() const override;
143 virtual MAS_status getSkinPatchStatus(size_t sens_index) const override;
145 virtual bool getSkinPatchName(size_t sens_index, std::string &name) const override;
147 virtual bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector& out, double& timestamp) const override;
149 virtual size_t getSkinPatchSize(size_t sens_index) const override;
150
151 // IethResource interface
152 virtual bool initialised();
153 virtual eth::iethresType_t type();
154 virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata);
155
156};
157
158#endif
159
bool fromConfig(yarp::os::Searchable &config)
eth::AbstractEthResource * res
Definition embObjSkin.h:85
SkinConfigReader _cfgReader
Definition embObjSkin.h:94
SkinConfig _skCfg
Definition embObjSkin.h:95
virtual bool getSkinPatchMeasure(size_t sens_index, yarp::sig::Vector &out, double &timestamp) const override
Get the last readings of the sensors related to the specified patch.
Vector skindata
Definition embObjSkin.h:90
string boardName
Definition embObjSkin.h:81
SkinBoardCfgParam _brdCfg
Definition embObjSkin.h:91
virtual bool initialised()
void cleanup(void)
bool _newCfg
Definition embObjSkin.h:93
string boardIPstring
Definition embObjSkin.h:80
eOprotIndex_t convertIdPatch2IndexNv(int idPatch)
Definition embObjSkin.h:103
bool initWithSpecialConfig(yarp::os::Searchable &config)
SkinTriangleCfgParam _triangCfg
Definition embObjSkin.h:92
virtual bool open(yarp::os::Searchable &config)
size_t sensorsNum
Definition embObjSkin.h:88
eOipv4addr_t ipv4addr
Definition embObjSkin.h:82
virtual bool close()
virtual eth::iethresType_t type()
virtual size_t getNrOfSkinPatches() const override
Get the number of skin patches exposed by THIS device.
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)
virtual MAS_status getSkinPatchStatus(size_t sens_index) const override
Get the status of the specified patch.
bool configPeriodicMessage(void)
std::mutex mtx
Definition embObjSkin.h:87
virtual size_t getSkinPatchSize(size_t sens_index) const override
Get the size of the specified skin patch, i.e., the number of taxels (sensors) it contains.
virtual bool getSkinPatchName(size_t sens_index, std::string &name) const override
Get the name of the specified patch.
eth::TheEthManager * ethManager
Definition embObjSkin.h:84
size_t _cumulativeTaxels
Definition embObjSkin.h:89
uint8_t numOfPatches
Definition embObjSkin.h:68
int totalCardsNum
Definition embObjSkin.h:66
std::vector< SkinPatchInfo > patchInfoList
Definition embObjSkin.h:67
std::optional< size_t > checkCardAddrIsInList(int cardAddr)
std::vector< int > cardAddrList
Definition embObjSkin.h:56
size_t taxelsSize
Definition embObjSkin.h:58
eOprotIndex_t indexNv
Definition embObjSkin.h:55
eOcanport_t canport
Definition embObjSkin.h:54
size_t boardsOffset
Definition embObjSkin.h:59
size_t taxelsOffset
Definition embObjSkin.h:57
iethresType_t
out
Definition sine.m:8