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