28using namespace yarp::os;
29using namespace yarp::sig;
36 if (!options.check(
"name"))
43 name=options.find(
"name").asString();
44 directLogic=(options.check(
"logic",Value(
"direct")).asString()==
"direct");
45 outputGain=options.check(
"output_gain",Value(1.0)).asFloat64();
47 if ((
name==
"thumb") || (
name==
"index") || (
name==
"middle") ||
59 options.put(
"name",
name);
60 options.put(
"logic",
directLogic?
"direct":
"inverse");
68 str<<
"name "<<
name<<endl;
69 str<<
"logic "<<(
directLogic?
"direct":
"inverse")<<endl;
82 yWarning(
"TactileFinger: calibration not available");
90 yWarning(
"TactileFinger: calibration not available");
99 for (
int j=0; j<12; j++)
104 map<string,Sensor*>::const_iterator In=
sensors.find(tag.str());
108 Value val_in; In->second->getOutput(val_in);
109 in[j]=val_in.asFloat64();
115 b.addList().read(in);
116 prop.put(
"in",b.get(0));
118 b.addList().read(prop);
133 if (Bottle *b1=
data.asList())
135 if (Bottle *b2=b1->find(
"in").asList())
137 in.resize(b2->size());
138 for (
size_t i=0; i<in.length(); i++)
139 in[i]=b2->get(i).asFloat64();
158 for (
size_t j=0; j<i.length(); j++)
178 if (!options.check(
"name") || !options.check(
"type"))
187 name=options.find(
"name").asString();
188 type=options.find(
"type").asString();
189 robot=options.check(
"robot",Value(
"icub")).asString();
190 carrier=options.check(
"carrier",Value(
"udp")).asString();
191 compensation=(options.check(
"compensation",Value(
"false")).asString()==
"true");
192 verbosity=options.check(
"verbosity",Value(0)).asInt32();
194 port->open(
"/"+
name+
"/"+type+
"_hand:i");
195 string skinPortName(
"/"+robot+
"/skin/"+type+
"_hand");
197 skinPortName+=
"_comp";
199 if (!Network::connect(skinPortName,port->getName(),carrier))
207 void *pPort=
static_cast<void*
>(port);
208 for (
int j=0; j<60; j++)
214 prop.put(
"name",tag.str());
217 if (!sensPort[j].configure(pPort,prop))
226 Property thumb(options.findGroup(
"thumb").toString().c_str());
227 Property index(options.findGroup(
"index").toString().c_str());
228 Property middle(options.findGroup(
"middle").toString().c_str());
229 Property ring(options.findGroup(
"ring").toString().c_str());
230 Property little(options.findGroup(
"little").toString().c_str());
232 bool fingers_ok=
true;
247 for (
int j=0; j<12; j++)
263 return configured=
true;
281 string thumb=
"(thumb ";
282 thumb+=prop[0].toString();
285 string index=
"(index ";
286 index+=prop[1].toString();
289 string middle=
"(middle ";
290 middle+=prop[2].toString();
293 string ring=
"(ring ";
294 ring+=prop[3].toString();
297 string little=
"(little ";
298 little+=prop[4].toString();
301 options.fromString(thumb+index+middle+ring+little);
302 options.put(
"name",
name);
303 options.put(
"type",type);
304 options.put(
"robot",robot);
305 options.put(
"compensation",compensation?
"true":
"false");
316 str<<
"name "<<
name<<endl;
317 str<<
"type "<<type<<endl;
318 str<<
"robot "<<robot<<endl;
319 str<<
"compensation "<<(compensation?
"true":
"false")<<endl;
323 str<<
"[thumb]"<<endl;
327 str<<
"[index]"<<endl;
331 str<<
"[middle]"<<endl;
339 str<<
"[little]"<<endl;
377 Bottle bOut; Bottle &ins=bOut.addList();
378 ins.addFloat64(val[0].asFloat64());
379 ins.addFloat64(val[1].asFloat64());
380 ins.addFloat64(val[2].asFloat64());
381 ins.addFloat64(val[3].asFloat64());
382 ins.addFloat64(val[4].asFloat64());
393void TactileFingersModel::close()
397 if (!port->isClosed())
virtual void printMessage(const int logtype, const int level, const char *format,...) const
void attachNode(Node &node)
Attach a node object to the model.
std::map< std::string, Node * > nodes
std::map< std::string, EventCallback * > callbacks
std::map< std::string, Node * > neighbors
std::map< std::string, Sensor * > sensors
void attachSensor(Sensor &sensor)
Attach a sensor object to the node.
bool extractSensorsData(yarp::sig::Vector &in) const
void toProperty(yarp::os::Property &options) const
Return a Property representation of all the node parameters.
bool isCalibrated() const
Not available.
bool toStream(std::ostream &str) const
Similar to the toProperty() method but it operates on output streams (e.g.
bool fromProperty(const yarp::os::Property &options)
Configure the finger taking its parameters from a Property object.
bool getOutput(yarp::os::Value &out) const
Retrieve the finger output.
bool getSensorsData(yarp::os::Value &data) const
Retrieve tactile data from the ports.
bool calibrate(const yarp::os::Property &options)
Not available.
bool fromProperty(const yarp::os::Property &options)
Configure the model taking its parameters from a Property object.
TactileFingersModel()
Constructor.
void toProperty(yarp::os::Property &options) const
Return a Property representation of all the model parameters.
bool calibrate(const yarp::os::Property &options)
Not available.
bool isCalibrated() const
Not available.
bool toStream(std::ostream &str) const
Similar to the toProperty() method but it operates on output streams (e.g.
virtual ~TactileFingersModel()
Destructor.
bool getOutput(yarp::os::Value &out) const
Retrieve the complete output of the model.