iCub-main
embObjMultiEnc.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __embObjMultiEnc_h__
4 #define __embObjMultiEnc_h__
5 
6 #include <yarp/dev/DeviceDriver.h>
7 #include <yarp/dev/IAnalogSensor.h>
8 #include <yarp/os/PeriodicThread.h>
9 #include <string>
10 #include <list>
11 #include <mutex>
12 
13 #include <iCub/FactoryInterface.h>
14 #include <iCub/LoggerInterfaces.h>
15 
16 
17 
18 #include "IethResource.h"
19 #include <ethManager.h>
20 #include <abstractEthResource.h>
21 
22 
23 
24 
25 #include <yarp/os/LogStream.h>
26 
27 #include "serviceParser.h"
28 
29 namespace yarp {
30  namespace dev {
31  class embObjMultiEnc;
32  }
33 }
34 
35 
36 #define EMBOBJMULTIENC_USESERVICEPARSER
37 
38 
39 // -- class embObjMais
40 
41 class yarp::dev::embObjMultiEnc: public yarp::dev::IAnalogSensor,
42  public yarp::dev::DeviceDriver,
43  public eth::IethResource
44 {
45 
46 public:
47 
48  enum{default_numofencperjoint = eOmc_joint_multienc_maxnum, default_numofjoints = 2};
49 
50 public:
51 
54 
55  // An open function yarp factory compatible
56  bool open(yarp::os::Searchable &config);
57  bool close();
58 
59  // IAnalogSensor interface
60  virtual int read(yarp::sig::Vector &out);
61  virtual int getState(int ch);
62  virtual int getChannels();
63  virtual int calibrateChannel(int ch, double v);
64  virtual int calibrateSensor();
65  virtual int calibrateSensor(const yarp::sig::Vector& value);
66  virtual int calibrateChannel(int ch);
67 
68  // IethResource interface
69  virtual bool initialised();
70  virtual eth::iethresType_t type();
71  virtual bool update(eOprotID32_t id32, double timestamp, void* rxdata);
72 
73 private:
74 
75  string boardIPstring;
76  string boardName;
77  eOipv4addr_t ipv4addr;
78 
79  uint8_t numofjoints;
80  uint8_t numofencperjoint;
81 
82  eth::TheEthManager* ethManager;
84  ServiceParser* parser;
85 
86  bool opened;
87  bool verbosewhenok;
88 
89  unsigned int counterSat;
90  unsigned int counterError;
91  unsigned int counterTimeout;
92 
94  // parameters
95  servConfigMais_t serviceConfig;
96 
97  std::mutex mtx;
98 
99  vector<double> analogdata;
100  vector<double> encoderConversionFactor;
101 
102  short status;
103  double timeStamp;
104  vector<int> listofjoints;
105 
106 private:
107 
108  // for all
109  bool extractGroup(Bottle &input, Bottle &out, const std::string &key1, const std::string &txt, int size);
110  bool fromConfig(yarp::os::Searchable &config);
111  bool initRegulars();
112  void cleanup(void);
113  void printServiceConfig(void);
114 
115 
116 
117  // for ??
118  void resetCounters();
119  void getCounters(unsigned int &saturations, unsigned int &errors, unsigned int &timeouts);
120 };
121 
122 
123 #endif
124 
Interface for a factory device; a device that can create objects.
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)
virtual int getState(int ch)
virtual int read(yarp::sig::Vector &out)
Read a vector from the sensor.
virtual int calibrateChannel(int ch, double v)
bool open(yarp::os::Searchable &config)
virtual eth::iethresType_t type()
iethresType_t
Definition: IethResource.h:62
Copyright (C) 2008 RobotCub Consortium.
out
Definition: sine.m:8