4 #include <handPoseEstimation_IDL.h> 5 #include <yarp/os/idl/WireTypes.h> 9 class handPoseEstimation_IDL_start :
public yarp::os::Portable {
13 virtual bool write(yarp::os::ConnectionWriter& connection) YARP_OVERRIDE;
14 virtual bool read(yarp::os::ConnectionReader& connection) YARP_OVERRIDE;
17 class handPoseEstimation_IDL_stop :
public yarp::os::Portable {
21 virtual bool write(yarp::os::ConnectionWriter& connection) YARP_OVERRIDE;
22 virtual bool read(yarp::os::ConnectionReader& connection) YARP_OVERRIDE;
25 class handPoseEstimation_IDL_pause :
public yarp::os::Portable {
29 virtual bool write(yarp::os::ConnectionWriter& connection) YARP_OVERRIDE;
30 virtual bool read(yarp::os::ConnectionReader& connection) YARP_OVERRIDE;
33 class handPoseEstimation_IDL_resume :
public yarp::os::Portable {
37 virtual bool write(yarp::os::ConnectionWriter& connection) YARP_OVERRIDE;
38 virtual bool read(yarp::os::ConnectionReader& connection) YARP_OVERRIDE;
41 class handPoseEstimation_IDL_lastOffsets :
public yarp::os::Portable {
43 yarp::os::Bottle _return;
45 virtual bool write(yarp::os::ConnectionWriter& connection) YARP_OVERRIDE;
46 virtual bool read(yarp::os::ConnectionReader& connection) YARP_OVERRIDE;
49 class handPoseEstimation_IDL_quit :
public yarp::os::Portable {
53 virtual bool write(yarp::os::ConnectionWriter& connection) YARP_OVERRIDE;
54 virtual bool read(yarp::os::ConnectionReader& connection) YARP_OVERRIDE;
57 bool handPoseEstimation_IDL_start::write(yarp::os::ConnectionWriter& connection) {
58 yarp::os::idl::WireWriter writer(connection);
59 if (!writer.writeListHeader(1))
return false;
60 if (!writer.writeTag(
"start",1,1))
return false;
64 bool handPoseEstimation_IDL_start::read(yarp::os::ConnectionReader& connection) {
65 yarp::os::idl::WireReader reader(connection);
66 if (!reader.readListReturn())
return false;
67 if (!reader.readBool(_return)) {
74 void handPoseEstimation_IDL_start::init() {
78 bool handPoseEstimation_IDL_stop::write(yarp::os::ConnectionWriter& connection) {
79 yarp::os::idl::WireWriter writer(connection);
80 if (!writer.writeListHeader(1))
return false;
81 if (!writer.writeTag(
"stop",1,1))
return false;
85 bool handPoseEstimation_IDL_stop::read(yarp::os::ConnectionReader& connection) {
86 yarp::os::idl::WireReader reader(connection);
87 if (!reader.readListReturn())
return false;
88 if (!reader.readBool(_return)) {
95 void handPoseEstimation_IDL_stop::init() {
99 bool handPoseEstimation_IDL_pause::write(yarp::os::ConnectionWriter& connection) {
100 yarp::os::idl::WireWriter writer(connection);
101 if (!writer.writeListHeader(1))
return false;
102 if (!writer.writeTag(
"pause",1,1))
return false;
106 bool handPoseEstimation_IDL_pause::read(yarp::os::ConnectionReader& connection) {
107 yarp::os::idl::WireReader reader(connection);
108 if (!reader.readListReturn())
return false;
109 if (!reader.readBool(_return)) {
116 void handPoseEstimation_IDL_pause::init() {
120 bool handPoseEstimation_IDL_resume::write(yarp::os::ConnectionWriter& connection) {
121 yarp::os::idl::WireWriter writer(connection);
122 if (!writer.writeListHeader(1))
return false;
123 if (!writer.writeTag(
"resume",1,1))
return false;
127 bool handPoseEstimation_IDL_resume::read(yarp::os::ConnectionReader& connection) {
128 yarp::os::idl::WireReader reader(connection);
129 if (!reader.readListReturn())
return false;
130 if (!reader.readBool(_return)) {
137 void handPoseEstimation_IDL_resume::init() {
141 bool handPoseEstimation_IDL_lastOffsets::write(yarp::os::ConnectionWriter& connection) {
142 yarp::os::idl::WireWriter writer(connection);
143 if (!writer.writeListHeader(1))
return false;
144 if (!writer.writeTag(
"lastOffsets",1,1))
return false;
148 bool handPoseEstimation_IDL_lastOffsets::read(yarp::os::ConnectionReader& connection) {
149 yarp::os::idl::WireReader reader(connection);
150 if (!reader.readListReturn())
return false;
151 if (!reader.read(_return)) {
158 void handPoseEstimation_IDL_lastOffsets::init() {
161 bool handPoseEstimation_IDL_quit::write(yarp::os::ConnectionWriter& connection) {
162 yarp::os::idl::WireWriter writer(connection);
163 if (!writer.writeListHeader(1))
return false;
164 if (!writer.writeTag(
"quit",1,1))
return false;
168 bool handPoseEstimation_IDL_quit::read(yarp::os::ConnectionReader& connection) {
169 yarp::os::idl::WireReader reader(connection);
170 if (!reader.readListReturn())
return false;
171 if (!reader.readBool(_return)) {
178 void handPoseEstimation_IDL_quit::init() {
182 handPoseEstimation_IDL::handPoseEstimation_IDL() {
183 yarp().setOwner(*
this);
186 bool _return =
false;
187 handPoseEstimation_IDL_start helper;
189 if (!yarp().canWrite()) {
190 yError(
"Missing server method '%s'?",
"bool handPoseEstimation_IDL::start()");
192 bool ok = yarp().write(helper,helper);
193 return ok?helper._return:_return;
196 bool _return =
false;
197 handPoseEstimation_IDL_stop helper;
199 if (!yarp().canWrite()) {
200 yError(
"Missing server method '%s'?",
"bool handPoseEstimation_IDL::stop()");
202 bool ok = yarp().write(helper,helper);
203 return ok?helper._return:_return;
206 bool _return =
false;
207 handPoseEstimation_IDL_pause helper;
209 if (!yarp().canWrite()) {
210 yError(
"Missing server method '%s'?",
"bool handPoseEstimation_IDL::pause()");
212 bool ok = yarp().write(helper,helper);
213 return ok?helper._return:_return;
216 bool _return =
false;
217 handPoseEstimation_IDL_resume helper;
219 if (!yarp().canWrite()) {
220 yError(
"Missing server method '%s'?",
"bool handPoseEstimation_IDL::resume()");
222 bool ok = yarp().write(helper,helper);
223 return ok?helper._return:_return;
226 yarp::os::Bottle _return;
227 handPoseEstimation_IDL_lastOffsets helper;
229 if (!yarp().canWrite()) {
230 yError(
"Missing server method '%s'?",
"yarp::os::Bottle handPoseEstimation_IDL::lastOffsets()");
232 bool ok = yarp().write(helper,helper);
233 return ok?helper._return:_return;
236 bool _return =
false;
237 handPoseEstimation_IDL_quit helper;
239 if (!yarp().canWrite()) {
240 yError(
"Missing server method '%s'?",
"bool handPoseEstimation_IDL::quit()");
242 bool ok = yarp().write(helper,helper);
243 return ok?helper._return:_return;
246 bool handPoseEstimation_IDL::read(yarp::os::ConnectionReader& connection) {
247 yarp::os::idl::WireReader reader(connection);
248 reader.expectAccept();
249 if (!reader.readListHeader()) { reader.fail();
return false; }
250 yarp::os::ConstString tag = reader.readTag();
251 bool direct = (tag==
"__direct__");
252 if (direct) tag = reader.readTag();
253 while (!reader.isError()) {
255 if (tag ==
"start") {
258 yarp::os::idl::WireWriter writer(reader);
259 if (!writer.isNull()) {
260 if (!writer.writeListHeader(1))
return false;
261 if (!writer.writeBool(_return))
return false;
269 yarp::os::idl::WireWriter writer(reader);
270 if (!writer.isNull()) {
271 if (!writer.writeListHeader(1))
return false;
272 if (!writer.writeBool(_return))
return false;
277 if (tag ==
"pause") {
280 yarp::os::idl::WireWriter writer(reader);
281 if (!writer.isNull()) {
282 if (!writer.writeListHeader(1))
return false;
283 if (!writer.writeBool(_return))
return false;
288 if (tag ==
"resume") {
291 yarp::os::idl::WireWriter writer(reader);
292 if (!writer.isNull()) {
293 if (!writer.writeListHeader(1))
return false;
294 if (!writer.writeBool(_return))
return false;
299 if (tag ==
"lastOffsets") {
300 yarp::os::Bottle _return;
301 _return = lastOffsets();
302 yarp::os::idl::WireWriter writer(reader);
303 if (!writer.isNull()) {
304 if (!writer.writeListHeader(1))
return false;
305 if (!writer.write(_return))
return false;
313 yarp::os::idl::WireWriter writer(reader);
314 if (!writer.isNull()) {
315 if (!writer.writeListHeader(1))
return false;
316 if (!writer.writeBool(_return))
return false;
322 std::string functionName;
323 if (!reader.readString(functionName)) {
324 functionName =
"--all";
326 std::vector<std::string> _return=help(functionName);
327 yarp::os::idl::WireWriter writer(reader);
328 if (!writer.isNull()) {
329 if (!writer.writeListHeader(2))
return false;
330 if (!writer.writeTag(
"many",1, 0))
return false;
331 if (!writer.writeListBegin(BOTTLE_TAG_INT, static_cast<uint32_t>(_return.size())))
return false;
332 std::vector<std::string> ::iterator _iterHelp;
333 for (_iterHelp = _return.begin(); _iterHelp != _return.end(); ++_iterHelp)
335 if (!writer.writeString(*_iterHelp))
return false;
337 if (!writer.writeListEnd())
return false;
342 if (reader.noMore()) { reader.fail();
return false; }
343 yarp::os::ConstString next_tag = reader.readTag();
344 if (next_tag==
"")
break;
345 tag = tag +
"_" + next_tag;
350 std::vector<std::string> handPoseEstimation_IDL::help(
const std::string& functionName) {
351 bool showAll=(functionName==
"--all");
352 std::vector<std::string> helpString;
354 helpString.push_back(
"*** Available commands:");
355 helpString.push_back(
"start");
356 helpString.push_back(
"stop");
357 helpString.push_back(
"pause");
358 helpString.push_back(
"resume");
359 helpString.push_back(
"lastOffsets");
360 helpString.push_back(
"quit");
361 helpString.push_back(
"help");
364 if (functionName==
"start") {
365 helpString.push_back(
"bool start() ");
366 helpString.push_back(
"Start (re-start) the hand pose estimation. ");
367 helpString.push_back(
"The filter generates particles and update the particle distribution accordingly ");
368 helpString.push_back(
"@return true/false on success/failure ");
370 if (functionName==
"stop") {
371 helpString.push_back(
"bool stop() ");
372 helpString.push_back(
"Stop the hand pose estimation. ");
373 helpString.push_back(
"The filter stop the generation of particles and waits for a start command ");
374 helpString.push_back(
"@return true/false on success/failure ");
376 if (functionName==
"pause") {
377 helpString.push_back(
"bool pause() ");
378 helpString.push_back(
"Pause the hand pose estimation. ");
379 helpString.push_back(
"The filter stop the generation of particles and waits for a resume command ");
380 helpString.push_back(
"@return true/false on success/failure ");
382 if (functionName==
"resume") {
383 helpString.push_back(
"bool resume() ");
384 helpString.push_back(
"Resume the hand pose estimation. ");
385 helpString.push_back(
"The filter resumes the generation of particles after a pause command ");
386 helpString.push_back(
"@return true/false on success/failure ");
388 if (functionName==
"lastOffsets") {
389 helpString.push_back(
"yarp::os::Bottle lastOffsets() ");
390 helpString.push_back(
"Ask for the last estimated angular Offsets on the arm (7DoF) ");
391 helpString.push_back(
"@return Bottle with last angular Offsets ");
393 if (functionName==
"quit") {
394 helpString.push_back(
"bool quit() ");
395 helpString.push_back(
"Quit the module. ");
396 helpString.push_back(
"@return true/false on success/failure ");
398 if (functionName==
"help") {
399 helpString.push_back(
"std::vector<std::string> help(const std::string& functionName=\"--all\")");
400 helpString.push_back(
"Return list of available commands, or help message for a specific function");
401 helpString.push_back(
"@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands");
402 helpString.push_back(
"@return list of strings (one string per line)");
405 if ( helpString.empty()) helpString.push_back(
"Command not found");
virtual yarp::os::Bottle lastOffsets()
Ask for the last estimated angular Offsets on the arm (7DoF)
virtual bool quit()
Quit the module.
virtual bool resume()
Resume the hand pose estimation.
virtual bool stop()
Stop the hand pose estimation.
virtual bool start()
Start (re-start) the hand pose estimation.
virtual bool pause()
Pause the hand pose estimation.