18 #include <yarp/os/LogStream.h> 27 initializeParameters(rf);
34 thread =
new TouchDetectorThread(&torsoPort, &leftArmPort, &rightArmPort, &leftForearmPort, &rightForearmPort, &leftHandPort, &rightHandPort, &touchPort, &touchPortCleaned, period, clustersConfFilepath,
threshold, taxelThreshold);
48 torsoPort.interrupt();
49 leftArmPort.interrupt();
50 rightArmPort.interrupt();
51 leftForearmPort.interrupt();
52 rightForearmPort.interrupt();
53 leftHandPort.interrupt();
54 rightHandPort.interrupt();
55 touchPort.interrupt();
56 touchPortCleaned.interrupt();
68 leftForearmPort.close();
69 rightForearmPort.close();
71 rightHandPort.close();
73 touchPortCleaned.close();
82 moduleName = rf.check(
"name", Value(
"touchDetector"),
"Module name (string)").asString();
83 setName(moduleName.c_str());
84 period = rf.check(
"period", Value(1000 / 10),
"Thread period (string)").asInt();
85 threshold = rf.check(
"threshold", Value(50.0),
"Activation threshold (double)").asDouble();
86 taxelThreshold = rf.check(
"taxelThreshold", Value(3),
"Minimum number of taxels which need to be active (int)").asInt();
87 rf.setDefault(
"clustersConfFile", Value(
"clustersConfig.ini"));
88 clustersConfFilepath = rf.findFile(
"clustersConfFile");
92 torsoPortName += getName(rf.check(
"torsoPort", Value(
"/torso:i"),
"Torso input port (string)").asString());
93 leftArmPortName =
"/";
94 leftArmPortName += getName(rf.check(
"leftArmPort", Value(
"/left_arm:i"),
"Left arm input port (string)").asString());
95 rightArmPortName =
"/";
96 rightArmPortName += getName(rf.check(
"rightArmPort", Value(
"/right_arm:i"),
"Right arm input port (string)").asString());
97 leftForearmPortName =
"/";
98 leftForearmPortName += getName(rf.check(
"leftForearmPort", Value(
"/left_forearm:i"),
"Left forearm input port (string)").asString());
99 rightForearmPortName =
"/";
100 rightForearmPortName += getName(rf.check(
"rightForearmPort", Value(
"/right_forearm:i"),
"Right forearm input port (string)").asString());
101 leftHandPortName =
"/";
102 leftHandPortName += getName(rf.check(
"leftHandPort", Value(
"/left_hand:i"),
"Left hand input port (string)").asString());
103 rightHandPortName =
"/";
104 rightHandPortName += getName(rf.check(
"rightHandPort", Value(
"/right_hand:i"),
"Right hand input port (string)").asString());
106 touchPortName += getName(rf.check(
"touchPort", Value(
"/touch:o"),
"Touch output port (string)").asString());
107 touchPortCleanName =
"/";
108 touchPortCleanName += getName(rf.check(
"touchPortClean", Value(
"/touchClean:o"),
"Touch clean output port (string)").asString());
113 if (!torsoPort.open(torsoPortName.c_str())) {
114 yError() << getName() <<
": unable to open port " << torsoPortName;
117 if (!leftArmPort.open(leftArmPortName.c_str())) {
118 yError() << getName() <<
": unable to open port " << leftArmPortName;
121 if (!rightArmPort.open(rightArmPortName.c_str())) {
122 yError() << getName() <<
": unable to open port " << rightArmPortName;
125 if (!leftForearmPort.open(leftForearmPortName.c_str())) {
126 yError() << getName() <<
": unable to open port " << leftForearmPortName;
129 if (!rightForearmPort.open(rightForearmPortName.c_str())) {
130 yError() << getName() <<
": unable to open port " << rightForearmPortName;
133 if (!leftHandPort.open(leftHandPortName.c_str())) {
134 yError() << getName() <<
": unable to open port " << leftHandPortName;
137 if (!rightHandPort.open(rightHandPortName.c_str())) {
138 yError() << getName() <<
": unable to open port " << rightHandPortName;
141 if (!touchPort.open(touchPortName.c_str())) {
142 yError() << getName() <<
": unable to open port " << touchPortName;
145 if (!touchPortCleaned.open(touchPortCleanName.c_str())) {
146 yError() << getName() <<
": unable to open port " << touchPortCleanName;
bool configure(yarp::os::ResourceFinder &rf)
void initializeParameters(yarp::os::ResourceFinder &rf)