23 #include <VirtualRobot/XML/RobotIO.h>
24 #include "../KinematicSolver.h"
25 #include <QFileDialog>
31 ARMARX_INFO <<
"RobotTrajectoryDesigner: SettingController on init";
41 ARMARX_INFO <<
"RobotTrajectoryDesigner: SettingController on connect";
44 QObject::connect(guiSettingTab->getSettingTab()->robotSelectionButton,
45 SIGNAL(clicked()),
this, SLOT(openRobotSelectionDialog()));
48 QObject::connect(guiSettingTab->getSettingTab()->shortcutButton,
49 SIGNAL(clicked()),
this, SLOT(openShortcutDialog()));
52 QObject::connect(guiSettingTab->getSettingTab()->tcpComboBox,
53 SIGNAL(activated(
int)),
57 QObject::connect(guiSettingTab->getSettingTab()->newIKSolutionButton,
58 SIGNAL(clicked()),
this, SLOT(newIKSolution()));
61 QObject::connect(guiSettingTab->getSettingTab()->collisionModelComboBox,
62 SIGNAL(activated(
int)),
this, SLOT(selectActiveCM(
int)));
65 QObject::connect(guiSettingTab->getSettingTab()->collisionModelList,
66 SIGNAL(itemChanged(QListWidgetItem*)),
67 this, SLOT(setCollisionModelList(QListWidgetItem*)));
70 QObject::connect(guiSettingTab->getSettingTab()->convertToMMMButton,
71 SIGNAL(clicked()),
this, SLOT(convertToMMMSlot()));
74 QObject::connect(guiSettingTab->getSettingTab()->importButton,
75 SIGNAL(clicked()),
this, SLOT(openImportDialog()));
80 ARMARX_INFO <<
"RobotTrajectoryDesigner: SettingController on disconnect";
85 ARMARX_INFO <<
"RobotTrajectoryDesigner: SettingController on exit";
89 guiSettingTab(settingTab)
97 return this->guiSettingTab;
102 if (guiSettingTab != NULL)
104 this->guiSettingTab = guiSettingTab;
108 void SettingController::openRobotSelectionDialog()
113 void SettingController::openShortcutDialog()
127 emit
changedTCP(this->guiSettingTab->getSettingTab()->
128 tcpComboBox->currentText());
132 enableWidgets(
false);
138 QComboBox* combobox = guiSettingTab->getSettingTab()->tcpComboBox;
139 int index = combobox->findText(tcp);
144 combobox->setCurrentIndex(
index);
148 void SettingController::selectActiveCM(
int index)
150 QListWidget* cmList = this->guiSettingTab->getSettingTab()->collisionModelList;
154 for (
int i = 0; i < cmList->count(); i++)
156 QListWidgetItem* item = cmList->item(i);
157 if (i == (
index - 1))
159 item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
163 item->setFlags(item->flags() | Qt::ItemIsEnabled);
166 cmList->setEnabled(
true);
170 cmList->setEnabled(
false);
175 void SettingController::setCollisionModelList(QListWidgetItem* item)
179 QComboBox* tcp = guiSettingTab->getSettingTab()->tcpComboBox;
180 QComboBox* cm = guiSettingTab->getSettingTab()->collisionModelComboBox;
183 if ((tcp->currentIndex() > 0)
184 && (cm->currentIndex() > 0))
186 QListWidget* models = guiSettingTab->getSettingTab()->collisionModelList;
187 QStringList bodyCollisionModels;
190 for (
int i = 0; i < models->count(); i++)
192 if (models->item(i)->checkState() == Qt::Checked)
194 bodyCollisionModels.push_back(models->item(i)->text());
202 void SettingController::exportTrajectorySlot()
207 void SettingController::convertToMMMSlot()
212 void SettingController::openImportDialog()
217 void SettingController::setLanguage(
int index)
231 this->guiSettingTab->getSettingTab()->newIKSolutionButton->setEnabled(enable);
236 this->guiSettingTab->getSettingTab()->convertToMMMButton->setEnabled(enable);
242 this->guiSettingTab->getSettingTab()->collisionModelComboBox->setEnabled(enable);
243 this->guiSettingTab->getSettingTab()->collisionModelList->setEnabled(enable);
244 this->guiSettingTab->getSettingTab()->tcpComboBox->setEnabled(enable);
245 this->guiSettingTab->getSettingTab()->importButton->setEnabled(enable);
248 void SettingController::newIKSolution()
252 VirtualRobot::RobotNodeSetPtr activeKinematicChain = robot->getRobotNodeSet(guiSettingTab->getSettingTab()->tcpComboBox->currentText().toStdString());
253 std::vector<double> newJA = kc->solveIK(activeKinematicChain, PoseBasePtr(
new Pose(activeKinematicChain->getTCP()->getGlobalPose())), VirtualRobot::IKSolver::CartesianSelection::All, 50);
254 if (newJA.size() != 0)
256 activeKinematicChain->setJointValues(std::vector<float>(newJA.begin(), newJA.end()));
262 throw (
"not yet implemented");
267 guiSettingTab->getSettingTab()->robotSelectionButton->setEnabled(enable);
272 guiSettingTab->getSettingTab()->tcpComboBox->clear();
273 guiSettingTab->getSettingTab()->collisionModelComboBox->clear();
274 guiSettingTab->getSettingTab()->collisionModelList->clear();
275 this->environment = environment;
278 initTCPComboBox(robot);
279 initCMComboBox(robot);
287 void SettingController::enableWidgets(
bool enable)
289 this->guiSettingTab->getSettingTab()->collisionModelComboBox->setEnabled(enable);
290 this->guiSettingTab->getSettingTab()->collisionModelList->setEnabled(enable);
297 QComboBox* tcpComboBox = this->guiSettingTab->getSettingTab()->tcpComboBox;
300 tcpComboBox->setFocusPolicy(Qt::StrongFocus);
301 tcpComboBox->installEventFilter(
new WheelEventFilter(
this));
305 tcpComboBox->clear();
308 tcpComboBox->insertItem(0, QString::fromStdString(
"- select -"));
310 auto robotNodeSets = robot->getRobotNodeSets();
313 for (VirtualRobot::RobotNodeSetPtr
s : robotNodeSets)
315 if ((
s->isKinematicChain()) && (
s->getTCP() != NULL))
317 ARMARX_DEBUG <<
"Add item " <<
s->getName() <<
" to tcp combo box";
318 tcpComboBox->addItem(QString::fromStdString(
s->getName()));
321 tcpComboBox->setEnabled(
true);
322 tcpComboBox->setCurrentIndex(0);
327 tcpComboBox->setEnabled(
false);
333 QComboBox* cmComboBox = this->guiSettingTab->getSettingTab()->
334 collisionModelComboBox;
337 cmComboBox->setFocusPolicy(Qt::StrongFocus);
338 cmComboBox->installEventFilter(
new WheelEventFilter(
this));
345 cmComboBox->insertItem(0, QString::fromStdString(
"- select -"));
347 auto robotNodeSets = robot->getRobotNodeSets();
350 for (VirtualRobot::RobotNodeSetPtr
s : robotNodeSets)
352 if (
s->isKinematicChain())
354 ARMARX_DEBUG <<
"Add item " <<
s->getName() <<
" to collision model combo box";
355 cmComboBox->addItem(QString::fromStdString(
s->getName()));
358 cmComboBox->setCurrentIndex(0);
363 cmComboBox->setEnabled(
false);
369 QListWidget* cmList = this->guiSettingTab->getSettingTab()->collisionModelList;
374 auto robotNodeSets = robot->getRobotNodeSets();
376 for (VirtualRobot::RobotNodeSetPtr
s : robotNodeSets)
378 if (
s->isKinematicChain())
380 QListWidgetItem* item =
new QListWidgetItem(QString::fromStdString(
s->getName()));
381 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
382 item->setCheckState(Qt::Unchecked);
383 ARMARX_DEBUG <<
"Add item " <<
s->getName() <<
" to collision model list";
384 cmList->addItem(item);
391 cmList->setEnabled(
false);