iCub-main
Loading...
Searching...
No Matches
SkinMeshClient.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) 2009 RobotCub Consortium
5 * Author: Marco Maggiali, Alessandro Scalzo, Jacopo Losi
6 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
7 *
8 */
9
10#ifndef __SKIN_MESH_CLIENT_H__
11#define __SKIN_MESH_CLIENT_H__
12
13#include <mutex>
14#include <string>
15#include <vector>
16
17#include <yarp/os/Log.h>
18#include <yarp/os/Property.h>
19#include <yarp/dev/ControlBoardInterfaces.h>
20#include <yarp/dev/PolyDriver.h>
21#include <yarp/dev/PolyDriverList.h>
22#include <yarp/dev/CanBusInterface.h>
23#include <yarp/sig/Vector.h>
24
25#include <yarp/os/RFModule.h>
26#include <yarp/dev/MultipleAnalogSensorsInterfaces.h>
27#include <yarp/dev/IMultipleWrapper.h>
28
29#include "include/Quad16.h"
30#include "include/PalmRight.h"
31#include "include/PalmLeft.h"
32#include "include/fakePalm.h"
33#include "include/Triangle.h"
34#include "include/Fingertip.h"
43#include "include/CER_SH_PDL.h"
44
45using namespace yarp::os;
46using namespace yarp::dev;
47
48class SkinMeshClient : public yarp::os::RFModule
49{
50protected:
51 static const int MAX_SENSOR_NUM = 128;
52
53 BufferedPort<Bottle> skin_port;
54 BufferedPort<Bottle> skin_port_virtual;
56
57 std::mutex mtx;
58
61 bool m_configured{false};
62 double m_period{0.05};
64 mutable double m_lastNoSkinPatchWarningTime{0.0};
65
66 std::vector<unsigned char> defaultColor;
67
69
70private:
71
72 yarp::os::Property m_config;
73 yarp::dev::PolyDriver _multipleAnalogSensorsClientDevice;
74 yarp::dev::PolyDriver _multipleAnalogSensorsRemapperDevice;
75 struct
76 {
77 yarp::dev::ISkinPatches* iskinPatchesSensors{nullptr};
78 yarp::dev::IMultipleWrapper* imultwrap{nullptr};
79 } remappedMASInterfaces;
80
81 bool configureFromSearchable(yarp::os::Searchable& config);
82 bool configureSkinClient(yarp::os::Searchable& config, const std::string& localPrefix);
83 bool readSkinPatches(yarp::sig::Vector& skinValue) const;
84
85public:
86 SkinMeshClient(Searchable& config,int period);
87
89 {
90 for (int t=0; t<MAX_SENSOR_NUM; ++t)
91 {
92 if (sensor[t]) delete sensor[t];
93 }
94 }
95
96 bool start();
97 void stop();
98
99 virtual bool configure(yarp::os::ResourceFinder &rf) override;
100 virtual bool close() override;
101 virtual double getPeriod() override;
102 virtual bool updateModule() override;
103
104 void resize(int width,int height)
105 {
106 std::lock_guard<std::mutex> lck(mtx);
107 for (int t=0; t<MAX_SENSOR_NUM; ++t)
108 {
109 if (sensor[t]) sensor[t]->resize(width,height,40);
110 }
111 }
112
113 void eval(unsigned char *image)
114 {
115 std::lock_guard<std::mutex> lck(mtx);
116 for (int t=0; t<MAX_SENSOR_NUM; ++t)
117 {
118 if (sensor[t])
119 {
120 if (mbSimpleDraw)
121 {
122 sensor[t]->eval_light(image);
123 }
124 else
125 {
126 sensor[t]->eval(image);
127 }
128 }
129 }
130 }
131
132 void draw(unsigned char *image)
133 {
134 for (int t=0; t<MAX_SENSOR_NUM; ++t)
135 {
136 if (sensor[t]) sensor[t]->draw(image);
137 }
138 }
139};
140
141#endif
void draw(unsigned char *image)
SkinMeshClient(Searchable &config, int period)
BufferedPort< Bottle > skin_port
TouchSensor * sensor[MAX_SENSOR_NUM]
static const int MAX_SENSOR_NUM
virtual bool configure(yarp::os::ResourceFinder &rf) override
void eval(unsigned char *image)
std::vector< unsigned char > defaultColor
virtual double getPeriod() override
void resize(int width, int height)
double m_lastNoSkinPatchWarningTime
yarp::dev::ISkinPatches * iskinPatchesSensors
virtual bool updateModule() override
BufferedPort< Bottle > skin_port_virtual
yarp::dev::IMultipleWrapper * imultwrap
virtual bool close() override