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){
693 if (m_currentPidDlg){
698void PartItem::onSendPositionPid(
int jointIndex,
Pid newPid)
705 if (m_currentPidDlg){
710void PartItem::onSendVelocityPid(
int jointIndex,
Pid newPid)
717 if (m_currentPidDlg){
722void PartItem::onRefreshPids(
int jointIndex)
785void PartItem::onSendCurrentPid(
int jointIndex,
Pid newPid)
787 if (m_iCur ==
nullptr)
789 yError() <<
"iCurrent interface not opened";
797 if (m_currentPidDlg){
802void PartItem::onSendSingleRemoteVariable(std::string key,
yarp::os::Bottle val)
808void PartItem::onUpdateAllRemoteVariables()
810 if (m_currentPidDlg){
819 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
823 if(QMessageBox::question(
this,
"Question",
"Do you really want to recalibrate the joint?") != QMessageBox::Yes){
832 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"));
834 QMessageBox::critical(
this,
"Calibration failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
842 const int jointIndex =
joint->getJointIndex();
844 m_currentPidDlg =
new PidDlg(m_partName.c_str(), jointIndex, jointName);
845 connect(m_currentPidDlg,
SIGNAL(sendPositionPid(
int,
Pid)),
this,
SLOT(onSendPositionPid(
int,
Pid)));
846 connect(m_currentPidDlg,
SIGNAL(sendVelocityPid(
int,
Pid)),
this,
SLOT(onSendVelocityPid(
int,
Pid)));
847 connect(m_currentPidDlg,
SIGNAL(sendCurrentPid(
int,
Pid)),
this,
SLOT(onSendCurrentPid(
int,
Pid)));
849 connect(m_currentPidDlg,
SIGNAL(updateAllRemoteVariables()),
this,
SLOT(onUpdateAllRemoteVariables()));
851 connect(m_currentPidDlg,
SIGNAL(sendStiffness(
int,
double,
double,
double)),
this,
SLOT(onSendStiffness(
int,
double,
double,
double)));
852 connect(m_currentPidDlg,
SIGNAL(sendPWM(
int,
double)),
this,
SLOT(onSendPWM(
int,
double)));
853 connect(m_currentPidDlg,
SIGNAL(refreshPids(
int)),
this,
SLOT(onRefreshPids(
int)));
854 connect(m_currentPidDlg,
SIGNAL(dumpRemoteVariables()),
this,
SLOT(onDumpAllRemoteVariables()));
856 this->onRefreshPids(jointIndex);
858 m_currentPidDlg->exec();
860 delete m_currentPidDlg;
861 m_currentPidDlg =
nullptr;
866 const int jointIndex =
joint->getJointIndex();
877 const int jointIndex =
joint->getJointIndex();
884 const int jointIndex =
joint->getJointIndex();
892 const int jointIndex =
joint->getJointIndex();
895 yInfo(
"joint: %d in IDLE mode", jointIndex);
899 yError(
"ERROR: cannot do!");
904 yInfo(
"joint: %d in POSITION mode", jointIndex);
907 joint->resetTarget();
909 yError(
"ERROR: cannot do!");
915 yInfo(
"joint: %d in POSITION DIRECT mode", jointIndex);
917 joint->resetTarget();
920 yError(
"ERROR: cannot do!");
935 yInfo(
"joint: %d in MIXED mode", jointIndex);
937 joint->resetTarget();
940 yError(
"ERROR: cannot do!");
956 yInfo(
"joint: %d in VELOCITY mode", jointIndex);
960 yInfo() <<
"Changing reference acceleration of joint " << jointIndex <<
" to 100000";
963 yError(
"ERROR: cannot do!");
979 yInfo(
"joint: %d in TORQUE mode", jointIndex);
983 yError(
"ERROR: cannot do!");
998 yInfo(
"joint: %d in PWM mode", jointIndex);
1002 yError(
"ERROR: cannot do!");
1007 yInfo(
"joint: %d in CURRENT mode", jointIndex);
1012 yError(
"ERROR: cannot do!");
1023 int count = m_layout->
count();
1038 for(
int i=0;i<count;i++){
1050 return m_layout->
count();
1081 if(event->type() == QEvent::WindowStateChange ){
1082 qDebug() <<
"State Changed " << width();
1083 int count = m_layout->
count();
1097 for(
int i=0;i<count;i++){
1112 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
1122 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()));
1124 QMessageBox::critical(
this,
"Calibration failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
1133 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
1144 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()));
1149 QMessageBox::critical(
this,
"Operation failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
1160 QMessageBox::critical(
this,
"Operation not supported",
QString(
"The IRemoteCalibrator interface was not found on this application"));
1171 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()));
1176 QMessageBox::critical(
this,
"Operation failed",
QString(
"The remote calibrator reported that something went wrong during the calibration procedure"));
1190 QMessageBox::critical(
this,
"Operation failed",
QString(
"No custom position supplied in configuration file for part ") +
QString(m_partName.c_str()));
1206 double velocity =
ytmp.get(jointIndex + 1).asFloat64();
1213 QMessageBox::critical(
this,
"Error",
QString(
"Check the number of entries in the group %1").arg(m_robotPartPort.c_str()));
1232 if (!m_sequenceWindow){
1243 if (!m_sequenceWindow){
1254 if (!m_sequenceWindow){
1263 if (!m_sequenceWindow){
1295 if (m_sequenceWindow)
1297 m_sequenceWindow->close();
1303 if (!m_sequenceWindow){
1305 connect(m_sequenceWindow,
SIGNAL(itemDoubleClicked(
int)),
this,
SLOT(onSequenceWindowDoubleClicked(
int)), Qt::DirectConnection);
1311 connect(m_sequenceWindow,
SIGNAL(openSequence()),
this,
SLOT(onOpenSequence()));
1330 if (!m_sequenceWindow->isVisible()){
1331 m_sequenceWindow->show();
1333 m_sequenceWindow->setFocus();
1334 m_sequenceWindow->raise();
1335 m_sequenceWindow->setWindowState(Qt::WindowActive);
1342 if (!m_sequenceWindow){
1350 m_cycleTimer.stop();
1352 m_runTimeTimer.stop();
1353 m_cycleTimeTimer.stop();
1357void PartItem::onStopSequence()
1362void PartItem::onOpenSequence()
1364 QString fileName = QFileDialog::getOpenFileName(m_sequenceWindow,
QString(
"Load Sequence for part %1 As").arg(m_partName.c_str()), QDir::homePath());
1367 if(!
fInfo.exists()){
1375 QMessageBox::critical(
this,
"Error Loading The Sequence",
1376 QString(
"Wrong format (check extensions) of the file associated with: ").arg(m_partName.c_str()));
1380 QFile file(fileName);
1381 if (!file.open(QFile::ReadOnly | QFile::Text)){
1384 QMessageBox::critical(
this,
"Error Loading The Sequence",msg);
1395 while(!reader.atEnd()){
1398 if(reader.isStartElement()){
1399 if(reader.name().contains(
"Sequence_")){
1401 referencePart = attributes.value(
"ReferencePart").toString();
1404 if(reader.name() ==
"Position"){
1406 int index = attributes.value(
"Index").toInt();
1407 double timing = attributes.value(
"Timing").toDouble();
1408 item.setTiming(timing);
1409 item.setSequenceNumber(index);
1412 if(reader.name() ==
"JointPositions"){
1414 int count = attributes.value(
"Count").toInt();
1417 for(
int i=0; i<count;i++){
1419 if(reader.name() ==
"PosValue"){
1420 double pos = reader.readElementText().toDouble();
1421 item.addPositionValue(pos);
1428 if(reader.name() ==
"JointVelocities"){
1430 int count = attributes.value(
"Count").toInt();
1433 for(
int i=0; i<count;i++){
1435 if(reader.name() ==
"SpeedValue"){
1436 double speed = reader.readElementText().toDouble();
1437 item.addSpeedValue(speed);
1446 if(reader.isEndElement()){
1447 if(reader.name() ==
"Position"){
1456 if (reader.hasError())
1459 QMessageBox::critical(
this,
"Error Loading The Sequence",msg);
1461 }
else if (file.error() != QFile::NoError) {
1463 QMessageBox::critical(
this,
"Error Loading The Sequence",msg);
1467 if (m_sequenceWindow){
1477 fileName = QFileDialog::getSaveFileName(
this,
QString(
"Save Sequence for part %1 As").arg(m_partName.c_str()), QDir::homePath());
1480 if(fileName.isEmpty()){
1492 if(!file.open(QIODevice::WriteOnly)){
1497 writer.setAutoFormatting(
true);
1498 writer.writeStartDocument();
1500 writer.writeStartElement(
QString(
"Sequence_pos%1").arg(m_partName.c_str()));
1502 writer.writeAttribute(
"TotPositions",
QString(
"%1").arg(
values.count()));
1503 writer.writeAttribute(
"ReferencePart", m_partName.c_str());
1505 for(
int i=0;i<
values.count();i++){
1507 writer.writeStartElement(
"Position");
1511 writer.writeStartElement(
"JointPositions");
1515 writer.writeTextElement(
"PosValue",s);
1517 writer.writeEndElement();
1519 writer.writeStartElement(
"JointVelocities");
1523 writer.writeTextElement(
"SpeedValue",s);
1525 writer.writeEndElement();
1526 writer.writeEndElement();
1528 writer.writeEndElement();
1529 writer.writeEndDocument();
1531 LOG_INFO(
"File saved and closed\n");
1571 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1575 m_cycleTimeValues.clear();
1576 for(
int i=0;i<
values.count();i++){
1578 if(
it.getTiming() > 0){
1579 m_cycleTimeValues.append(
it);
1584 if (m_cycleTimeValues.count() > 0)
1586 vals = m_cycleTimeValues.takeFirst();
1587 m_cycleTimeValues.append(
vals);
1589 fixedTimeMove(
vals);
1590 m_cycleTimeTimer.start(
vals.getTiming() * 1000);
1595void PartItem::onCycleTimeTimerTimeout()
1597 if (m_cycleTimeValues.count() > 0)
1600 m_cycleTimeValues.append(
vals);
1602 fixedTimeMove(
vals);
1603 m_cycleTimeTimer.start(
vals.getTiming() * 1000);
1610 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1614 m_cycleValues.clear();
1615 for(
int i=0;i<
values.count();i++){
1617 if(
it.getTiming() > 0){
1618 m_cycleValues.append(
it);
1623 if (m_cycleValues.count() > 0){
1624 vals = m_cycleValues.takeFirst();
1626 m_cycleValues.append(
vals);
1631 for(
int i=0;i<
vals.getPositions().count();i++){
1641 m_cycleTimer.start(
vals.getTiming() * 1000);
1647void PartItem::onCycleTimerTimeout()
1649 if (m_cycleValues.count() > 0){
1652 m_cycleValues.append(
vals);
1657 for(
int i=0;i<
vals.getPositions().count();i++){
1667 m_cycleTimer.start(
vals.getTiming() * 1000);
1674 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1678 m_runValues.clear();
1679 for(
int i=0;i<
values.count();i++){
1681 if(
it.getTiming() > 0){
1682 m_runValues.append(
it);
1687 if (m_runValues.count() > 0){
1688 vals = m_runValues.takeFirst();
1690 m_runValues.append(
vals);
1695 for(
int i=0;i<
vals.getPositions().count();i++){
1705 m_runTimer.start(
vals.getTiming() * 1000);
1710void PartItem::onRunTimeout()
1712 if (m_runValues.count() > 0){
1714 if(
vals.getTiming() < 0){
1721 for(
int i=0;i<
vals.getPositions().count();i++){
1733 m_runTimer.start(
vals.getTiming() * 1000);
1743 if (m_cycleTimeTimer.isActive() || m_cycleTimer.isActive() || m_runTimeTimer.isActive() || m_runTimer.isActive()){
1747 m_runTimeValues.clear();
1749 for(
int i=0;i<
values.count();i++){
1751 if(
it.getTiming() > 0){
1752 m_runTimeValues.append(
it);
1757 if (m_runTimeValues.count() > 0){
1758 vals = m_runTimeValues.takeFirst();
1761 fixedTimeMove(
vals);
1762 m_runTimeTimer.start(
vals.getTiming() * 1000);
1769void PartItem::onRunTimerTimeout()
1771 if (m_runTimeValues.count() > 0){
1773 if(
vals.getTiming() < 0){
1778 fixedTimeMove(
vals);
1779 m_runTimeTimer.start(
vals.getTiming() * 1000);
1813 m_sequence_port_stamp.
update();
1814 m_sequence_port.
setEnvelope(m_sequence_port_stamp);
1816 m_sequence_port.
write(v);
1827 QMessageBox::critical(
this,
"Error",
"Select an entry in the table before performing a movement");
1841void PartItem::onSequenceActivated()
1843 for (
int i = 0; i<m_layout->
count(); i++)
1847 joint->sequenceActivated();
1855void PartItem::onSequenceStopped()
1857 for (
int i = 0; i<m_layout->
count(); i++)
1861 joint->sequenceStopped();
1867void PartItem::onSequenceWindowDoubleClicked(
int sequenceNum)
1871 for (
int i = 0; i<m_layout->
count(); i++)
1874 values.append(this->m_positions[i]);
1875 speeds.append(
joint->getTrajectoryVelocityValue());
1883 for (
int i = 0; i<m_layout->
count(); i++)
1892 for (
int i = 0; i<m_layout->
count(); i++)
1901 for (
int i = 0; i<m_layout->
count(); i++)
1910 for (
int i = 0; i<m_layout->
count(); i++)
1919 for (
int i = 0; i<m_layout->
count(); i++)
1928 m_part_speedVisible = view;
1929 for (
int i = 0; i<m_layout->
count(); i++)
1932 joint->setSpeedVisible(view);
1938 m_part_motorPositionVisible = view;
1939 for (
int i = 0; i<m_layout->
count(); i++)
1942 joint->setMotorPositionVisible(view);
1948 m_part_dutyVisible = view;
1949 for (
int i = 0; i<m_layout->
count(); i++)
1952 joint->setDutyVisible(view);
1958 m_part_currentVisible = view;
1959 for (
int i = 0; i<m_layout->
count(); i++)
1962 joint->setCurrentsVisible(view);
1968 for (
int i = 0; i<m_layout->
count(); i++)
1977 for (
int i = 0; i < m_layout->
count(); i++)
1980 joint->viewPositionTargetValue(
ena);
1986 for (
int i = 0; i<m_layout->
count(); i++)
1991 joint->enablePositionSliderDoubleAuto();
1995 joint->enablePositionSliderDoubleValue(step);
1999 joint->enablePositionSliderDoubleValue(1.0);
2003 joint->disablePositionSliderDouble();
2010 for (
int i = 0; i<m_layout->
count(); i++)
2015 joint->enableVelocitySliderDoubleAuto();
2016 joint->enableTrajectoryVelocitySliderDoubleAuto();
2020 joint->enableVelocitySliderDoubleValue(step);
2021 joint->enableTrajectoryVelocitySliderDoubleValue(step);
2025 joint->enableVelocitySliderDoubleValue(1.0);
2026 joint->enableTrajectoryVelocitySliderDoubleValue(1.0);
2030 joint->disableVelocitySliderDouble();
2031 joint->disableTrajectoryVelocitySliderDouble();
2038 for (
int i = 0; i<m_layout->
count(); i++)
2043 joint->enableCurrentSliderDoubleAuto();
2047 joint->enableCurrentSliderDoubleValue(step);
2051 joint->enableCurrentSliderDoubleValue(1.0);
2055 joint->disableCurrentSliderDouble();
2062 for (
int i = 0; i<m_layout->
count(); i++)
2067 joint->enableTorqueSliderDoubleAuto();
2071 joint->enableTorqueSliderDoubleValue(step);
2075 joint->enableTorqueSliderDoubleValue(1.0);
2079 joint->disableTorqueSliderDouble();
2098 m_modesList.resize(m_layout->
count());
2099 for (
int k = 0;
k < m_layout->
count();
k++){
2100 switch (m_controlModes[
k])
2162 LOG_ERROR(
"Lost connection with the robot. You should save and restart.\n" );
2165 for (
int i = 0; i<m_layout->
count(); i++){
2177 if (!b) {
yWarning(
"Unable to update encoders");
return false; }
2182 if (!b) {
yWarning(
"Unable to update torques"); }
2184 if (this->m_part_currentVisible)
2187 if (!b) {
yWarning(
"Unable to update currents"); }
2189 if (this->m_part_speedVisible)
2192 if (!b) {
yWarning(
"Unable to update speeds"); }
2194 if (this->m_part_motorPositionVisible)
2197 if (!b) {
yWarning(
"Unable to update motorPositions"); }
2199 if (this->m_part_dutyVisible)
2202 if (!b) {
yWarning(
"Unable to update dutyCycles"); }
2217 yError() <<
"Missing Implementation of getTargetPosition()";
2221 yError() <<
"Missing Implementation of getRefVelocity()";
2225 yError() <<
"Missing Implementation of getRefSpeed()";
2229 yError() <<
"Missing Implementation of getRefTorque()";
2233 yError() <<
"Missing Implementation of checkMotionDone()";
2240 if (
true) {
joint->setPosition(m_positions[
jk]); }
2242 if (
true) {
joint->setTorque(m_torques[
jk]); }
2244 if (
true) {
joint->setSpeed(m_speeds[
jk]); }
2246 if (
true) {
joint->setCurrent(m_currents[
jk]); }
2248 if (
true) {
joint->setMotorPosition(m_motorPositions[
jk]); }
2250 if (
true) {
joint->setDutyCycles(m_dutyCycles[
jk]); }
2278 LOG_ERROR(
"iint->getInteractionlMode failed\n" );
2289 std::string message;
2297 LOG_ERROR(
"Unsuccessful call to getLastJointFault()\n");
2307 switch (m_controlModes[
k])
2330 double ref_current = 0;
2332 joint->setRefCurrent(ref_current);
2363 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
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 initStiffness(double curStiffVal, double minStiff, double maxStiff, double curDampVal, double minDamp, double maxDamp, double curForceVal, double minForce, double maxForce)
void initTorque(Pid myPid, MotorTorqueParameters TorqueParam)
void initCurrent(Pid myPid)
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 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