SimulatorControlGuiPlugin.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package MemoryX::SimulatorControlGui
17 * @author Nikolaus Vahrenkamp (vahrenkamp at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
24 
25 
28 
29 
30 // Qt headers
31 #include <Qt>
32 #include <QtGlobal>
33 #include <QSpinBox>
34 #include <QSlider>
35 #include <QPushButton>
36 #include <QStringList>
37 #include <QTableView>
38 #include <QCheckBox>
39 #include <QBrush>
40 #include <QMessageBox>
41 
42 // Coin3D headers
43 #include <Inventor/SoDB.h>
44 #include <Inventor/Qt/SoQt.h>
45 #include <Inventor/nodes/SoUnits.h>
46 
47 // System
48 #include <stdio.h>
49 #include <string>
50 #include <string.h>
51 #include <stdlib.h>
52 #include <iostream>
53 #include <math.h>
54 
55 // Simox-VirtualRobot
56 #include <SimoxUtility/math/convert/pos_rpy_to_mat4f.h>
57 #include <VirtualRobot/XML/RobotIO.h>
58 #include <VirtualRobot/XML/ObjectIO.h>
59 #include <VirtualRobot/ManipulationObject.h>
60 #include <VirtualRobot/Grasping/GraspSet.h>
61 #include <VirtualRobot/Grasping/Grasp.h>
62 #include <VirtualRobot/Visualization/CoinVisualization/CoinVisualizationFactory.h>
63 
64 using namespace armarx;
65 using namespace VirtualRobot;
66 
67 #define DEFAULT_SETTINGS_SIMULATOR_PROXY_NAME "Simulator"
68 #define DEFAULT_SETTINGS_SIMULATORVIEWER_PROXY_NAME "SimulatorViewer_SimulationWindow"
69 #define DEFAULT_SETTINGS_TIMER_MS_UPDATE_SIM_INFO 500.0f
70 
71 static const int POLL_DELAY_MS = 1000;
72 
74 {
75  addWidget<SimulatorControlController>();
76 }
77 
79 {
80  // init gui
81  ui.setupUi(getWidget());
82 
83  ui.layerTable->setColumnWidth(0, 200);
84  ui.layerTable->setColumnWidth(1, 40);
85  ui.layerTable->setColumnWidth(2, 40);
86  ui.layerTable->setColumnWidth(3, 80);
87  ui.layerTable->setColumnWidth(4, 80);
88  ui.layerTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
89  ui.layerTable->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
90  ui.layerTable->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
91  ui.layerTable->horizontalHeader()->setResizeMode(3, QHeaderView::Fixed);
92  ui.layerTable->horizontalHeader()->setResizeMode(4, QHeaderView::Fixed);
93  for (int i = ui.layerTable->rowCount(); i; --i)
94  {
95  ui.layerTable->removeRow(0);
96  }
97 
98  ARMARX_INFO << "Finished setup of SimulatorControlGuiPlugin" << flush;
99 }
100 
102 {
103  verbose = true;
104 
105  ARMARX_INFO << "Init SimulatorControlController " << flush;
106 
107  settings_simulatorPrxName = DEFAULT_SETTINGS_SIMULATOR_PROXY_NAME;
108  settings_simulatorViewerPrxName = DEFAULT_SETTINGS_SIMULATORVIEWER_PROXY_NAME;
109 
110  usingProxy(settings_simulatorPrxName);
111  connectSlots();
112 }
113 
115 {
116  // subscribe topic in order to receive the simulator reports
117  ARMARX_INFO << "Using simulator proxy: " << settings_simulatorPrxName << flush;
118  simulatorPrx = getProxy<SimulatorInterfacePrx>(settings_simulatorPrxName);
119 
120  timerId = startTimer(DEFAULT_SETTINGS_TIMER_MS_UPDATE_SIM_INFO);
121  //start timer
122  layerPollTimer.start(POLL_DELAY_MS);
123  enableMainWidgetAsync(true);
124 
125 }
126 
128 {
129  killTimer(timerId);
130  layerPollTimer.stop();
131  enableMainWidgetAsync(false);
132 }
133 
135 {
136 
137 }
138 
140 {
141  /*robotFile = settings->value("RobotFile", QString::fromStdString(robotFile_default)).toString().toStdString();
142  objectFile = settings->value("ObjectFile", QString::fromStdString(objectFile_default)).toString().toStdString();
143  show3DViewer = settings->value("ViewerEnabled", "false") == "true";*/
144 }
145 
147 {
148  /*settings->setValue("RobotFile", QString::fromStdString(robotFile));
149  settings->setValue("ObjectFile", QString::fromStdString(objectFile));
150  settings->setValue("ViewerEnabled", QString(show3DViewer?"true":"false"));*/
151 }
152 
153 QPointer<QWidget> SimulatorControlController::getCustomTitlebarWidget(QWidget* parent)
154 {
155  if (customToolbar)
156  {
157  customToolbar->setParent(parent);
158  }
159  else
160  {
161  customToolbar = new QToolBar(parent);
162  customToolbar->addAction("Play / Stop", this, SLOT(playStopSim()));
163  customToolbar->addSeparator();
164  customToolbar->addAction("Reinit", this, SLOT(reInit()));
165  }
166  return customToolbar.data();
167 }
168 
170 {
171  connect(ui.cbWindow, SIGNAL(toggled(bool)), this, SLOT(showSimWindow(bool)), Qt::QueuedConnection);
172  connect(ui.cbShowCoordSystem, SIGNAL(toggled(bool)), this, SLOT(showCoordSystem(bool)), Qt::QueuedConnection);
173  connect(ui.cbContacts, SIGNAL(toggled(bool)), this, SLOT(showContacts(bool)), Qt::QueuedConnection);
174  connect(ui.rbFull, SIGNAL(toggled(bool)), this, SLOT(selectVisuType()), Qt::QueuedConnection);
175  connect(ui.rbCol, SIGNAL(toggled(bool)), this, SLOT(selectVisuType()), Qt::QueuedConnection);
176  connect(ui.pushButtonPlayStop, SIGNAL(clicked()), this, SLOT(playStopSim()), Qt::QueuedConnection);
177  connect(ui.pushButtonStep, SIGNAL(clicked()), this, SLOT(stepSim()), Qt::QueuedConnection);
178  connect(ui.pushButtonReInit, SIGNAL(clicked()), this, SLOT(reInit()), Qt::QueuedConnection);
179 
180  connect(ui.spinBoxAntiAliasing, SIGNAL(valueChanged(int)), this, SLOT(antiAliasing(int)), Qt::QueuedConnection);
181 
182  //connect signal mapper
183  QObject::connect(&layerSignalMapperVisible, SIGNAL(mapped(QString)), this, SLOT(layerToggleVisibility(QString)));
184  QObject::connect(&layerSignalMapperClear, SIGNAL(mapped(QString)), this, SLOT(layerClear(QString)));
185  QObject::connect(&layerSignalMapperRemove, SIGNAL(mapped(QString)), this, SLOT(layerRemove(QString)));
186  //connect poll timer
187  QObject::connect(&layerPollTimer, SIGNAL(timeout()), this, SLOT(layerPoll()));
188 
189  connect(ui.pushButtonAddRobot, SIGNAL(clicked()), this, SLOT(on_pushButtonAddRobot_clicked()));
190  connect(ui.pushButtonManipRobotUpdate, SIGNAL(clicked()), this, SLOT(on_pushButtonManipRobotUpdate_clicked()));
191  connect(ui.pushButtonManipRobSetPose, SIGNAL(clicked()), this, SLOT(on_pushButtonManipRobSetPose_clicked()));
192 
193  ui.tableObjects->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
194  ui.layerTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
195 
196 }
197 
199 {
200  QString textSimTime("SimulationTime:");
201  QString textComTime("CommunicationTime:");
202  QString textRobots("Robots:");
203  QString textJoints("Actuated Joints:");
204  QString textObjects("Objects:");
205  QString textContacts("Contacts:");
206  QString textDraw("DrawTime:");
207  QString textSync("SyncTime:");
208  QString curTime;
209  QString textCam("Camera ");
210 
211  try
212  {
213  if (simulatorPrx)
214  {
215  SimulatorInformation i = simulatorPrx->getSimulatorInformation();
216 
217  textSimTime += QString::number((double)i.simTimeStepMeasuredMS, 'f', 2);
218  textSimTime += QString(" ms (x ");
219  textSimTime += QString::number((double)i.simTimeFactor, 'f', 2);
220  textSimTime += QString(")");
221 
222  textComTime += QString::number((double)i.comTimeMS, 'f', 2);
223  textComTime += QString(" ms");
224 
225  textSync += QString::number((double)i.syncEngineTimeMS, 'f', 2);
226  textSync += QString(" ms");
227 
228  textRobots += QString::number(i.nrRobots);
229  textJoints += QString::number(i.nrActuatedJoints);
230  textObjects += QString::number(i.nrObjects);
231  textContacts += QString::number(i.nrContacts);
232  curTime = QString::number(i.currentSimulatorTimeSec, 'f', 3);
233 
234  // update object info
235 
236  ui.tableObjects->setRowCount(i.objects.size());
237 
238  for (std::size_t ob = 0; ob < i.objects.size(); ++ob)
239  {
240  const auto& o = i.objects.at(ob);
241  QString name = QString::fromStdString(o.name);
242  //ARMARX_INFO << "objects:" << VAROUT(o.objectPoses);
243  PoseBasePtr pose = o.objectPoses.begin()->second;
244  Eigen::Matrix4f gp = PosePtr::dynamicCast(pose)->toEigen();
245  float x = gp(0, 3);
246  float y = gp(1, 3);
247  float z = gp(2, 3);
248  QString pos = QString::number(x, 'f', 2) + "," + QString::number(y, 'f', 2) + "," + QString::number(z, 'f', 2);
249  Eigen::Vector3f rpy;
250  VirtualRobot::MathTools::eigen4f2rpy(gp, rpy);
251  QString ori = QString::number(rpy(0), 'f', 2) + "," + QString::number(rpy(1), 'f', 2) + "," + QString::number(rpy(2), 'f', 2);
252 
253  QString status;
254 
255  if (o.staticObject)
256  {
257  status = "static";
258  }
259  else
260  {
261  status = "dynamic";
262  }
263 
264  //add name and number of elements
265  ui.tableObjects->setItem(ob, 0, new QTableWidgetItem {name});
266  ui.tableObjects->setItem(ob, 1, new QTableWidgetItem {pos});
267  ui.tableObjects->setItem(ob, 2, new QTableWidgetItem {ori});
268  ui.tableObjects->setItem(ob, 3, new QTableWidgetItem {status});
269  }
270  }
271 
272  if (!simulatorViewerPrx)
273  {
274  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
275  }
276 
277  if (simulatorViewerPrx)
278  {
279  SimulatorViewerInformation i = simulatorViewerPrx->getSimulatorInformation();
280  textDraw += QString::number((double)i.drawTimeMS + (double)i.comTimeMS, 'f', 2);
281  textDraw += QString(" ms");
282 
283  //textDraw += " / ";
284  //textDraw += QString::number((double)i.comTimeMS, 'f', 2);
285 
286  PoseBasePtr p = simulatorViewerPrx->getCameraPose();
287  PosePtr p2 = PosePtr::dynamicCast(p);
288  Eigen::Matrix4f p3 = p2->toEigen();
289  Eigen::Vector3f rpy;
290  MathTools::eigen4f2rpy(p3, rpy);
291  textCam += "pos:";
292  textCam += QString::number(p2->position->x * 1000.0f, 'f', 2);
293  textCam += ",";
294  textCam += QString::number(p2->position->y * 1000.0f, 'f', 2);
295  textCam += ",";
296  textCam += QString::number(p2->position->z * 1000.0f, 'f', 2);
297  textCam += ", rpy:";
298  textCam += QString::number(rpy(0), 'f', 2);
299  textCam += ",";
300  textCam += QString::number(rpy(1), 'f', 2);
301  textCam += ",";
302  textCam += QString::number(rpy(2), 'f', 2);
303  }
304  }
305  catch (...)
306  {
307  // silently ignore lost connections
308  }
309 
310  ui.lSimTime->setText(textSimTime);
311  ui.lComTime->setText(textComTime);
312  ui.lRobots->setText(textRobots);
313  ui.lJoints->setText(textJoints);
314  ui.lObjects->setText(textObjects);
315  ui.lContacts->setText(textContacts);
316  ui.lDrawTime->setText(textDraw);
317  ui.lSyncTime->setText(textSync);
318  ui.lcdNumberSimTime->setText(curTime);
319 
320  ui.labelCamPose->setText(textCam);
321 }
322 
324 {
325  try
326  {
327  if (!simulatorViewerPrx)
328  {
329  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
330  }
331 
332  if (simulatorViewerPrx)
333  {
334  simulatorViewerPrx->enableSimulatorWindow(enable);
335  }
336  }
337  catch (...)
338  {
340  }
341 }
342 
344 {
345  try
346  {
347  if (!simulatorViewerPrx)
348  {
349  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
350  }
351 
352  if (simulatorViewerPrx)
353  {
354  simulatorViewerPrx->showBaseCoordSystem(enable, 5.0f);
355  }
356  }
357  catch (...)
358  {
360  }
361 }
362 
364 {
365  try
366  {
367  simulatorPrx->showContacts(enable, "contacts");
368  /*if (!simulatorViewerPrx)
369  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
370  if (simulatorViewerPrx)
371  simulatorViewerPrx->showContacts(enable);*/
372  }
373  catch (...)
374  {
376  }
377 }
378 
380 {
381  try
382  {
383  bool fullModel = ui.rbFull->isChecked();
384 
385  if (!simulatorViewerPrx)
386  {
387  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
388  }
389 
390  if (simulatorViewerPrx)
391  {
392  simulatorViewerPrx->selectVisuType(fullModel);
393  }
394  }
395  catch (...)
396  {
398  }
399 }
400 
402 {
403  try
404  {
405  bool running = simulatorPrx->isRunning();
406 
407  if (running)
408  {
409  simulatorPrx->pause();
410  ui.pushButtonStep->setEnabled(true);
411  }
412  else
413  {
414  simulatorPrx->start();
415  ui.pushButtonStep->setEnabled(false);
416  }
417  }
418  catch (...)
419  {
421  }
422 }
423 
425 {
426  try
427  {
428  bool running = simulatorPrx->isRunning();
429 
430  if (!running)
431  {
432  simulatorPrx->step();
433  }
434  }
435  catch (...)
436  {
438  }
439 }
440 
442 {
443  if (!simulatorPrx)
444  {
445  return;
446  }
447 
448  try
449  {
450  simulatorPrx->reInitialize();
451  }
452  catch (...)
453  {
455  }
456 }
457 
459 {
460  try
461  {
462  if (!simulatorViewerPrx)
463  {
464  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
465  }
466 
467  if (simulatorViewerPrx)
468  {
469  simulatorViewerPrx->setAntiAliasing(steps);
470  }
471  }
472  catch (...)
473  {
475  }
476 }
477 
479 {
480  try
481  {
482  if (!simulatorViewerPrx)
483  {
484  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
485  }
486 
487  if (simulatorViewerPrx)
488  {
489  std::string name = layerName.toStdString();
490  ARMARX_VERBOSE << "Removing layer " << name << "...";
491  simulatorViewerPrx->removeLayer(name);
492  ARMARX_VERBOSE << "done!";
493  }
494  }
495  catch (...)
496  {
498  }
499 }
500 
502 {
503  try
504  {
505  if (!simulatorViewerPrx)
506  {
507  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
508  }
509 
510  if (simulatorViewerPrx)
511  {
512  std::string name = layerName.toStdString();
513  ARMARX_VERBOSE << "Clearing layer " << name << "...";
514  simulatorViewerPrx->clearLayer(name);
515  ARMARX_VERBOSE << "done!";
516  }
517  }
518  catch (...)
519  {
521  }
522 }
523 
525 {
526  try
527  {
528  if (!simulatorViewerPrx)
529  {
530  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
531  }
532 
533  if (simulatorViewerPrx)
534  {
535  auto name = layerName.toStdString();
536 
537  if (layerVisibilityCheckBoxes.count(name))
538  {
539  const bool vis = layerVisibilityCheckBoxes.at(name).second->isChecked();
540  ARMARX_VERBOSE << "Toggling visibility from " << !vis << " to " << vis << " for layer " << name << "...";
541  simulatorViewerPrx->enableLayerVisu(name, vis);
542  ARMARX_VERBOSE << "done!";
543  }
544  }
545  }
546  catch (...)
547  {
549  }
550 }
551 
553 {
554  try
555  {
556  if (!simulatorViewerPrx)
557  {
558  simulatorViewerPrx = getProxy<SimulatorViewerControlInterfacePrx>(settings_simulatorViewerPrxName);
559  }
560 
561  if (simulatorViewerPrx)
562  {
563  auto layerInfo = simulatorViewerPrx->layerInformation();
564  ui.layerTable->setRowCount(layerInfo.size());
565  LayerVisibilityCheckBoxesType newLayerVisibilityCheckBoxes;
566 
567  const bool hideEmptyLayers = ui.checkBoxHideEmptyLayers->isChecked();
568  //fill & map signals
569  for (const auto& layer : layerInfo)
570  {
571  auto& layerEntry = newLayerVisibilityCheckBoxes[layer.layerName];
572  int tableIdx = 0;
573  //create row if missing
574  {
575  if (layerVisibilityCheckBoxes.count(layer.layerName))
576  {
577  //already there
578  layerEntry = layerVisibilityCheckBoxes.at(layer.layerName);
579  layerVisibilityCheckBoxes.erase(layer.layerName);
580  //search for idx
581  bool found = false;
582  for (; tableIdx < ui.layerTable->rowCount(); ++tableIdx)
583  {
584  const QTableWidgetItem* item = ui.layerTable->item(tableIdx, 0);
585  if (item)
586  {
587  found = (item->text() == QString::fromStdString(layer.layerName));
588  }
589  else
590  {
591  ARMARX_WARNING << "layerPoll(search old): item " << tableIdx << " is null";
592  }
593  if (found)
594  {
595  break;
596  }
597  }
598  }
599  else
600  {
601  ui.layerTable->insertRow(0);
602  //missing! -> create it
603  QString name = QString::fromStdString(layer.layerName);
604  //store visibility
605  //set text
606  ui.layerTable->setItem(0, 0, new QTableWidgetItem {name});
607 
608  //add&connect checkbox
609  QCheckBox* box {new QCheckBox};
610  ui.layerTable->setCellWidget(0, 2, box);
611  layerEntry.second = box;
612  // layerEntry.first = ui.layerTable->item(0,0);
613  layerSignalMapperVisible.setMapping(box, name);
614  QObject::connect(box, SIGNAL(stateChanged(int)), &layerSignalMapperVisible, SLOT(map()));
615 
616  //add&connect button clear
617  QPushButton* clear {new QPushButton{"Clear"}};
618  ui.layerTable->setCellWidget(0, 3, clear);
619  layerSignalMapperClear.setMapping(clear, name);
620  QObject::connect(clear, SIGNAL(clicked()), &layerSignalMapperClear, SLOT(map()));
621 
622  //add&connect button remove
623  QPushButton* remove {new QPushButton{"Remove"}};
624  ui.layerTable->setCellWidget(0, 4, remove);
625  layerSignalMapperRemove.setMapping(remove, name);
626  QObject::connect(remove, SIGNAL(clicked()), &layerSignalMapperRemove, SLOT(map()));
627  }
628  }
629  // ARMARX_CHECK_NOT_NULL(layerEntry.first);
630  ARMARX_CHECK_NOT_NULL(layerEntry.second);
631  // const auto tableIdx = ui.layerTable->row(layerEntry.first);
632  QCheckBox* box = layerEntry.second;
633  //update layer
634  ui.layerTable->setItem(tableIdx, 1, new QTableWidgetItem {QString::number(layer.elementCount)});
635  box->blockSignals(true);
636  box->setChecked(layer.visible);
637  box->blockSignals(false);
638 
639  if (!layer.elementCount && hideEmptyLayers)
640  {
641  //hide it
642  ui.layerTable->hideRow(tableIdx);
643  continue;
644  }
645  ui.layerTable->showRow(tableIdx);
646  }
647  //remove old entries
648  for (const auto& pair : layerVisibilityCheckBoxes)
649  {
650  ui.layerTable->removeRow(ui.layerTable->row(pair.second.first));
651  }
652  for (int i = ui.layerTable->rowCount() - 1; i >= 0; --i)
653  {
654  const QTableWidgetItem* item = ui.layerTable->item(i, 0);
655  if (item)
656  {
657  if (layerVisibilityCheckBoxes.count(item->text().toStdString()))
658  {
659  ui.layerTable->removeRow(i);
660  }
661  }
662  else
663  {
664  ARMARX_WARNING << "layerPoll(delete old): item " << i << " is null";
665  }
666  }
667  layerVisibilityCheckBoxes = std::move(newLayerVisibilityCheckBoxes);
668  ui.layerTable->setRowCount(layerVisibilityCheckBoxes.size());
669  }
670  }
671  catch (...)
672  {
673  //handleExceptions();
674  }
675 
676  /*if (!simulatorPrx)
677  {
678  return;
679  }
680 
681  auto layerInfo = simulatorPrx->layerInformation();
682  ui.layerTable->setRowCount(layerInfo.size());
683  layerVisibility.clear();
684  //fill&map signals
685  for(std::size_t i=0;i<layerInfo.size();++i)
686  {
687  const auto& layer=layerInfo.at(i);
688  QString name=QString::fromStdString(layer.layerName);
689  //store visibility
690  layerVisibility[layer.layerName]=layer.visible;
691  //set text
692  ui.layerTable->setItem(i,0,new QTableWidgetItem{name});
693  ui.layerTable->setItem(i,1,new QTableWidgetItem{QString::number(layer.elementCount)});
694  //add&connect checkbox
695  std::unique_ptr<QCheckBox> box{new QCheckBox};
696  box->setChecked(layer.visible);
697  layerSignalMapperVisible.setMapping(box.get(),name);
698  QObject::connect(box.get(), SIGNAL(stateChanged(int)), &layerSignalMapperVisible, SLOT(map()));
699  ui.layerTable->setCellWidget(i,2,box.release());
700  //add&connect button clear
701  std::unique_ptr<QPushButton> clear{new QPushButton{"Clear"}};
702  layerSignalMapperClear.setMapping(clear.get(),name);
703  QObject::connect(clear.get(), SIGNAL(clicked()), &layerSignalMapperClear, SLOT(map()));
704  ui.layerTable->setCellWidget(i,3,clear.release());
705  //add&connect button remove
706  std::unique_ptr<QPushButton> remove{new QPushButton{"Remove"}};
707  layerSignalMapperRemove.setMapping(remove.get(),name);
708  QObject::connect(remove.get(), SIGNAL(clicked()), &layerSignalMapperRemove, SLOT(map()));
709  ui.layerTable->setCellWidget(i,4,remove.release());
710  }*/
711 }
712 
713 void armarx::SimulatorControlController::on_pushButtonAddRobot_clicked()
714 {
715  if (!simulatorPrx)
716  {
717  return;
718  }
719  const auto result = simulatorPrx->addScaledRobot(
720  ui.lineEditAddRobotXML->text().toStdString(),
721  ui.doubleSpinBoxAddRobotScale->value());
722  ui.labelAddRobotResult->setText(QString::fromStdString(result));
723 }
724 
725 void armarx::SimulatorControlController::on_pushButtonManipRobotUpdate_clicked()
726 {
727  if (!simulatorPrx)
728  {
729  return;
730  }
731  ui.comboBoxManipRobotName->clear();
732  for (const auto& n : simulatorPrx->getRobotNames())
733  {
734  ui.comboBoxManipRobotName->addItem(QString::fromStdString(n));
735  }
736 }
737 
738 void armarx::SimulatorControlController::on_pushButtonManipRobSetPose_clicked()
739 {
740  if (!simulatorPrx)
741  {
742  return;
743  }
744  const Eigen::Matrix4f p = simox::math::pos_rpy_to_mat4f(
745  ui.doubleSpinBoxManipRobTX->value(),
746  ui.doubleSpinBoxManipRobTY->value(),
747  ui.doubleSpinBoxManipRobTZ->value(),
748 
749  ui.doubleSpinBoxManipRobRX->value(),
750  ui.doubleSpinBoxManipRobRY->value(),
751  ui.doubleSpinBoxManipRobRZ->value()
752  );
753  simulatorPrx->setRobotPose(ui.comboBoxManipRobotName->currentText().toStdString(), new Pose{p});
754 }
armarx::SimulatorControlController::layerToggleVisibility
void layerToggleVisibility(QString layerName)
Toggles a layer's visibility.
Definition: SimulatorControlGuiPlugin.cpp:524
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::SimulatorControlController::reInit
void reInit()
reInit Re-loads all simulator content.
Definition: SimulatorControlGuiPlugin.cpp:441
armarx::SimulatorControlController::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: SimulatorControlGuiPlugin.cpp:114
armarx::SimulatorControlController::showContacts
void showContacts(bool enable)
Definition: SimulatorControlGuiPlugin.cpp:363
armarx::SimulatorControlController::getCustomTitlebarWidget
QPointer< QWidget > getCustomTitlebarWidget(QWidget *parent) override
getTitleToolbar returns a pointer to the a toolbar widget of this controller.
Definition: SimulatorControlGuiPlugin.cpp:153
VirtualRobot
Definition: FramedPose.h:43
armarx::SimulatorControlGuiPlugin::SimulatorControlGuiPlugin
SimulatorControlGuiPlugin()
Definition: SimulatorControlGuiPlugin.cpp:73
string.h
Pose.h
ARMARX_CHECK_NOT_NULL
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
Definition: ExpressionException.h:206
armarx::SimulatorControlController::layerPoll
void layerPoll()
Requests the current layer information from simulatorPrx and updates the table.
Definition: SimulatorControlGuiPlugin.cpp:552
armarx::SimulatorControlController::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: SimulatorControlGuiPlugin.cpp:134
armarx::SimulatorControlController::stepSim
void stepSim()
Definition: SimulatorControlGuiPlugin.cpp:424
armarx::SimulatorControlController::SimulatorControlController
SimulatorControlController()
Definition: SimulatorControlGuiPlugin.cpp:78
armarx::SimulatorControlController::playStopSim
void playStopSim()
Definition: SimulatorControlGuiPlugin.cpp:401
IceInternal::Handle< Pose >
armarx::SimulatorControlController::antiAliasing
void antiAliasing(int steps)
Definition: SimulatorControlGuiPlugin.cpp:458
armarx::status
status
Definition: FiniteStateMachine.h:259
armarx::SimulatorControlController::saveSettings
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
Definition: SimulatorControlGuiPlugin.cpp:146
armarx::SimulatorControlController::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: SimulatorControlGuiPlugin.cpp:101
armarx::SimulatorControlController::timerEvent
void timerEvent(QTimerEvent *) override
timerEvent
Definition: SimulatorControlGuiPlugin.cpp:198
armarx::flush
const LogSender::manipulator flush
Definition: LogSender.h:251
armarx::SimulatorControlController::showSimWindow
void showSimWindow(bool enable)
Definition: SimulatorControlGuiPlugin.cpp:323
SimulatorControlGuiPlugin.h
DEFAULT_SETTINGS_TIMER_MS_UPDATE_SIM_INFO
#define DEFAULT_SETTINGS_TIMER_MS_UPDATE_SIM_INFO
Definition: SimulatorControlGuiPlugin.cpp:69
armarx::SimulatorControlController::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: SimulatorControlGuiPlugin.cpp:127
armarx::Pose
The Pose class.
Definition: Pose.h:242
armarx::SimulatorControlController::showCoordSystem
void showCoordSystem(bool enable)
Definition: SimulatorControlGuiPlugin.cpp:343
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::SimulatorControlController::selectVisuType
void selectVisuType()
Definition: SimulatorControlGuiPlugin.cpp:379
armarx::SimulatorControlController::layerRemove
void layerRemove(QString layerName)
Removes a layer.
Definition: SimulatorControlGuiPlugin.cpp:478
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::SimulatorControlController::loadSettings
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
Definition: SimulatorControlGuiPlugin.cpp:139
armarx::handleExceptions
void handleExceptions()
Definition: Exception.cpp:141
DEFAULT_SETTINGS_SIMULATORVIEWER_PROXY_NAME
#define DEFAULT_SETTINGS_SIMULATORVIEWER_PROXY_NAME
Definition: SimulatorControlGuiPlugin.cpp:68
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx::SimulatorControlController::connectSlots
void connectSlots()
Definition: SimulatorControlGuiPlugin.cpp:169
ArmarXDataPath.h
armarx::SimulatorControlController::layerClear
void layerClear(QString layerName)
Clears a layer.
Definition: SimulatorControlGuiPlugin.cpp:501
DEFAULT_SETTINGS_SIMULATOR_PROXY_NAME
#define DEFAULT_SETTINGS_SIMULATOR_PROXY_NAME
Definition: SimulatorControlGuiPlugin.cpp:67
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28