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) 2012 iCub Facility, Istituto Italiano di Tecnologia
5 * Author: Alberto Cardellino
6 * email: alberto.cardellino@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
27#include <yarp/os/PeriodicThread.h>
28#include <yarp/dev/ControlBoardInterfaces.h>
29#include <yarp/dev/IAnalogSensor.h>
30#include <yarp/dev/PolyDriver.h>
31
32
33#include "IethResource.h"
34#include <ethManager.h>
35#include <abstractEthResource.h>
36
37
38#include "SkinConfigReader.h"
39#include <SkinDiagnostics.h>
40#include "serviceParser.h"
41
42using namespace yarp::os;
43using namespace yarp::dev;
44using namespace yarp::os::impl;
45using namespace yarp::sig;
46
47
48
50{
51public:
53 eOcanport_t canport; // so far a patch contains addresses of a unique canport
54 eOprotIndex_t indexNv;
55 std::vector <int> cardAddrList;
56 int checkCardAddrIsInList(int cardAddr);
57};
58
60{
61 public:
63 std::vector<SkinPatchInfo> patchInfoList;
64 uint8_t numOfPatches;
65};
66
67
68// -- class EmbObjSkin
69
70class EmbObjSkin : public yarp::dev::IAnalogSensor,
71 public DeviceDriver,
73{
74
75public:
76
77 enum { EMBSK_SIZE_INFO = 128 };
79
80 bool opened;
81
82protected:
83
85 string boardName;
86 eOipv4addr_t ipv4addr;
87
90
91 std::mutex mtx;
92 //int totalCardsNum;
93 //std::vector<SkinPatchInfo> patchInfoList;
94 size_t sensorsNum;
95 Vector skindata;
96 //uint8_t numOfPatches; //currently one patch is made up by all skin boards connected to one can port of ems.
99 bool _newCfg;
102
103 bool init();
104 bool fromConfig(yarp::os::Searchable& config);
105 bool initWithSpecialConfig(yarp::os::Searchable& config);
106 bool start();
107 bool configPeriodicMessage(void);
108 eOprotIndex_t convertIdPatch2IndexNv(int idPatch)
109 {
110 /*in xml file idPatch are number of ems canPort identified with numer 1 or 2 on electronic schematics.
111 * in ethernet protocol the patch number is the index part of network variable identifier, that starts from 0 */
112 if(_skCfg.numOfPatches == 1)
113 return(0);
114 else
115 return(idPatch-1);
116 }
117
118private:
119
120 ServiceParser *parser;
121 eOmn_serv_parameter_t ethservice;
122
123 bool verbosewhenok;
124
125 /****************** diagnostic********************************/
126 bool _isDiagnosticPresent; // is the diagnostic available from the firmware
127 /*************************************************************/
128
130 std::vector<iCub::skin::diagnostics::DetectedError> errors;
131
132public:
133
134 EmbObjSkin();
135 ~EmbObjSkin();
136
137 virtual bool open(yarp::os::Searchable& config);
138
139 virtual bool close();
140 void cleanup(void);
141
142 virtual int read(yarp::sig::Vector &out);
143 virtual int getState(int ch);
144 virtual int getChannels();
145 virtual int calibrateSensor();
146 virtual int calibrateChannel(int ch, double v);
147
148 virtual int calibrateSensor(const yarp::sig::Vector& v);
149 virtual int calibrateChannel(int ch);
150
151 virtual bool initialised();
152 virtual eth::iethresType_t type();
153 virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata);
154
155};
156
157#endif
158
virtual int read(yarp::sig::Vector &out)
bool fromConfig(yarp::os::Searchable &config)
eth::AbstractEthResource * res
Definition embObjSkin.h:89
SkinConfigReader _cfgReader
Definition embObjSkin.h:100
SkinConfig _skCfg
Definition embObjSkin.h:101
Vector skindata
Definition embObjSkin.h:95
virtual int calibrateSensor()
string boardName
Definition embObjSkin.h:85
SkinBoardCfgParam _brdCfg
Definition embObjSkin.h:97
virtual bool initialised()
@ SPECIAL_TRIANGLE_CFG_MAX_NUM
Definition embObjSkin.h:78
virtual int calibrateChannel(int ch, double v)
void cleanup(void)
bool _newCfg
Definition embObjSkin.h:99
string boardIPstring
Definition embObjSkin.h:84
eOprotIndex_t convertIdPatch2IndexNv(int idPatch)
Definition embObjSkin.h:108
bool initWithSpecialConfig(yarp::os::Searchable &config)
SkinTriangleCfgParam _triangCfg
Definition embObjSkin.h:98
bool opened
Definition embObjSkin.h:80
@ EMBSK_SIZE_INFO
Definition embObjSkin.h:77
virtual bool open(yarp::os::Searchable &config)
size_t sensorsNum
Definition embObjSkin.h:94
eOipv4addr_t ipv4addr
Definition embObjSkin.h:86
virtual bool close()
virtual eth::iethresType_t type()
virtual int getState(int ch)
virtual int getChannels()
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)
bool configPeriodicMessage(void)
std::mutex mtx
Definition embObjSkin.h:91
eth::TheEthManager * ethManager
Definition embObjSkin.h:88
uint8_t numOfPatches
Definition embObjSkin.h:64
int totalCardsNum
Definition embObjSkin.h:62
std::vector< SkinPatchInfo > patchInfoList
Definition embObjSkin.h:63
std::vector< int > cardAddrList
Definition embObjSkin.h:55
eOprotIndex_t indexNv
Definition embObjSkin.h:54
eOcanport_t canport
Definition embObjSkin.h:53
int checkCardAddrIsInList(int cardAddr)
iethresType_t
out
Definition sine.m:8