33 _verb = (prop.
check(
"verbose",
"if present, give detailed output"));
39 if(!parseOptions(prop))
47bool ControlBoardRemapper::parseOptions(
Property& prop)
51 usingAxesNamesForAttachAll = prop.
check(
"axesNames",
"list of networks merged by this wrapper");
52 usingNetworksForAttachAll = prop.
check(
"networks",
"list of networks merged by this wrapper");
55 if( usingAxesNamesForAttachAll &&
56 usingNetworksForAttachAll )
62 if( !usingAxesNamesForAttachAll &&
63 !usingNetworksForAttachAll )
69 if( usingAxesNamesForAttachAll )
71 ok = parseAxesNames(prop);
74 if( usingNetworksForAttachAll )
76 ok = parseNetworks(prop);
82bool ControlBoardRemapper::parseAxesNames(
const Property& prop)
85 if(propAxesNames==
nullptr)
91 axesNames.resize(propAxesNames->
size());
92 for(
size_t ax=0; ax < propAxesNames->
size(); ax++)
97 this->setNrOfControlledAxes(axesNames.size());
102bool ControlBoardRemapper::parseNetworks(
const Property& prop)
111 if (!prop.
check(
"joints",
"number of joints of the part"))
117 this->setNrOfControlledAxes((
size_t)prop.
find(
"joints").
asInt32());
119 int nsubdevices=nets->
size();
120 remappedControlBoards.
lut.resize(controlledJoints);
121 remappedControlBoards.
subdevices.resize(nsubdevices);
124 for(
size_t k=0;k<nets->
size();k++)
134 if(parameters.
size()==2)
144 if(tmpBot.
size() != 4)
147 <<
"Check network parameters in part description"
148 <<
"--> I was expecting" << nets->
get(k).
asString() <<
"followed by a list of four integers in parenthesis"
164 else if (parameters.
size()==5)
175 <<
"Check network parameters in part description"
176 <<
"--> I was expecting" << nets->
get(k).
asString() <<
"followed by a list of four integers in parenthesis"
184 if( (wTop-wBase) != (top-base) )
187 <<
"Check network parameters in network " << nets->
get(k).
asString().c_str()
188 <<
"I was expecting a well form quadruple of numbers, got instead: "<< parameters.
toString().c_str();
193 for(
int j=wBase;j<=wTop;j++)
196 remappedControlBoards.
lut[j].subControlBoardIndex=k;
197 remappedControlBoards.
lut[j].axisIndexInSubControlBoard=base+off;
204void ControlBoardRemapper::setNrOfControlledAxes(
const size_t nrOfControlledAxes)
206 controlledJoints = nrOfControlledAxes;
208 buffers.
dummyBuffer.resize(nrOfControlledAxes,0.0);
212bool ControlBoardRemapper::updateAxesName()
215 axesNames.resize(controlledJoints);
217 for(
int l=0; l < controlledJoints; l++)
219 std::string axNameYARP;
223 axesNames[l] = axNameYARP;
238 if( usingAxesNamesForAttachAll )
240 ok = attachAllUsingAxesNames(polylist);
243 if( usingNetworksForAttachAll )
245 ok = attachAllUsingNetworks(polylist);
252 if (!remappedControlBoards.
subdevices[k].isAttached())
282bool ControlBoardRemapper::attachAllUsingAxesNames(
const PolyDriverList& polylist)
284 std::map<std::string, axisLocation> axesLocationMap;
286 for(
int p=0;p<polylist.
size();p++)
291 std::string deviceKey=polylist[p]->key;
292 if(deviceKey ==
"Calibrator" || deviceKey ==
"calibrator")
296 polylist[p]->poly->view(calibrator);
298 IRemoteCalibrator::setCalibratorDevice(calibrator);
305 polylist[p]->poly->view(iaxinfos);
306 polylist[p]->poly->view(iencs);
311 yCError(
CONTROLBOARDREMAPPER) <<
"subdevice" << deviceKey <<
"does not implemented the required IAxisInfo or IEncoders interfaces";
315 int nrOfSubdeviceAxes;
316 bool ok = iencs->
getAxes(&nrOfSubdeviceAxes);
324 for(
int axInSubDevice =0; axInSubDevice < nrOfSubdeviceAxes; axInSubDevice++)
326 std::string axNameYARP;
327 ok = iaxinfos->
getAxisName(axInSubDevice,axNameYARP);
329 std::string axName = axNameYARP;
337 auto it = axesLocationMap.find(axName);
338 if( it != axesLocationMap.end() )
341 <<
"multiple axes have the same name" << axName
342 <<
"on on device " << polylist[p]->key <<
"with index" << axInSubDevice
343 <<
"and another on device" << it->second.subDeviceKey <<
"with index" << it->second.indexInSubDevice;
351 axesLocationMap[axName] = newLocation;
356 std::vector<std::string> subControlBoardsKeys;
357 std::map<std::string, size_t> subControlBoardKey2IndexInPolyDriverList;
358 std::map<std::string, size_t> subControlBoardKey2IndexInRemappedControlBoards;
363 for(
const auto& axesName : axesNames)
365 auto it = axesLocationMap.find(axesName);
366 if( it == axesLocationMap.end() )
369 <<
"axis " << axesName
370 <<
"specified in axesNames was not found in the axes of the controlboards passed to attachAll, attachAll failed.";
377 if(std::find(subControlBoardsKeys.begin(), subControlBoardsKeys.end(), key) == subControlBoardsKeys.end())
380 subControlBoardKey2IndexInRemappedControlBoards[key] = subControlBoardsKeys.size();
381 subControlBoardsKeys.push_back(key);
386 assert(controlledJoints == (
int) axesNames.size());
389 size_t nrOfSubControlBoards = subControlBoardsKeys.size();
390 remappedControlBoards.
lut.resize(controlledJoints);
391 remappedControlBoards.
subdevices.resize(nrOfSubControlBoards);
394 for(
size_t ctrlBrd=0; ctrlBrd < nrOfSubControlBoards; ctrlBrd++)
396 size_t p = subControlBoardKey2IndexInPolyDriverList[subControlBoardsKeys[ctrlBrd]];
399 tmpDevice->
id = subControlBoardsKeys[ctrlBrd];
400 bool ok = tmpDevice->
attach(polylist[p]->poly,subControlBoardsKeys[ctrlBrd]);
409 for(
size_t l=0; l < axesNames.size(); l++)
412 remappedControlBoards.
lut[l].subControlBoardIndex = subControlBoardKey2IndexInRemappedControlBoards[loc.
subDeviceKey];
420bool ControlBoardRemapper::attachAllUsingNetworks(
const PolyDriverList &polylist)
422 for(
int p=0;p<polylist.
size();p++)
425 std::string subDeviceKey = polylist[p]->key;
426 if(subDeviceKey ==
"Calibrator" || subDeviceKey ==
"calibrator")
430 polylist[p]->poly->view(calibrator);
432 IRemoteCalibrator::setCalibratorDevice(calibrator);
440 if (remappedControlBoards.
subdevices[k].id==subDeviceKey)
442 if (!remappedControlBoards.
subdevices[k].attach(polylist[p]->poly, subDeviceKey))
451 bool ok = updateAxesName();
466 for (
int k = 0; k < devices; k++) {
470 IRemoteCalibrator::releaseCalibratorDevice();
474void ControlBoardRemapper::configureBuffers()
476 allJointsBuffers.
configure(remappedControlBoards);
477 selectedJointsBuffers.
configure(remappedControlBoards);
481bool ControlBoardRemapper::setControlModeAllAxes(
const int cm)
483 std::lock_guard<std::mutex> lock(buffers.
mutex);
485 for(
int j=0; j < controlledJoints; j++)
502 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
503 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
523 for(
int l=0;l<controlledJoints;l++)
525 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
527 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
537 bool ok = p->
pid->
setPid(pidtype, off, ps[l]);
550 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
551 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
572 for(
int l=0;l<controlledJoints;l++)
574 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
576 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
599 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
600 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
620 for(
int l=0;l<controlledJoints;l++)
622 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
624 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
647 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
648 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
669 for(
int l=0;l<controlledJoints;l++)
671 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
672 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
695 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
696 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
716 for(
int l=0;l<controlledJoints;l++)
718 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
720 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
730 ret=
ret&&p->pid->getPidOutput(pidtype, off, outs+l);
742 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
743 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
761 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
762 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
782 for(
int l=0;l<controlledJoints;l++)
784 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
785 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
795 bool ok = p->
pid->
getPid(pidtype, off, pids+l);
809 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
810 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
830 for(
int l=0;l<controlledJoints;l++)
832 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
834 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
857 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
858 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
878 for(
int l=0;l<controlledJoints;l++)
880 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
882 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
906 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
907 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
926 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
927 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
941 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
942 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
961 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
962 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
982 *ax=controlledJoints;
988 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
989 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1009 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1029 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1048 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1049 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1060 bool ret = p->pos->getTargetPosition(off, ref);
1070 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1101 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1133 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1134 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1154 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1174 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1193 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1194 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1216 for(
int l=0;l<controlledJoints;l++)
1218 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1219 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
1230 bool singleJointMotionDone =
false;
1233 *flag = *flag && singleJointMotionDone;
1248 for(
int j=0;j<n_joints;j++)
1252 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1253 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
1264 bool singleJointMotionDone =
false;
1267 *flag = *flag && singleJointMotionDone;
1280 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1281 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1301 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1321 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1340 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1341 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1361 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1381 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1400 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1401 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1421 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1452 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1484 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1485 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1505 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1535 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1567 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1568 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1588 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1608 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
1609 std::lock_guard<std::mutex> lock2(buffers.
mutex);
1629 int off = (int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1630 size_t subIndex = remappedControlBoards.
lut[j].subControlBoardIndex;
1651 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1652 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1672 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
1692 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1693 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1713 for(
int l=0;l<controlledJoints;l++)
1715 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1716 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
1739 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1740 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1761 for(
int l=0;l<controlledJoints;l++)
1763 int off = (int) remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1764 size_t subIndex = remappedControlBoards.
lut[l].subControlBoardIndex;
1788 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1789 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1810 for(
int l=0;l<controlledJoints;l++)
1812 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1813 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
1839 for(
int l=0;l<controlledJoints;l++)
1841 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1842 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
1866 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1867 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1886 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1887 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1908 for(
int l=0;l<controlledJoints;l++)
1910 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1911 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
1935 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
1936 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
1957 for(
int l=0;l<controlledJoints;l++)
1959 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
1960 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
1985 *num=controlledJoints;
1991 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
1992 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2012 for(
int l=0;l<controlledJoints;l++)
2014 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2015 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
2025 ret=
ret&&p->imotor->getTemperature(off, vals+l);
2037 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2038 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2057 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2058 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2077 int off = (int)remappedControlBoards.
lut[m].subControlBoardIndex;
2078 size_t subIndex = remappedControlBoards.
lut[m].subControlBoardIndex;
2097 int off = (int)remappedControlBoards.
lut[m].subControlBoardIndex;
2098 size_t subIndex = remappedControlBoards.
lut[m].subControlBoardIndex;
2154 size_t bottle_size = val.
size();
2156 if (bottle_size != device_size)
2163 for (
unsigned int i = 0; i < device_size; i++)
2187 size_t subIndex = remappedControlBoards.
lut[0].subControlBoardIndex;
2207 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2208 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2229 for(
int l=0;l<controlledJoints;l++)
2231 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2232 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
2256 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2257 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2278 for(
int l=0;l<controlledJoints;l++)
2280 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2281 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
2306 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2307 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2326 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2327 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2346 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2347 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2368 for(
int l=0;l<controlledJoints;l++)
2370 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2371 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
2380 ret=
ret&&p->iMotEnc->getMotorEncoder(off, encs+l);
2392 for(
int l=0;l<controlledJoints;l++)
2394 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2395 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
2419 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2420 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2439 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2440 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2461 for(
int l=0;l<controlledJoints;l++)
2463 int off = (int) remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2464 size_t subIndex = remappedControlBoards.
lut[l].subControlBoardIndex;
2488 int off = (int) remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2489 size_t subIndex = remappedControlBoards.
lut[m].subControlBoardIndex;
2510 for(
int l=0;l<controlledJoints;l++)
2512 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2513 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
2539 *num=controlledJoints;
2546 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2547 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2573 for(
int l=0;l<controlledJoints;l++)
2575 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
2576 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
2601 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2602 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2621 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2622 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2641 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2642 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2661 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2662 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2681 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2682 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2701 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2702 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2721 int off = (int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2722 size_t subIndex = remappedControlBoards.
lut[m].subControlBoardIndex;
2741 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2742 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2760 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2761 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2780 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2781 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2800 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
2801 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
2823 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2824 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2843 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2844 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2863 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2864 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2883 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2884 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
2916 int off = (int) remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2917 size_t subIndex = remappedControlBoards.
lut[j].subControlBoardIndex;
2934 return IRemoteCalibrator::getCalibratorDevice()->calibrateSingleJoint(j);
2960 return IRemoteCalibrator::getCalibratorDevice()->calibrateWholePart();
2968 int off = (int) remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
2969 size_t subIndex = remappedControlBoards.
lut[j].subControlBoardIndex;
2986 return IRemoteCalibrator::getCalibratorDevice()->homingSingleJoint(j);
2995 for(
int l=0;l<controlledJoints;l++)
3005 return IRemoteCalibrator::getCalibratorDevice()->homingWholePart();
3013 int off = (int) remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3014 size_t subIndex = remappedControlBoards.
lut[j].subControlBoardIndex;
3041 for(
int l=0; l<controlledJoints; l++)
3078 return IRemoteCalibrator::getCalibratorDevice()->quitCalibrate();
3104 return IRemoteCalibrator::getCalibratorDevice()->quitPark();
3112 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3113 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3126 int off = (int) remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3127 size_t subIndex = remappedControlBoards.
lut[j].subControlBoardIndex;
3141 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3142 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3175 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3176 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3195 int off = (int) remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3196 size_t subIndex = remappedControlBoards.
lut[j].subControlBoardIndex;
3217 for(
int l=0;l<controlledJoints;l++)
3219 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
3220 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
3244 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3245 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3264 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
3293 int off = (int) remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3294 size_t subIndex = remappedControlBoards.
lut[j].subControlBoardIndex;
3312 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
3331 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3332 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3351 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3352 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3371 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3372 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3391 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3392 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3411 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3412 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3433 for(
int l=0;l<controlledJoints;l++)
3435 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
3436 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
3461 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3462 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3483 for(
int l=0;l<controlledJoints;l++)
3485 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
3486 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
3510 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3511 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3530 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3531 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3550 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3551 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3570 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3571 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3585 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
3616 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
3650 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3651 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3660 ret = p->iMode->setControlMode(off, mode);
3668 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
3688 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
3707 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3708 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3728 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
3748 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
3767 double averageTimestamp = 0.0;
3768 int collectedTimestamps = 0;
3770 for(
int l=0;l<controlledJoints;l++)
3772 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
3784 collectedTimestamps++;
3789 std::lock_guard<std::mutex> lock(buffers.
mutex);
3791 if( collectedTimestamps > 0 )
3793 buffers.
stamp.
update(averageTimestamp/collectedTimestamps);
3800 return buffers.
stamp;
3805 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3806 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3817 bool ret = p->posDir->getRefPosition(off, ref);
3827 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
3858 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
3894 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
3913 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3914 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
3925 bool ret = p->vel->getRefVelocity(off, vel);
3936 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
3966 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
3998 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
3999 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
4019 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
4052 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
4081 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
4082 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
4102 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
4122 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
4143 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
4149 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
4160 for(
int l=0;l<controlledJoints;l++)
4162 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
4163 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
4190 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
4196 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
4207 for(
int l=0;l<controlledJoints;l++)
4209 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
4210 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
4237 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
4243 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
4254 for(
int l=0;l<controlledJoints;l++)
4256 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
4257 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
4284 size_t subIndex=remappedControlBoards.
lut[j].subControlBoardIndex;
4290 int off=(int)remappedControlBoards.
lut[j].axisIndexInSubControlBoard;
4301 for(
int l=0;l<controlledJoints;l++)
4303 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
4304 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
4331 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
4337 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
4348 for(
int l=0;l<controlledJoints;l++)
4350 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
4351 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
4378 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
4384 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
4394 std::lock_guard<std::mutex> lock(selectedJointsBuffers.
mutex);
4402 if (!(p && p->
iCurr))
4420 std::lock_guard<std::mutex> lock(allJointsBuffers.
mutex);
4441 size_t subIndex=remappedControlBoards.
lut[m].subControlBoardIndex;
4447 int off=(int)remappedControlBoards.
lut[m].axisIndexInSubControlBoard;
4458 for(
int l=0;l<controlledJoints;l++)
4460 int off=(int)remappedControlBoards.
lut[l].axisIndexInSubControlBoard;
4461 size_t subIndex=remappedControlBoards.
lut[l].subControlBoardIndex;
const yarp::os::LogComponent & CONTROLBOARDREMAPPER()
constexpr yarp::conf::vocab32_t VOCAB_CM_IDLE
bool configure(const RemappedControlBoards &remappedControlBoards)
Resize the buffers using the information in the RemappedControlBoards.
std::vector< std::vector< double > > m_bufferForSubControlBoard
std::vector< std::vector< yarp::dev::InteractionModeEnum > > m_bufferForSubControlBoardInteractionModes
void fillSubControlBoardBuffersFromArbitraryJointVector(const double *arbitraryVec, const int n_joints, const int *joints, const RemappedControlBoards &remappedControlBoards)
Fill buffers for the SubControlBoard from a vector of joints of the RemappedControlBoards.
std::vector< std::vector< int > > m_jointsInSubControlBoard
void resizeSubControlBoardBuffers(const int n_joints, const int *joints, const RemappedControlBoards &remappedControlBoards)
Resize buffers to have the dimension of specified by the method (used for multi joint methods that re...
std::vector< std::vector< int > > m_bufferForSubControlBoardControlModes
void fillArbitraryJointVectorFromSubControlBoardBuffers(double *arbitraryVec, const int n_joints, const int *joints, const RemappedControlBoards &remappedControlBoards)
Fill a vector of joints of the ControlBoardRemapper from the buffers of the SubControlBoard .
std::vector< int > m_nJointsInSubControlBoard
std::mutex mutex
Mutex to grab to use this class.
std::vector< double > dummyBuffer
std::vector< int > controlBoardModes
bool parkWholePart() override
parkWholePart: start the parking procedure for the whole part
bool setImpedance(int j, double stiff, double damp) override
Set current impedance gains (stiffness,damping) for a specific joint.
bool getPidErrorLimit(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *limit) override
Get the error limit for the controller on a specific joint.
bool setRefAccelerations(const double *accs) override
Set reference acceleration on all joints.
bool resetMotorEncoder(int m) override
Reset motor encoder, single motor.
bool getTorqueRange(int j, double *min, double *max) override
Get the full scale of the torque sensor of a given joint.
bool getTargetPosition(const int joint, double *ref) override
Get the last position reference for the specified axis.
bool getMotorEncoderCountsPerRevolution(int m, double *cpr) override
Gets number of counts per revolution for motor encoder m.
bool getAmpStatus(int *st) override
bool setTemperatureLimit(int m, const double val) override
Set the temperature limit for a specific motor.
bool setPid(const yarp::dev::PidControlTypeEnum &pidtype, int j, const yarp::dev::Pid &p) override
ControlBoard methods.
bool setRefCurrent(int m, double curr) override
Set the reference value of the current for a single motor.
bool getEncoderSpeeds(double *spds) override
Read the instantaneous speed of all axes.
bool getControlMode(int j, int *mode) override
Get the current control mode.
bool getRefPositions(double *refs) override
Get the last position reference for all axes.
bool setRefSpeed(int j, double sp) override
Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.
bool setNominalCurrent(int m, const double val) override
bool getMotorEncoderTimed(int m, double *v, double *t) override
Read the instantaneous position of a motor encoder.
bool getRefCurrents(double *currs) override
Get the reference value of the currents for all motors.
bool close() override
Close the device driver by deallocating all resources and closing ports.
bool getTorques(double *t) override
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
bool getRemoteVariable(std::string key, yarp::os::Bottle &val) override
bool checkMotionDone(int j, bool *flag) override
Check if the current trajectory is terminated.
bool calibrationDone(int j) override
Check if the calibration is terminated, on a particular joint.
bool getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp) override
Get the current impedandance limits for a specific joint.
bool setPWMLimit(int m, const double val) override
bool getTemperatureLimit(int m, double *val) override
Retreives the current temperature limit for a specific motor.
bool getAxes(int *ax) override
Get the number of controlled axes.
bool setPidOffset(const yarp::dev::PidControlTypeEnum &pidtype, int j, double v) override
Set offset value for a given controller.
bool setEncoder(int j, double val) override
Set the value of the encoder for a given joint.
bool setRefAcceleration(int j, double acc) override
Set reference acceleration for a joint.
bool getPid(const yarp::dev::PidControlTypeEnum &pidtype, int j, yarp::dev::Pid *p) override
Get current pid value for a specific joint.
bool getImpedanceOffset(int j, double *offset) override
Get current force Offset for a specific joint.
bool getEncoderSpeed(int j, double *sp) override
Read the istantaneous speed of an axis.
bool getRefSpeed(int j, double *ref) override
Get reference speed for a joint.
bool resetEncoder(int j) override
Reset encoder, single joint.
bool getDutyCycles(double *vals) override
Gets the current dutycycle of the output of the amplifier (i.e.
bool getEncoderAcceleration(int j, double *acc) override
Read the instantaneous acceleration of an axis.
bool setControlModes(const int n_joints, const int *joints, int *modes) override
Set the current control mode for a subset of axes.
bool getEncoderTimed(int j, double *v, double *t) override
Read the instantaneous acceleration of all axes.
bool getImpedance(int j, double *stiff, double *damp) override
Get current impedance gains (stiffness,damping,offset) for a specific joint.
bool getEncoders(double *encs) override
Read the position of all axes.
bool getRefPosition(const int joint, double *ref) override
Get the last position reference for the specified axis.
bool setVelLimits(int j, double min, double max) override
Set the software speed limits for a particular axis, the behavior of the control card when these limi...
bool getEncoder(int j, double *v) override
Read the value of an encoder.
bool getMotorEncoder(int m, double *v) override
Read the value of a motor encoder.
bool getTorqueRanges(double *min, double *max) override
Get the full scale of the torque sensors of all joints.
bool getMotorEncodersTimed(double *encs, double *t) override
Read the instantaneous position of all motor encoders.
bool setRefTorque(int j, double t) override
Set the reference value of the torque for a given joint.
bool getNumberOfMotors(int *num) override
Retrieves the number of controlled axes from the current physical interface.
bool disableAmp(int j) override
Disable the amplifier on a specific joint.
bool setInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Set the interaction mode of the robot for a set of joints, values can be stiff or compliant.
bool getPeakCurrent(int m, double *val) override
bool setGearboxRatio(int m, const double val) override
Set the gearbox ratio for a specific motor.
bool quitCalibrate() override
quitCalibrate: interrupt the calibration procedure
bool calibrateAxisWithParams(int j, unsigned int ui, double v1, double v2, double v3) override
Start calibration, this method is very often platform specific.
bool getAxisName(int j, std::string &name) override
bool getControlModes(int *modes) override
Get the current control mode (multiple joints).
bool getRefTorques(double *refs) override
Get the reference value of the torque for all joints.
bool getPidReferences(const yarp::dev::PidControlTypeEnum &pidtype, double *refs) override
Get the current reference of all pid controllers.
bool isPidEnabled(const yarp::dev::PidControlTypeEnum &pidtype, int j, bool *enabled) override
Get the current status (enabled/disabled) of the pid.
bool getRefVelocity(const int joint, double *vel) override
Get the last reference speed set by velocityMove for single joint.
bool setPidErrorLimits(const yarp::dev::PidControlTypeEnum &pidtype, const double *limits) override
Get the error limit for the controller on all joints.
bool setRefCurrents(const double *currs) override
Set the reference value of the currents for all motors.
bool setMotorTorqueParams(int j, const yarp::dev::MotorTorqueParameters params) override
Set a subset of motor parameters (bemf, ktau etc) useful for torque control.
bool open(yarp::os::Searchable &prop) override
Open the device driver.
bool setPidErrorLimit(const yarp::dev::PidControlTypeEnum &pidtype, int j, double limit) override
Set the error limit for the controller on a specifi joint.
bool setMaxCurrent(int j, double v) override
yarp::dev::IRemoteCalibrator * getCalibratorDevice() override
getCalibratorDevice: return the pointer stored with the setCalibratorDevice
bool abortCalibration() override
bool enablePid(const yarp::dev::PidControlTypeEnum &pidtype, int j) override
Enable the pid computation for a joint.
bool calibrateWholePart() override
calibrateWholePart: call the procedure for calibrating the whole device
bool getLimits(int j, double *min, double *max) override
Get the software limits for a particular axis.
bool getRefDutyCycles(double *refs) override
Gets the last reference sent using the setRefDutyCycles function.
bool getPidReference(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *ref) override
Get the current reference of the pid controller for a specific joint.
bool setRefSpeeds(const double *spds) override
Set reference speed on all joints.
bool getNominalCurrent(int m, double *val) override
bool getRefVelocities(double *vels) override
Get the last reference speed set by velocityMove for all joints.
bool setEncoders(const double *vals) override
Set the value of all encoders.
bool getInteractionMode(int j, yarp::dev::InteractionModeEnum *mode) override
Get the current interaction mode of the robot, values can be stiff or compliant.
bool setMotorEncoder(int m, const double val) override
Set the value of the motor encoder for a given motor.
bool getPidErrors(const yarp::dev::PidControlTypeEnum &pidtype, double *errs) override
Get the error of all joints.
bool getPidError(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *err) override
Get the current error for a joint.
bool getPidErrorLimits(const yarp::dev::PidControlTypeEnum &pidtype, double *limits) override
Get the error limit for all controllers.
bool getCurrent(int m, double *curr) override
bool detachAll() override
Detach the object (you must have first called attach).
bool setPids(const yarp::dev::PidControlTypeEnum &pidtype, const yarp::dev::Pid *ps) override
Set new pid value on multiple axes.
bool parkSingleJoint(int j, bool _wait=true) override
parkSingleJoint(): start the parking procedure for the single joint
bool calibrateSingleJoint(int j) override
calibrateSingleJoint: call the calibration procedure for the single joint
bool getRefTorque(int j, double *t) override
Get the reference value of the torque for a given joint.
bool quitPark() override
quitPark: interrupt the park procedure
bool velocityMove(int j, double v) override
Start motion at a given speed, single joint.
bool getRefDutyCycle(int m, double *ref) override
Gets the last reference sent using the setRefDutyCycle function.
bool getNumberOfMotorEncoders(int *num) override
Get the number of available motor encoders.
bool getPidOutput(const yarp::dev::PidControlTypeEnum &pidtype, int j, double *out) override
Get the output of the controller (e.g.
bool getMotorEncoderAcceleration(int m, double *acc) override
Read the instantaneous acceleration of a motor encoder.
bool setLimits(int j, double min, double max) override
Set the software limits for a particular axis, the behavior of the control card when these limits are...
bool setMotorEncoders(const double *vals) override
Set the value of all motor encoders.
bool getMotorEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all motor encoders.
bool setPidReferences(const yarp::dev::PidControlTypeEnum &pidtype, const double *refs) override
Set the controller reference, multiple axes.
bool getTargetPositions(double *refs) override
Get the last position reference for all axes.
bool getPWM(int m, double *val) override
bool setRemoteVariable(std::string key, const yarp::os::Bottle &val) override
bool setImpedanceOffset(int j, double offset) override
Set current force Offset for a specific joint.
bool getPidOutputs(const yarp::dev::PidControlTypeEnum &pidtype, double *outs) override
Get the output of the controllers (e.g.
bool getJointType(int j, yarp::dev::JointTypeEnum &type) override
bool resetEncoders() override
Reset encoders.
bool setRefDutyCycles(const double *refs) override
Sets the reference dutycycle for all the motors.
yarp::os::Stamp getLastInputStamp() override
Return the time stamp relative to the last acquisition.
bool getDutyCycle(int m, double *val) override
Gets the current dutycycle of the output of the amplifier (i.e.
bool getCurrentRanges(double *min, double *max) override
Get the full scale of the current measurements for all motors motor (e.g.
bool attachAll(const yarp::dev::PolyDriverList &l) override
Attach to a list of objects.
bool getMotorTorqueParams(int j, yarp::dev::MotorTorqueParameters *params) override
Get a subset of motor parameters (bemf, ktau etc) useful for torque control.
bool setRefTorques(const double *t) override
Set the reference value of the torque for all joints.
bool getLastJointFault(int j, int &fault, std::string &message) override
bool resetMotorEncoders() override
Reset motor encoders.
bool getTorque(int j, double *t) override
Get the value of the torque on a given joint (this is the feedback if you have a torque sensor).
bool getRefCurrent(int m, double *curr) override
Get the reference value of the current for a single motor.
bool setInteractionMode(int j, yarp::dev::InteractionModeEnum mode) override
Set the interaction mode of the robot, values can be stiff or compliant.
bool getGearboxRatio(int m, double *val) override
Get the gearbox ratio for a specific motor.
bool getVelLimits(int j, double *min, double *max) override
Get the software speed limits for a particular axis.
bool getRefAccelerations(double *accs) override
Get reference acceleration of all joints.
bool enableAmp(int j) override
Enable the amplifier on a specific joint.
bool positionMove(int j, double ref) override
Set new reference point for a single axis.
bool disablePid(const yarp::dev::PidControlTypeEnum &pidtype, int j) override
Disable the pid computation for a joint.
bool getTemperatures(double *vals) override
Get temperature of all the motors.
bool resetPid(const yarp::dev::PidControlTypeEnum &pidtype, int j) override
Reset the controller of a given joint, usually sets the current status of the joint as the reference ...
bool getCurrentRange(int m, double *min, double *max) override
Get the full scale of the current measurement for a given motor (e.g.
bool getTemperature(int m, double *val) override
Get temperature of a motor.
bool setControlMode(const int j, const int mode) override
Set the current control mode.
bool getInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
bool abortPark() override
bool isCalibratorDevicePresent(bool *isCalib) override
isCalibratorDevicePresent: check if a calibrator device has been set
bool setMotorEncoderCountsPerRevolution(int m, const double cpr) override
Sets number of counts per revolution for motor encoder m.
bool getPowerSupplyVoltage(int m, double *val) override
bool getMotorEncoders(double *encs) override
Read the position of all motor encoders.
bool setPositions(const int n_joints, const int *joints, const double *dpos) override
Set new reference point for all axes.
bool setCalibrationParameters(int j, const yarp::dev::CalibrationParameters ¶ms) override
Start calibration, this method is very often platform specific.
bool stop() override
Stop motion, multiple joints.
bool getCurrents(double *currs) override
bool getRemoteVariablesList(yarp::os::Bottle *listOfKeys) override
bool getPWMLimit(int m, double *val) override
bool getEncoderAccelerations(double *accs) override
Read the instantaneous acceleration of all axes.
bool setPeakCurrent(int m, const double val) override
bool homingWholePart() override
homingWholePart: call the homing procedure for a the whole part/device
bool getMotorEncoderSpeed(int m, double *sp) override
Read the istantaneous speed of a motor encoder.
bool homingSingleJoint(int j) override
homingSingleJoint: call the homing procedure for a single joint
bool getRefAcceleration(int j, double *acc) override
Get reference acceleration for a joint.
bool getEncodersTimed(double *encs, double *t) override
Read the instantaneous acceleration of all axes.
bool getRefSpeeds(double *spds) override
Get reference speed of all joints.
bool setRefDutyCycle(int m, double ref) override
Sets the reference dutycycle to a single motor.
bool getMaxCurrent(int j, double *v) override
Returns the maximum electric current allowed for a given motor.
bool setPidReference(const yarp::dev::PidControlTypeEnum &pidtype, int j, double ref) override
Set the controller reference for a given axis.
bool getMotorEncoderSpeeds(double *spds) override
Read the instantaneous speed of all motor encoders.
bool getPids(const yarp::dev::PidControlTypeEnum &pidtype, yarp::dev::Pid *pids) override
Get current pid value for a specific joint.
bool setPosition(int j, double ref) override
Set new position for a single axis.
bool relativeMove(int j, double delta) override
Set relative position.
std::vector< int > m_nJointsInSubControlBoard
bool configure(const RemappedControlBoards &remappedControlBoards)
Resize the buffers using the information in the RemappedControlBoards.
std::mutex mutex
Mutex to grab to use this class.
std::vector< std::vector< int > > m_jointsInSubControlBoard
void fillCompleteJointVectorFromSubControlBoardBuffers(double *full, const RemappedControlBoards &remappedControlBoards)
Fill a vector of joints of the ControlBoardRemapper from the buffers of the SubControlBoard .
void fillSubControlBoardBuffersFromCompleteJointVector(const double *full, const RemappedControlBoards &remappedControlBoards)
Fill buffers for the SubControlBoard from a vector of joints of the RemappedControlBoards.
std::vector< std::vector< double > > m_bufferForSubControlBoard
std::vector< std::vector< int > > m_bufferForSubControlBoardControlModes
std::vector< std::vector< yarp::dev::InteractionModeEnum > > m_bufferForSubControlBoardInteractionModes
size_t getNrOfSubControlBoards() const
std::vector< RemappedSubControlBoard > subdevices
Vector of dimension getNrOfSubControlBoards .
std::vector< RemappedAxis > lut
Vector of dimension getNrOfRemappedAxes .
RemappedSubControlBoard * getSubControlBoard(size_t i)
Given a controlboard index between 0 and getNrOfSubControlBoards()-1, return the relative SubControlB...
yarp::dev::IPositionControl * pos
yarp::dev::IImpedanceControl * iImpedance
yarp::dev::IAmplifierControl * amp
yarp::dev::IEncodersTimed * iJntEnc
yarp::dev::IInteractionMode * iInteract
yarp::dev::IRemoteVariables * iVar
yarp::dev::ICurrentControl * iCurr
yarp::dev::ITorqueControl * iTorque
yarp::dev::IVelocityControl * vel
yarp::dev::IControlMode * iMode
yarp::dev::IJointFault * iFault
yarp::dev::IPositionDirect * posDir
yarp::dev::IRemoteCalibrator * remcalib
bool attach(yarp::dev::PolyDriver *d, const std::string &id)
yarp::dev::IPidControl * pid
yarp::dev::IAxisInfo * info
yarp::dev::IControlLimits * lim
yarp::dev::IMotor * imotor
yarp::dev::IPWMControl * iPwm
yarp::dev::IControlCalibration * calib
yarp::dev::IMotorEncoders * iMotEnc
void setVerbose(bool _verbose)
yarp::dev::IPreciselyTimed * iTimed
virtual bool getPWMLimit(int j, double *val)
virtual bool enableAmp(int j)=0
Enable the amplifier on a specific joint.
virtual bool setNominalCurrent(int m, const double val)
virtual bool getPWM(int j, double *val)
virtual bool getAmpStatus(int *st)=0
virtual bool setPWMLimit(int j, const double val)
virtual bool getMaxCurrent(int j, double *v)=0
Returns the maximum electric current allowed for a given motor.
virtual bool getNominalCurrent(int m, double *val)
virtual bool getPowerSupplyVoltage(int j, double *val)
virtual bool setMaxCurrent(int j, double v)=0
virtual bool setPeakCurrent(int m, const double val)
virtual bool getPeakCurrent(int m, double *val)
Interface for getting information about specific axes, if available.
virtual bool getAxisName(int axis, std::string &name)=0
virtual bool getJointType(int axis, yarp::dev::JointTypeEnum &type)
virtual bool setCalibrationParameters(int axis, const CalibrationParameters ¶ms)
Start calibration, this method is very often platform specific.
virtual bool calibrationDone(int j)=0
Check if the calibration is terminated, on a particular joint.
virtual bool calibrateAxisWithParams(int axis, unsigned int type, double p1, double p2, double p3)=0
Start calibration, this method is very often platform specific.
virtual bool getVelLimits(int axis, double *min, double *max)=0
Get the software speed limits for a particular axis.
virtual bool getLimits(int axis, double *min, double *max)=0
Get the software limits for a particular axis.
virtual bool setLimits(int axis, double min, double max)=0
Set the software limits for a particular axis, the behavior of the control card when these limits are...
virtual bool setVelLimits(int axis, double min, double max)=0
Set the software speed limits for a particular axis, the behavior of the control card when these limi...
virtual bool setControlModes(const int n_joint, const int *joints, int *modes)=0
Set the current control mode for a subset of axes.
virtual bool getControlModes(int *modes)=0
Get the current control mode (multiple joints).
virtual bool getControlMode(int j, int *mode)=0
Get the current control mode.
virtual bool setRefCurrent(int m, double curr)=0
Set the reference value of the current for a single motor.
virtual bool setRefCurrents(const double *currs)=0
Set the reference value of the currents for all motors.
virtual bool getCurrent(int m, double *curr)=0
Get the instantaneous current measurement for a single motor.
virtual bool getCurrentRange(int m, double *min, double *max)=0
Get the full scale of the current measurement for a given motor (e.g.
virtual bool getRefCurrent(int m, double *curr)=0
Get the reference value of the current for a single motor.
virtual bool getEncoderTimed(int j, double *encs, double *time)=0
Read the instantaneous acceleration of all axes.
Control board, encoder interface.
virtual bool getEncoderSpeed(int j, double *sp)=0
Read the istantaneous speed of an axis.
virtual bool setEncoder(int j, double val)=0
Set the value of the encoder for a given joint.
virtual bool getEncoder(int j, double *v)=0
Read the value of an encoder.
virtual bool resetEncoder(int j)=0
Reset encoder, single joint.
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
virtual bool getEncoderAcceleration(int j, double *spds)=0
Read the instantaneous acceleration of an axis.
virtual bool setImpedance(int j, double stiffness, double damping)=0
Set current impedance gains (stiffness,damping) for a specific joint.
virtual bool getImpedanceOffset(int j, double *offset)=0
Get current force Offset for a specific joint.
virtual bool setImpedanceOffset(int j, double offset)=0
Set current force Offset for a specific joint.
virtual bool getImpedance(int j, double *stiffness, double *damping)=0
Get current impedance gains (stiffness,damping,offset) for a specific joint.
virtual bool getCurrentImpedanceLimit(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp)=0
Get the current impedandance limits for a specific joint.
virtual bool getInteractionMode(int axis, yarp::dev::InteractionModeEnum *mode)=0
Get the current interaction mode of the robot, values can be stiff or compliant.
virtual bool getInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes)=0
Get the current interaction mode of the robot for a set of joints, values can be stiff or compliant.
virtual bool setInteractionModes(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes)=0
Set the interaction mode of the robot for a set of joints, values can be stiff or compliant.
virtual bool setInteractionMode(int axis, yarp::dev::InteractionModeEnum mode)=0
Set the interaction mode of the robot, values can be stiff or compliant.
virtual bool getLastJointFault(int j, int &fault, std::string &message)=0
virtual bool getMotorEncoderCountsPerRevolution(int m, double *cpr)=0
Gets number of counts per revolution for motor encoder m.
virtual bool setMotorEncoderCountsPerRevolution(int m, const double cpr)=0
Sets number of counts per revolution for motor encoder m.
virtual bool resetMotorEncoder(int m)=0
Reset motor encoder, single motor.
virtual bool getMotorEncoderSpeed(int m, double *sp)=0
Read the istantaneous speed of a motor encoder.
virtual bool getMotorEncoderTimed(int m, double *encs, double *time)=0
Read the instantaneous position of a motor encoder.
virtual bool getMotorEncoderAcceleration(int m, double *acc)=0
Read the instantaneous acceleration of a motor encoder.
virtual bool setMotorEncoder(int m, const double val)=0
Set the value of the motor encoder for a given motor.
virtual bool getMotorEncoder(int m, double *v)=0
Read the value of a motor encoder.
virtual bool getTemperature(int m, double *val)=0
Get temperature of a motor.
virtual bool getTemperatureLimit(int m, double *temp)=0
Retreives the current temperature limit for a specific motor.
virtual bool getGearboxRatio(int m, double *val)
Get the gearbox ratio for a specific motor.
virtual bool setTemperatureLimit(int m, const double temp)=0
Set the temperature limit for a specific motor.
virtual bool setGearboxRatio(int m, const double val)
Set the gearbox ratio for a specific motor.
virtual bool getDutyCycle(int m, double *val)=0
Gets the current dutycycle of the output of the amplifier (i.e.
virtual bool setRefDutyCycle(int m, double ref)=0
Sets the reference dutycycle to a single motor.
virtual bool getRefDutyCycle(int m, double *ref)=0
Gets the last reference sent using the setRefDutyCycle function.
virtual bool setPid(const PidControlTypeEnum &pidtype, int j, const Pid &pid)=0
Set new pid value for a joint axis.
virtual bool getPidReference(const PidControlTypeEnum &pidtype, int j, double *ref)=0
Get the current reference of the pid controller for a specific joint.
virtual bool getPidOutput(const PidControlTypeEnum &pidtype, int j, double *out)=0
Get the output of the controller (e.g.
virtual bool resetPid(const PidControlTypeEnum &pidtype, int j)=0
Reset the controller of a given joint, usually sets the current status of the joint as the reference ...
virtual bool setPidOffset(const PidControlTypeEnum &pidtype, int j, double v)=0
Set offset value for a given controller.
virtual bool getPidError(const PidControlTypeEnum &pidtype, int j, double *err)=0
Get the current error for a joint.
virtual bool getPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double *limit)=0
Get the error limit for the controller on a specific joint.
virtual bool setPidErrorLimit(const PidControlTypeEnum &pidtype, int j, double limit)=0
Set the error limit for the controller on a specifi joint.
virtual bool disablePid(const PidControlTypeEnum &pidtype, int j)=0
Disable the pid computation for a joint.
virtual bool setPidReference(const PidControlTypeEnum &pidtype, int j, double ref)=0
Set the controller reference for a given axis.
virtual bool enablePid(const PidControlTypeEnum &pidtype, int j)=0
Enable the pid computation for a joint.
virtual bool isPidEnabled(const PidControlTypeEnum &pidtype, int j, bool *enabled)=0
Get the current status (enabled/disabled) of the pid.
virtual bool getPid(const PidControlTypeEnum &pidtype, int j, Pid *pid)=0
Get current pid value for a specific joint.
virtual bool getRefAcceleration(int j, double *acc)=0
Get reference acceleration for a joint.
virtual bool setRefSpeed(int j, double sp)=0
Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.
virtual bool setRefAcceleration(int j, double acc)=0
Set reference acceleration for a joint.
virtual bool relativeMove(int j, double delta)=0
Set relative position.
virtual bool setRefSpeeds(const double *spds)=0
Set reference speed on all joints.
virtual bool checkMotionDone(int j, bool *flag)=0
Check if the current trajectory is terminated.
virtual bool getRefSpeeds(double *spds)=0
Get reference speed of all joints.
virtual bool stop(int j)=0
Stop motion, single joint.
virtual bool setRefAccelerations(const double *accs)=0
Set reference acceleration on all joints.
virtual bool getRefAccelerations(double *accs)=0
Get reference acceleration of all joints.
virtual bool getRefSpeed(int j, double *ref)=0
Get reference speed for a joint.
virtual bool positionMove(int j, double ref)=0
Set new reference point for a single axis.
virtual bool getTargetPositions(double *refs)
Get the last position reference for all axes.
virtual bool getRefPositions(double *refs)
Get the last position reference for all axes.
virtual bool setPositions(const int n_joint, const int *joints, const double *refs)=0
Set new reference point for all axes.
virtual bool setPosition(int j, double ref)=0
Set new position for a single axis.
virtual yarp::os::Stamp getLastInputStamp()=0
Return the time stamp relative to the last acquisition.
IRemoteCalibrator interface is meant to remotize the access of the calibration device in order to all...
virtual bool parkWholePart()=0
parkWholePart: start the parking procedure for the whole part
virtual bool homingSingleJoint(int j)=0
homingSingleJoint: call the homing procedure for a single joint
virtual bool isCalibratorDevicePresent(bool *isCalib)
isCalibratorDevicePresent: check if a calibrator device has been set
virtual bool quitPark()=0
quitPark: interrupt the park procedure
virtual bool parkSingleJoint(int j, bool _wait=true)=0
parkSingleJoint(): start the parking procedure for the single joint
virtual bool calibrateSingleJoint(int j)=0
calibrateSingleJoint: call the calibration procedure for the single joint
virtual bool calibrateWholePart()=0
calibrateWholePart: call the procedure for calibrating the whole device
virtual bool quitCalibrate()=0
quitCalibrate: interrupt the calibration procedure
virtual yarp::dev::IRemoteCalibrator * getCalibratorDevice()
getCalibratorDevice: return the pointer stored with the setCalibratorDevice
virtual bool setRemoteVariable(std::string key, const yarp::os::Bottle &val)=0
virtual bool getRemoteVariable(std::string key, yarp::os::Bottle &val)=0
virtual bool getRemoteVariablesList(yarp::os::Bottle *listOfKeys)=0
virtual bool setRefTorque(int j, double t)=0
Set the reference value of the torque for a given joint.
virtual bool setRefTorques(const double *t)=0
Set the reference value of the torque for all joints.
virtual bool setMotorTorqueParams(int j, const yarp::dev::MotorTorqueParameters params)
Set a subset of motor parameters (bemf, ktau etc) useful for torque control.
virtual bool getMotorTorqueParams(int j, yarp::dev::MotorTorqueParameters *params)
Get a subset of motor parameters (bemf, ktau etc) useful for torque control.
virtual bool getTorqueRange(int j, double *min, double *max)=0
Get the full scale of the torque sensor of a given joint.
virtual bool getRefTorque(int j, double *t)=0
Get the reference value of the torque for a given joint.
virtual bool getTorque(int j, double *t)=0
Get the value of the torque on a given joint (this is the feedback if you have a torque sensor).
virtual bool velocityMove(int j, double sp)=0
Start motion at a given speed, single joint.
virtual bool getRefVelocities(double *vels)
Get the last reference speed set by velocityMove for all joints.
Contains the parameters for a PID.
A simple collection of objects that can be described and transmitted in a portable way.
void fromString(const std::string &text)
Initializes bottle from a string.
void append(const Bottle &alt)
Append the content of the given bottle to the current list.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
A base class for nested structures that can be searched.
virtual std::string toString() const =0
Return a standard text representation of the content of the object.
An abstraction for a time stamp and/or sequence number.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
double getTime() const
Get the time stamp.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
virtual std::string asString() const
Get string value.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
size_t indexOfSubDeviceInPolyDriverList