16#include <QResizeEvent>
18#include <QXmlStreamWriter>
19#include <QXmlStreamAttribute>
30 m_sequenceWindow(nullptr),
32 m_mixedEnabled(
false),
33 m_positionDirectEnabled(
false),
35 m_currentEnabled(
false),
36 m_currentPidDlg(nullptr),
37 m_part_speedVisible(
false),
38 m_part_motorPositionVisible(
false),
39 m_part_dutyVisible(
false),
40 m_part_currentVisible(
false),
51 if (robotName.at(0) ==
'/') {
52 robotName.erase(0, 1);
54 if (partName.at(0) ==
'/') {
57 m_robotPartPort = std::string(
"/") + robotName +std::string(
"/") + partName;
58 m_partName = partName;
59 m_robotName = robotName;
76 yDebug(
"ADDRESS is: %s \n",
adr.toString().c_str());
89 m_interfaceError =
false;
93 m_partOptions.
put(
"device",
"remote_controlboard");
94 m_partOptions.
put(
"remote", m_robotPartPort);
95 m_partOptions.
put(
"carrier",
"udp");
101 if (m_interfaceError ==
true)
103 yError(
"Opening PolyDriver for part %s failed...", m_robotPartPort.c_str());
104 QMessageBox::critical(
nullptr,
"Error opening a device",
QString(
"Error while opening device for part ").append(m_robotPartPort.c_str()));
111 yDebug(
"Setting a valid finder \n");
120 if (m_interfaceError ==
false)
130 m_refTrajectorySpeeds[i] = std::nan(
"");
134 m_refTrajectoryPositions[i] = std::nan(
"");
138 m_refTorques[i] = std::nan(
"");
142 m_refVelocitySpeeds[i] = std::nan(
"");
146 m_torques[i] = std::nan(
"");
150 m_positions[i] = std::nan(
"");
154 m_speeds[i] = std::nan(
"");
158 m_currents[i] = std::nan(
"");
162 m_motorPositions[i] = std::nan(
"");
166 m_dutyCycles[i] = std::nan(
"");
176 yError(
"%s iencs->getEncoders() failed, retrying...\n", partName.c_str());
181 yInfo(
"%s iencs->getEncoders() ok!\n", partName.c_str());
196 yError() <<
"Error while getting position limits, part " << partName <<
" joint " <<
k;
200 yError() <<
"Error while getting velocity limits, part " << partName <<
" joint " <<
k;
204 yError() <<
"Error while getting current range, part " << partName <<
" joint " <<
k;
207 QSettings settings(
"YARP",
"yarpmotorgui");
208 double max_slider_vel = settings.value(
"velocity_slider_limit", 100.0).toDouble();
223 joint->setPWMRange(-100.0, 100.0);
225 m_layout->addWidget(
joint);
229 joint->setTorqueRange(5.0);
231 joint->enableControlPositionDirect(m_positionDirectEnabled);
232 joint->enableControlMixed(m_mixedEnabled);
233 joint->enableControlPWM(m_pwmEnabled);
234 joint->enableControlCurrent(m_currentEnabled);
236 int val_pos_choice = settings.value(
"val_pos_choice", 0).toInt();
237 int val_trq_choice = settings.value(
"val_trq_choice", 0).toInt();
238 int val_vel_choice = settings.value(
"val_vel_choice", 0).toInt();
240 double val_pos_custom_step = settings.value(
"val_pos_custom_step", 1.0).toDouble();
241 double val_trq_custom_step = settings.value(
"val_trq_custom_step", 1.0).toDouble();
242 double val_vel_custom_step = settings.value(
"val_vel_custom_step", 1.0).toDouble();
254 connect(
joint,
SIGNAL(sliderTrajectoryPositionCommand(
double,
int)),
this,
SLOT(onSliderTrajectoryPositionCommand(
double,
int)));
255 connect(
joint,
SIGNAL(sliderTrajectoryVelocityCommand(
double,
int)),
this,
SLOT(onSliderTrajectoryVelocityCommand(
double,
int)));
256 connect(
joint,
SIGNAL(sliderMixedPositionCommand(
double,
int)),
this,
SLOT(onSliderMixedPositionCommand(
double,
int)));
257 connect(
joint,
SIGNAL(sliderMixedVelocityCommand(
double,
int)),
this,
SLOT(onSliderMixedVelocityCommand(
double,
int)));
258 connect(
joint,
SIGNAL(sliderTorqueCommand(
double,
int)),
this,
SLOT(onSliderTorqueCommand(
double,
int)));
259 connect(
joint,
SIGNAL(sliderDirectPositionCommand(
double,
int)),
this,
SLOT(onSliderDirectPositionCommand(
double,
int)));
260 connect(
joint,
SIGNAL(sliderPWMCommand(
double,
int)),
this,
SLOT(onSliderPWMCommand(
double,
int)));
261 connect(
joint,
SIGNAL(sliderCurrentCommand(
double,
int)),
this,
SLOT(onSliderCurrentCommand(
double,
int)));
262 connect(
joint,
SIGNAL(sliderVelocityCommand(
double,
int)),
this,
SLOT(onSliderVelocityCommand(
double,
int)));
274 m_cycleTimer.setSingleShot(
true);
275 m_cycleTimer.setTimerType(Qt::PreciseTimer);
276 connect(&m_cycleTimer,
SIGNAL(timeout()),
this,
SLOT(onCycleTimerTimeout()), Qt::QueuedConnection);
278 m_cycleTimeTimer.setSingleShot(
true);
279 m_cycleTimeTimer.setTimerType(Qt::PreciseTimer);
280 connect(&m_cycleTimeTimer,
SIGNAL(timeout()),
this,
SLOT(onCycleTimeTimerTimeout()), Qt::QueuedConnection);
283 m_runTimeTimer.setSingleShot(
true);
284 m_runTimeTimer.setTimerType(Qt::PreciseTimer);
285 connect(&m_runTimeTimer,
SIGNAL(timeout()),
this,
SLOT(onRunTimerTimeout()), Qt::QueuedConnection);
287 m_runTimer.setSingleShot(
true);
288 m_runTimer.setTimerType(Qt::PreciseTimer);
289 connect(&m_runTimer,
SIGNAL(timeout()),
this,
SLOT(onRunTimeout()), Qt::QueuedConnection);
294 disconnect(&m_runTimer,
SIGNAL(timeout()),
this,
SLOT(onRunTimeout()));
297 disconnect(&m_runTimeTimer,
SIGNAL(timeout()),
this,
SLOT(onRunTimerTimeout()));
298 m_runTimeTimer.stop();
300 disconnect(&m_cycleTimer,
SIGNAL(timeout()),
this,
SLOT(onCycleTimerTimeout()));
303 disconnect(&m_cycleTimeTimer,
SIGNAL(timeout()),
this,
SLOT(onCycleTimeTimerTimeout()));
304 m_cycleTimeTimer.stop();
306 if (m_sequenceWindow){
307 m_sequenceWindow->hide();
308 delete m_sequenceWindow;
311 for (
int i = 0; i<m_layout->
count(); i++){
334 m_partsdd->
open(m_partOptions);
339 #ifdef DEBUG_INTERFACE
344 yError(
"Problems opening the debug client!");
355 yDebug(
"Initializing interfaces...");
370 m_ictrlmode =
nullptr;
371 m_iinteract =
nullptr;
372 m_iremCalib =
nullptr;
373 m_ijointfault =
nullptr;
378 yDebug(
"Opening interfaces...");
382 ok = m_partsdd->
view(m_iPid);
384 yError(
"...iPid was not ok...");
386 ok &= m_partsdd->
view(m_iAmp);
388 yError(
"...iAmp was not ok...");
390 ok &= m_partsdd->
view(m_iPos);
392 yError(
"...iPos was not ok...");
394 ok &= m_partsdd->
view(m_iDir);
396 yError(
"...posDirect was not ok...");
398 ok &= m_partsdd->
view(m_iVel);
400 yError(
"...iVel was not ok...");
402 ok &= m_partsdd->
view(m_iLim);
404 yError(
"...iLim was not ok...");
406 ok &= m_partsdd->
view(m_iencs);
408 yError(
"...enc was not ok...");
410 ok &= m_partsdd->
view(m_ical);
412 yError(
"...cal was not ok...");
414 ok &= m_partsdd->
view(m_iTrq);
416 yError(
"...trq was not ok...");
418 ok = m_partsdd->
view(m_iPWM);
420 yError(
"...opl was not ok...");
422 ok &= m_partsdd->
view(m_iImp);
424 yError(
"...imp was not ok...");
426 ok &= m_partsdd->
view(m_ictrlmode);
428 yError(
"...ctrlmode2 was not ok...");
430 ok &= m_partsdd->
view(m_iinteract);
432 yError(
"...iinteract was not ok...");
436 if (!m_partsdd->
view(m_ijointfault))
438 yError(
"...m_iJointFault was not ok...");
441 if (!m_partsdd->
view(m_iVar))
443 yError(
"...iVar was not ok...");
446 if (!m_partsdd->
view(m_iMot))
448 yError(
"...iMot was not ok...");
451 if (!m_partsdd->
view(m_iremCalib))
453 yError(
"...remCalib was not ok...");
456 if (!m_partsdd->
view(m_iinfo))
458 yError(
"...axisInfo was not ok...");
461 if (!m_partsdd->
view(m_iCur))
463 yError(
"...iCur was not ok...");
467 yError(
"Error while acquiring interfaces!");
468 QMessageBox::critical(
nullptr,
"Problems acquiring interfaces.",
"Check if interface is running");
469 m_interfaceError =
true;
474 yError(
"Device driver was not valid!");
475 m_interfaceError =
true;
478 return !m_interfaceError;
483 return m_interfaceError;
488 return m_partName.c_str();
491void PartItem::onSliderPWMCommand(
double pwmVal,
int index)
496void PartItem::onSliderCurrentCommand(
double currentVal,
int index)
501void PartItem::onSliderVelocityCommand(
double speedVal,
int index)
506void PartItem::onSliderTorqueCommand(
double torqueVal,
int index)
511void PartItem::onSliderTrajectoryVelocityCommand(
double trajspeedVal,
int index)
517void PartItem::onSliderDirectPositionCommand(
double dirpos,
int index)
527 yWarning(
"Joint not in position direct mode so cannot send references");
531void PartItem::onDumpAllRemoteVariables()
533 if (m_iVar ==
nullptr)
538 QString fileName = QFileDialog::getSaveFileName(
this,
QString(
"Save Dump for Remote Variables as:"), QDir::homePath()+
QString(
"/RemoteVariablesDump.txt"));
569void PartItem::onSliderTrajectoryPositionCommand(
double posVal,
int index)
580 yWarning(
"Joint not in position mode so cannot send references");
584void PartItem::onSliderMixedPositionCommand(
double posVal,
int index)
595 LOG_ERROR(
"Joint not in mixed mode so cannot send references");
599void PartItem::onSliderMixedVelocityCommand(
double vel,
int index)
610 LOG_ERROR(
"Joint not in mixed mode so cannot send references");
616 const int jointIndex =
joint->getJointIndex();
619 yInfo(
"interaction mode of joint %d set to COMPLIANT", jointIndex);
623 yInfo(
"interaction mode of joint %d set to STIFF", jointIndex);
632void PartItem::onSendPWM(
int jointIndex,
double pwmVal)
644 if (m_currentPidDlg){
704 if (m_currentPidDlg){
709void PartItem::onSendPositionPid(
int jointIndex,
Pid newPid)
716 if (m_currentPidDlg){
721void PartItem::onSendVelocityPid(
int jointIndex,
Pid newPid)
728 if (m_currentPidDlg){
733void PartItem::onRefreshPids(
int jointIndex)
797void PartItem::onSendCurrentPid(
int jointIndex,
Pid newPid)
799 if (m_iCur ==
nullptr)
801 yError() <<
"iCurrent interface not opened";
809 if (m_currentPidDlg){
814void PartItem::onSendSingleRemoteVariable(std::string key,
yarp::os::Bottle val)
820void PartItem::onUpdateAllRemoteVariables()
822 if (m_currentPidDlg){
831 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
835 if(QMessageBox::question(
this,
"Question",
"Do you really want to recalibrate the joint?") != QMessageBox::Yes){
844 QMessageBox::critical(
this,
"Calibration failed",
QString(
"No calibrator device was configured to perform this action, please verify that the wrapper config file has the 'Calibrator' keyword in the attach phase"));
846 QMessageBox::critical(
this,
"Calibration failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
854 const int jointIndex =
joint->getJointIndex();
856 m_currentPidDlg =
new PidDlg(m_partName.c_str(), jointIndex, jointName);
857 connect(m_currentPidDlg,
SIGNAL(sendPositionPid(
int,
Pid)),
this,
SLOT(onSendPositionPid(
int,
Pid)));
858 connect(m_currentPidDlg,
SIGNAL(sendVelocityPid(
int,
Pid)),
this,
SLOT(onSendVelocityPid(
int,
Pid)));
859 connect(m_currentPidDlg,
SIGNAL(sendCurrentPid(
int,
Pid)),
this,
SLOT(onSendCurrentPid(
int,
Pid)));
861 connect(m_currentPidDlg,
SIGNAL(updateAllRemoteVariables()),
this,
SLOT(onUpdateAllRemoteVariables()));
863 connect(m_currentPidDlg,
SIGNAL(sendStiffness(
int,
double,
double)),
this,
SLOT(onSendStiffness(
int,
double,
double)));
864 connect(m_currentPidDlg,
SIGNAL(sendForceOffset(
int,
double)),
this,
SLOT(onSendForceOffset(
int,
double)));
865 connect(m_currentPidDlg,
SIGNAL(sendPWM(
int,
double)),
this,
SLOT(onSendPWM(
int,
double)));
866 connect(m_currentPidDlg,
SIGNAL(refreshPids(
int)),
this,
SLOT(onRefreshPids(
int)));
867 connect(m_currentPidDlg,
SIGNAL(dumpRemoteVariables()),
this,
SLOT(onDumpAllRemoteVariables()));
869 this->onRefreshPids(jointIndex);
871 m_currentPidDlg->exec();
873 delete m_currentPidDlg;
874 m_currentPidDlg =
nullptr;
879 const int jointIndex =
joint->getJointIndex();
890 const int jointIndex =
joint->getJointIndex();
897 const int jointIndex =
joint->getJointIndex();
905 const int jointIndex =
joint->getJointIndex();
908 yInfo(
"joint: %d in IDLE mode", jointIndex);
912 yError(
"ERROR: cannot do!");
917 yInfo(
"joint: %d in POSITION mode", jointIndex);
920 joint->resetTarget();
922 yError(
"ERROR: cannot do!");
928 yInfo(
"joint: %d in POSITION DIRECT mode", jointIndex);
930 joint->resetTarget();
933 yError(
"ERROR: cannot do!");
948 yInfo(
"joint: %d in MIXED mode", jointIndex);
950 joint->resetTarget();
953 yError(
"ERROR: cannot do!");
969 yInfo(
"joint: %d in VELOCITY mode", jointIndex);
973 yInfo() <<
"Changing reference acceleration of joint " << jointIndex <<
" to 100000";
976 yError(
"ERROR: cannot do!");
992 yInfo(
"joint: %d in TORQUE mode", jointIndex);
996 yError(
"ERROR: cannot do!");
1011 yInfo(
"joint: %d in PWM mode", jointIndex);
1015 yError(
"ERROR: cannot do!");
1020 yInfo(
"joint: %d in CURRENT mode", jointIndex);
1025 yError(
"ERROR: cannot do!");
1036 int count = m_layout->
count();
1051 for(
int i=0;i<count;i++){
1063 return m_layout->
count();
1094 if(event->type() == QEvent::WindowStateChange ){
1095 qDebug() <<
"State Changed " << width();
1096 int count = m_layout->
count();
1110 for(
int i=0;i<count;i++){
1125 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
1135 QMessageBox::critical(
this,
"Calibration failed",
QString(
"No calibrator device was configured to perform this action, please verify that the wrapper config file for part %1 has the 'Calibrator' keyword in the attach phase").arg(m_partName.c_str()));
1137 QMessageBox::critical(
this,
"Calibration failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
1146 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
1157 QMessageBox::critical(
this,
"Operation failed",
QString(
"No calibrator device was configured to perform this action, please verify that the wrapper config file for part %1 has the 'Calibrator' keyword in the attach phase").arg(m_partName.c_str()));
1162 QMessageBox::critical(
this,
"Operation failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
1173 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
1184 QMessageBox::critical(
this,
"Operation failed",
QString(
"No calibrator device was configured to perform this action, please verify that the wrapper config file for part %1 has the 'Calibrator' keyword in the attach phase").arg(m_partName.c_str()));
1189 QMessageBox::critical(
this,
"Operation failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
1203 QMessageBox::critical(
this,
"Operation failed",
QString(
"No custom position supplied in configuration file for part ") +
QString(m_partName.c_str()));
1219 double velocity =
ytmp.get(jointIndex + 1).asFloat64();
1226 QMessageBox::critical(
this,
"Error",
QString(
"Check the number of entries in the group %1").arg(m_robotPartPort.c_str()));
1245 if (!m_sequenceWindow){
1256 if (!m_sequenceWindow){
1267 if (!m_sequenceWindow){
1276 if (!m_sequenceWindow){
1308 if (m_sequenceWindow)
1310 m_sequenceWindow->close();
1316 if (!m_sequenceWindow){
1318 connect(m_sequenceWindow,
SIGNAL(itemDoubleClicked(
int)),
this,
SLOT(onSequenceWindowDoubleClicked(
int)), Qt::DirectConnection);
1324 connect(m_sequenceWindow,
SIGNAL(openSequence()),
this,
SLOT(onOpenSequence()));
1343 if (!m_sequenceWindow->isVisible()){
1344 m_sequenceWindow->show();
1346 m_sequenceWindow->setFocus();
1347 m_sequenceWindow->raise();
1348 m_sequenceWindow->setWindowState(Qt::WindowActive);
1355 if (!m_sequenceWindow){
1363 m_cycleTimer.stop();
1365 m_runTimeTimer.stop();
1366 m_cycleTimeTimer.stop();
1370void PartItem::onStopSequence()
1375void PartItem::onOpenSequence()
1377 QString fileName = QFileDialog::getOpenFileName(m_sequenceWindow,
QString(
"Load Sequence for part %1 As").arg(m_partName.c_str()), QDir::homePath());
1380 if(!
fInfo.exists()){
1388 QMessageBox::critical(
this,
"Error Loading The Sequence",
1389 QString(
"Wrong format (check extensions) of the file associated with: ").arg(m_partName.c_str()));
1393 QFile file(fileName);
1394 if (!file.open(QFile::ReadOnly | QFile::Text)){
1397 QMessageBox::critical(
this,
"Error Loading The Sequence",msg);
1408 while(!reader.atEnd()){
1411 if(reader.isStartElement()){
1412 if(reader.name().contains(
"Sequence_")){
1414 referencePart = attributes.value(
"ReferencePart").toString();
1417 if(reader.name() ==
"Position"){
1419 int index = attributes.value(
"Index").toInt();
1420 double timing = attributes.value(
"Timing").toDouble();
1421 item.setTiming(timing);
1422 item.setSequenceNumber(index);
1425 if(reader.name() ==
"JointPositions"){
1427 int count = attributes.value(
"Count").toInt();
1430 for(
int i=0; i<count;i++){
1432 if(reader.name() ==
"PosValue"){
1433 double pos = reader.readElementText().toDouble();
1434 item.addPositionValue(pos);
1441 if(reader.name() ==
"JointVelocities"){
1443 int count = attributes.value(
"Count").toInt();
1446 for(
int i=0; i<count;i++){
1448 if(reader.name() ==
"SpeedValue"){
1449 double speed = reader.readElementText().toDouble();
1450 item.addSpeedValue(speed);
1459 if(reader.isEndElement()){
1460 if(reader.name() ==
"Position"){
1469 if (reader.hasError())
1472 QMessageBox::critical(
this,
"Error Loading The Sequence",msg);
1474 }
else if (file.error() != QFile::NoError) {
1476 QMessageBox::critical(
this,
"Error Loading The Sequence",msg);
1480 if (m_sequenceWindow){
1490 fileName = QFileDialog::getSaveFileName(
this,
QString(
"Save Sequence for part %1 As").arg(m_partName.c_str()), QDir::homePath());
1493 if(fileName.isEmpty()){
1505 if(!file.open(QIODevice::WriteOnly)){
1510 writer.setAutoFormatting(
true);
1511 writer.writeStartDocument();
1513 writer.writeStartElement(
QString(
"Sequence_pos%1").arg(m_partName.c_str()));
1515 writer.writeAttribute(
"TotPositions",
QString(
"%1").arg(
values.count()));
1516 writer.writeAttribute(
"ReferencePart", m_partName.c_str());
1518 for(
int i=0;i<
values.count();i++){
1520 writer.writeStartElement(
"Position");
1524 writer.writeStartElement(
"JointPositions");
1528 writer.writeTextElement(
"PosValue",s);
1530 writer.writeEndElement();
1532 writer.writeStartElement(
"JointVelocities");
1536 writer.writeTextElement(
"SpeedValue",s);
1538 writer.writeEndElement();
1539 writer.writeEndElement();
1541 writer.writeEndElement();
1542 writer.writeEndDocument();
1544 LOG_INFO(
"File saved and closed\n");
1584 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1588 m_cycleTimeValues.clear();
1589 for(
int i=0;i<
values.count();i++){
1591 if(
it.getTiming() > 0){
1592 m_cycleTimeValues.append(
it);
1597 if (m_cycleTimeValues.count() > 0)
1599 vals = m_cycleTimeValues.takeFirst();
1600 m_cycleTimeValues.append(
vals);
1602 fixedTimeMove(
vals);
1603 m_cycleTimeTimer.start(
vals.getTiming() * 1000);
1608void PartItem::onCycleTimeTimerTimeout()
1610 if (m_cycleTimeValues.count() > 0)
1613 m_cycleTimeValues.append(
vals);
1615 fixedTimeMove(
vals);
1616 m_cycleTimeTimer.start(
vals.getTiming() * 1000);
1623 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1627 m_cycleValues.clear();
1628 for(
int i=0;i<
values.count();i++){
1630 if(
it.getTiming() > 0){
1631 m_cycleValues.append(
it);
1636 if (m_cycleValues.count() > 0){
1637 vals = m_cycleValues.takeFirst();
1639 m_cycleValues.append(
vals);
1644 for(
int i=0;i<
vals.getPositions().count();i++){
1654 m_cycleTimer.start(
vals.getTiming() * 1000);
1660void PartItem::onCycleTimerTimeout()
1662 if (m_cycleValues.count() > 0){
1665 m_cycleValues.append(
vals);
1670 for(
int i=0;i<
vals.getPositions().count();i++){
1680 m_cycleTimer.start(
vals.getTiming() * 1000);
1687 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1691 m_runValues.clear();
1692 for(
int i=0;i<
values.count();i++){
1694 if(
it.getTiming() > 0){
1695 m_runValues.append(
it);
1700 if (m_runValues.count() > 0){
1701 vals = m_runValues.takeFirst();
1703 m_runValues.append(
vals);
1708 for(
int i=0;i<
vals.getPositions().count();i++){
1718 m_runTimer.start(
vals.getTiming() * 1000);
1723void PartItem::onRunTimeout()
1725 if (m_runValues.count() > 0){
1727 if(
vals.getTiming() < 0){
1734 for(
int i=0;i<
vals.getPositions().count();i++){
1746 m_runTimer.start(
vals.getTiming() * 1000);
1756 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1760 m_runTimeValues.clear();
1762 for(
int i=0;i<
values.count();i++){
1764 if(
it.getTiming() > 0){
1765 m_runTimeValues.append(
it);
1770 if (m_runTimeValues.count() > 0){
1771 vals = m_runTimeValues.takeFirst();
1774 fixedTimeMove(
vals);
1775 m_runTimeTimer.start(
vals.getTiming() * 1000);
1782void PartItem::onRunTimerTimeout()
1784 if (m_runTimeValues.count() > 0){
1786 if(
vals.getTiming() < 0){
1791 fixedTimeMove(
vals);
1792 m_runTimeTimer.start(
vals.getTiming() * 1000);
1826 m_sequence_port_stamp.
update();
1827 m_sequence_port.
setEnvelope(m_sequence_port_stamp);
1829 m_sequence_port.
write(v);
1840 QMessageBox::critical(
this,
"Error",
"Select an entry in the table before performing a movement");
1854void PartItem::onSequenceActivated()
1856 for (
int i = 0; i<m_layout->
count(); i++)
1860 joint->sequenceActivated();
1868void PartItem::onSequenceStopped()
1870 for (
int i = 0; i<m_layout->
count(); i++)
1874 joint->sequenceStopped();
1880void PartItem::onSequenceWindowDoubleClicked(
int sequenceNum)
1884 for (
int i = 0; i<m_layout->
count(); i++)
1887 values.append(this->m_positions[i]);
1888 speeds.append(
joint->getTrajectoryVelocityValue());
1896 for (
int i = 0; i<m_layout->
count(); i++)
1905 for (
int i = 0; i<m_layout->
count(); i++)
1914 for (
int i = 0; i<m_layout->
count(); i++)
1923 for (
int i = 0; i<m_layout->
count(); i++)
1932 for (
int i = 0; i<m_layout->
count(); i++)
1941 for (
int i = 0; i<m_layout->
count(); i++)
1950 m_part_speedVisible = view;
1951 for (
int i = 0; i<m_layout->
count(); i++)
1954 joint->setSpeedVisible(view);
1960 m_part_motorPositionVisible = view;
1961 for (
int i = 0; i<m_layout->
count(); i++)
1964 joint->setMotorPositionVisible(view);
1970 m_part_dutyVisible = view;
1971 for (
int i = 0; i<m_layout->
count(); i++)
1974 joint->setDutyVisible(view);
1980 m_part_currentVisible = view;
1981 for (
int i = 0; i<m_layout->
count(); i++)
1984 joint->setCurrentsVisible(view);
1990 for (
int i = 0; i<m_layout->
count(); i++)
1999 for (
int i = 0; i < m_layout->
count(); i++)
2002 joint->viewPositionTargetValue(
ena);
2008 for (
int i = 0; i<m_layout->
count(); i++)
2013 joint->enablePositionSliderDoubleAuto();
2017 joint->enablePositionSliderDoubleValue(step);
2021 joint->enablePositionSliderDoubleValue(1.0);
2025 joint->disablePositionSliderDouble();
2032 for (
int i = 0; i<m_layout->
count(); i++)
2037 joint->enableVelocitySliderDoubleAuto();
2038 joint->enableTrajectoryVelocitySliderDoubleAuto();
2042 joint->enableVelocitySliderDoubleValue(step);
2043 joint->enableTrajectoryVelocitySliderDoubleValue(step);
2047 joint->enableVelocitySliderDoubleValue(1.0);
2048 joint->enableTrajectoryVelocitySliderDoubleValue(1.0);
2052 joint->disableVelocitySliderDouble();
2053 joint->disableTrajectoryVelocitySliderDouble();
2060 for (
int i = 0; i<m_layout->
count(); i++)
2065 joint->enableCurrentSliderDoubleAuto();
2069 joint->enableCurrentSliderDoubleValue(step);
2073 joint->enableCurrentSliderDoubleValue(1.0);
2077 joint->disableCurrentSliderDouble();
2084 for (
int i = 0; i<m_layout->
count(); i++)
2089 joint->enableTorqueSliderDoubleAuto();
2093 joint->enableTorqueSliderDoubleValue(step);
2097 joint->enableTorqueSliderDoubleValue(1.0);
2101 joint->disableTorqueSliderDouble();
2120 m_modesList.resize(m_layout->
count());
2121 for (
int k = 0;
k < m_layout->
count();
k++){
2122 switch (m_controlModes[
k])
2184 LOG_ERROR(
"Lost connection with the robot. You should save and restart.\n" );
2187 for (
int i = 0; i<m_layout->
count(); i++){
2199 if (!b) {
yWarning(
"Unable to update encoders");
return false; }
2204 if (!b) {
yWarning(
"Unable to update torques"); }
2206 if (this->m_part_currentVisible)
2209 if (!b) {
yWarning(
"Unable to update currents"); }
2211 if (this->m_part_speedVisible)
2214 if (!b) {
yWarning(
"Unable to update speeds"); }
2216 if (this->m_part_motorPositionVisible)
2219 if (!b) {
yWarning(
"Unable to update motorPositions"); }
2221 if (this->m_part_dutyVisible)
2224 if (!b) {
yWarning(
"Unable to update dutyCycles"); }
2239 yError() <<
"Missing Implementation of getTargetPosition()";
2243 yError() <<
"Missing Implementation of getRefVelocity()";
2247 yError() <<
"Missing Implementation of getRefSpeed()";
2251 yError() <<
"Missing Implementation of getRefTorque()";
2255 yError() <<
"Missing Implementation of checkMotionDone()";
2262 if (
true) {
joint->setPosition(m_positions[
jk]); }
2264 if (
true) {
joint->setTorque(m_torques[
jk]); }
2266 if (
true) {
joint->setSpeed(m_speeds[
jk]); }
2268 if (
true) {
joint->setCurrent(m_currents[
jk]); }
2270 if (
true) {
joint->setMotorPosition(m_motorPositions[
jk]); }
2272 if (
true) {
joint->setDutyCycles(m_dutyCycles[
jk]); }
2300 LOG_ERROR(
"iint->getInteractionlMode failed\n" );
2311 std::string message;
2319 LOG_ERROR(
"Unsuccessful call to getLastJointFault()\n");
2329 switch (m_controlModes[
k])
2352 double ref_current = 0;
2354 joint->setRefCurrent(ref_current);
2385 switch (m_interactionModes[
k])
constexpr yarp::conf::vocab32_t VOCAB_CM_UNKNOWN
constexpr yarp::conf::vocab32_t VOCAB_CM_MIXED
constexpr yarp::conf::vocab32_t VOCAB_CM_TORQUE
constexpr yarp::conf::vocab32_t VOCAB_CM_PWM
constexpr yarp::conf::vocab32_t VOCAB_CM_HW_FAULT
constexpr yarp::conf::vocab32_t VOCAB_CM_IDLE
constexpr yarp::conf::vocab32_t VOCAB_CM_CALIB_DONE
constexpr yarp::conf::vocab32_t VOCAB_CM_NOT_CONFIGURED
constexpr yarp::conf::vocab32_t VOCAB_CM_POSITION
constexpr yarp::conf::vocab32_t VOCAB_CM_CONFIGURED
constexpr yarp::conf::vocab32_t VOCAB_CM_CURRENT
constexpr yarp::conf::vocab32_t VOCAB_CM_POSITION_DIRECT
constexpr yarp::conf::vocab32_t VOCAB_CM_VELOCITY
constexpr yarp::conf::vocab32_t VOCAB_CM_FORCE_IDLE
constexpr yarp::conf::vocab32_t VOCAB_CM_CALIBRATING
int SIGNAL(int pid, int signum)
Original license follows:
QLayoutItem * itemAt(int index) const override
int count() const override
void onSetCurSliderOptionPI(int mode, double step)
void onViewDutyCycles(bool)
bool homeToCustomPosition(const yarp::os::Bottle &positionElement)
void setCurrentIndex(int)
JointItem * getJointWidget(int jointIndex)
void onEnableControlCurrent(bool control)
void onViewMotorPositions(bool)
void onEnableControlPWM(bool control)
void onEnableControlVelocity(bool control)
QString getJointName(int joint)
void onViewPositionTargetValue(bool)
void onViewPositionTargetBox(bool)
bool homeJoint(int joint)
void onViewCurrentValues(bool)
void sendPartJointsValues(int, QList< double >, QList< double >)
bool checkAndCycleAllSeq()
void closeSequenceWindow()
void onViewSpeedValues(bool)
void openSequenceWindow()
void onEnableControlPositionDirect(bool control)
void saveSequence(QString global_filename)
void resizeEvent(QResizeEvent *event) override
void changeEvent(QEvent *event) override
void onEnableControlTorque(bool control)
PartItem(std::string robotName, int partId, std::string partName, ResourceFinder &_finder, bool debug_param_enabled, bool speedview_param_enabled, bool enable_calib_all, QWidget *parent=0)
const QVector< JointItem::JointState > & getPartModes()
void onEnableControlMixed(bool control)
void onSetPosSliderOptionPI(int mode, double step, int numOfDec)
void onSetTrqSliderOptionPI(int mode, double step)
bool checkAndRunTimeAllSeq()
bool checkAndCycleTimeAllSeq()
void onSetVelSliderOptionPI(int mode, double step)
void initVelocity(Pid myPid)
void initPosition(Pid myPid)
void initTorque(Pid myPid, MotorTorqueParameters TorqueParam)
void initTorqueOffset(double curForceVal, double minForce, double maxForce)
void initCurrent(Pid myPid)
void initStiffness(double curStiffVal, double minStiff, double maxStiff, double curDampVal, double minDamp, double maxDamp)
void initRemoteVariables(IRemoteVariables *iVar)
void initPWM(double pwmVal, double pwm)
bool checkAndCycleTimeSeq()
void save(QString global_filename)
void loadSequence(QList< SequenceItem >)
bool view(T *&x)
Get an interface to the device driver.
virtual bool getAxisName(int axis, std::string &name)=0
virtual bool getJointType(int axis, yarp::dev::JointTypeEnum &type)
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 setControlMode(const int j, const int mode)=0
Set the current control mode.
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 getCurrents(double *currs)=0
Get the instantaneous current measurement for all motors.
virtual bool setRefCurrent(int m, double curr)=0
Set the reference value of the current 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 getEncoder(int j, double *v)=0
Read the value of an encoder.
virtual bool getEncoders(double *encs)=0
Read the position of all axes.
virtual bool getEncoderSpeeds(double *spds)=0
Read the instantaneous speed of all axes.
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 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 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 getMotorEncoders(double *encs)=0
Read the position of all motor encoders.
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 getDutyCycles(double *vals)=0
Gets the current dutycycle of the output of the amplifier (i.e.
virtual bool setPid(const PidControlTypeEnum &pidtype, int j, const Pid &pid)=0
Set new pid value for a joint axis.
virtual bool getPid(const PidControlTypeEnum &pidtype, int j, Pid *pid)=0
Get current pid value for a specific joint.
virtual bool getAxes(int *ax)=0
Get the number of controlled axes.
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 getTargetPosition(const int joint, double *ref)
Get the last position reference for the specified axis.
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 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 setPosition(int j, double ref)=0
Set new position for a single axis.
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 homingWholePart()=0
homingWholePart: call the homing procedure for a the whole part/device
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 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 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 getTorques(double *t)=0
Get the value of the torque for all joints (this is the feedback if you have torque sensors).
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 setRefAcceleration(int j, double acc)=0
Set reference acceleration for a joint.
virtual bool getRefVelocity(const int joint, double *vel)
Get the last reference speed set by velocityMove for single joint.
virtual bool velocityMove(int j, double sp)=0
Start motion at a given speed, single joint.
Contains the parameters for a PID.
A container for a device driver.
bool close() override
Close the DeviceDriver.
bool isValid() const
Check if device is valid.
bool open(const std::string &txt)
Construct and configure a device by its common name.
A simple collection of objects that can be described and transmitted in a portable way.
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 mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
bool setEnvelope(PortWriter &envelope) override
Set an envelope (e.g., a timestamp) to the next message which will be sent.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Helper class for finding config files and other external resources.
bool isNull() const override
Checks if the object is invalid.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
static void delaySystem(double seconds)
virtual bool isString() const
Checks if value is a string.
virtual std::string asString() const
Get string value.
bool speedview_param_enabled
@ VOCAB_JOINTTYPE_REVOLUTE