58 virtual bool configure(yarp::os::ResourceFinder &rf)
61 options.fromString(rf.toString());
64 std::string moduleName =
"directPositionControl";
66 if (options.check(
"help"))
68 yInfo() <<
"Available options:";
69 yInfo() <<
"--robot <robot name>";
70 yInfo() <<
"--name <local_module_name>";
71 yInfo() <<
"--part <part_name>";
72 yInfo() <<
"--joints ""(x x x)"" ";
73 yInfo() <<
"--joints_limiter <deg>";
74 yInfo() <<
"--target_limiter <deg>";
75 yInfo() <<
"--period <s>";
79 options.put(
"device",
"remote_controlboard");
80 if(options.check(
"robot"))
81 strncpy(robotName, options.find(
"robot").asString().c_str(),
sizeof(robotName));
83 strncpy(robotName,
"icub",
sizeof(robotName));
85 if (options.check(
"name"))
87 moduleName = options.find(
"name").asString();
90 if(options.check(
"part"))
92 snprintf(partName,
sizeof(partName),
"%s", options.find(
"part").asString().c_str());
95 snprintf(tmp,
sizeof(tmp),
"/%s/%s/%s/client", moduleName.c_str(), robotName, partName);
96 options.put(
"local",tmp);
98 snprintf(tmp,
sizeof(tmp),
"/%s/%s", robotName, partName);
99 options.put(
"remote", tmp);
101 snprintf(tmp,
sizeof(tmp),
"/%s/%s/rpc", moduleName.c_str(), partName);
104 options.put(
"carrier",
"tcp");
110 yError(
"Please specify part (e.g. --part head)\n");
114 if(options.check(
"joints"))
116 jointsList = options.find(
"joints").asList();
117 if (jointsList==0) yError(
"Unable to parts 'joints' parameter\n");
121 yError(
"Please specify the joints to control (e.g. --joints ""(0 1 2)"" ");
126 double joints_limiter = 2.0;
127 double target_limiter = 1.0;
128 if (options.check(
"joints_limiter"))
130 joints_limiter = options.find(
"joints_limiter").asFloat64();
132 if (options.check(
"target_limiter"))
134 target_limiter = options.find(
"target_limiter").asFloat64();
137 yDebug() <<
"joints_limiter:" << joints_limiter;
138 yDebug() <<
"target_limiter" << target_limiter;
141 if (!driver.open(options))
143 yError(
"Error opening device, check parameters\n");
149 if(options.check(
"period"))
150 period = options.find(
"period").asInt32();
152 yInfo(
"control rate is %d ms",period);
155 pThread->
init(&driver, moduleName, partName, robotName, jointsList);