ManipulationAttributesEditTab.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::MemoryX::PriorMemoryEditorPlugin
17* @author Kai Welke (welke at kit dot edu)
18* @date 2013
19* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20* GNU General Public License
21*/
22
24
25#include <QMessageBox>
26
29
30#include "GraspEditorDialog.h"
31#include <MemoryX/gui-plugins/PriorMemoryEditor/ui_ManipulationAttributesEditTab.h>
34
35
36using namespace memoryx;
37using namespace memoryx::EntityWrappers;
38
41 QWidget* parent) :
44 robotStateComponent(robotStateComponent)
45{
46 ui->setupUi(this);
47
48 // connect radiobuttons
49 connect(ui->rbManipulationFile, SIGNAL(toggled(bool)), this, SLOT(update()));
50 connect(ui->rbIVFiles, SIGNAL(toggled(bool)), this, SLOT(update()));
51 update();
52
53 // init manipulation file dialog
54 manipulationFileDialog = new QFileDialog(parent);
55 manipulationFileDialog->setModal(true);
56 manipulationFileDialog->setFileMode(QFileDialog::ExistingFiles);
57 manipulationFileDialog->setNameFilter(tr("Manipulation Object XML (*.xml *.moxml)"));
58 connect(ui->btnSelectManipulationFile, SIGNAL(clicked()), manipulationFileDialog, SLOT(show()));
59 connect(manipulationFileDialog, SIGNAL(accepted()), this, SLOT(manipulationFileSelected()));
60 connect(ui->btnEditGrasps, SIGNAL(clicked()), this, SLOT(editGrasps()));
61
62 // init visualization file dialog
63 visuFileDialog = new QFileDialog(parent);
64 visuFileDialog->setModal(true);
65 visuFileDialog->setFileMode(QFileDialog::ExistingFiles);
66 visuFileDialog->setNameFilter(tr("Inventor & VRML models (*.iv *.wrl)"));
67 connect(ui->btnSelectVisuFile, SIGNAL(clicked()), visuFileDialog, SLOT(show()));
68 connect(visuFileDialog, SIGNAL(accepted()), this, SLOT(visuFileSelected()));
69
70 // init collision file dialog
71 collisionFileDialog = new QFileDialog(parent);
72 collisionFileDialog->setModal(true);
73 collisionFileDialog->setFileMode(QFileDialog::ExistingFiles);
74 collisionFileDialog->setNameFilter(tr("Inventor & VRML models (*.iv *.wrl)"));
75 connect(ui->btnSelectCollisionFile, SIGNAL(clicked()), collisionFileDialog, SLOT(show()));
76 connect(collisionFileDialog, SIGNAL(accepted()), this, SLOT(collisionFileSelected()));
77}
78
83
84void
86{
87 ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
88
89 SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
90
91 // fill dialog (with simox wrapper attributes)
92 ui->rbManipulationFile->setChecked(true);
93 ui->editManipulationFile->setText(
94 QString::fromStdString(simoxWrapper->getManipulationObjectFileName()));
95
96 Eigen::Vector3f putdownOrientation = simoxWrapper->getPutdownOrientationRPY();
97 ui->editPutdownOrientationR->setText(QString::number(putdownOrientation(0)));
98 ui->editPutdownOrientationP->setText(QString::number(putdownOrientation(1)));
99 ui->editPutdownOrientationY->setText(QString::number(putdownOrientation(2)));
100}
101
102void
103ManipulationAttributesEditTab::updateEntity(const EntityPtr& entity, std::string filesDBName)
104{
105 ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
106
107 SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
108
109 // update simox wrapper specific attributes
110 if (ui->rbManipulationFile->isChecked())
111 {
112 simoxWrapper->setAndStoreManipulationFile(ui->editManipulationFile->text().toStdString(),
113 filesDBName);
114 }
115 else
116 {
117 simoxWrapper->setAndStoreModelIVFiles(ui->editVisuFile->text().toStdString(),
118 ui->editCollisionFile->text().toStdString(),
119 filesDBName);
120 }
121
122 Eigen::Vector3f putdownOrientation;
123 putdownOrientation(0) = std::stof(ui->editPutdownOrientationR->text().toStdString());
124 putdownOrientation(1) = std::stof(ui->editPutdownOrientationP->text().toStdString());
125 putdownOrientation(2) = std::stof(ui->editPutdownOrientationY->text().toStdString());
126 simoxWrapper->setPutdownOrientationRPY(putdownOrientation);
127}
128
129void
131{
132 ui->editManipulationFile->setText(manipulationFileDialog->selectedFiles()[0]);
133}
134
135void
137{
138 ui->editVisuFile->setText(visuFileDialog->selectedFiles()[0]);
139}
140
141void
143{
144 ui->editCollisionFile->setText(collisionFileDialog->selectedFiles()[0]);
145}
146
147void
149{
150 if (ui->editManipulationFile->text().isEmpty())
151 {
152 QMessageBox msgBox;
153 msgBox.setText("Please select a manipulation file first.");
154 msgBox.setIcon(QMessageBox::Information);
155 msgBox.setStandardButtons(QMessageBox::Ok);
156 msgBox.setDefaultButton(QMessageBox::Ok);
157 msgBox.exec();
158 }
159 else
160 {
161 std::string robotFile("/usr/local/data/robots/ArmarIII/ArmarIII.xml");
162 std::string localRobot = "RobotAPI/robots/Armar3/ArmarIII.xml";
163 armarx::CMakePackageFinder finder("RobotAPI");
164 if (armarx::ArmarXDataPath::getAbsolutePath(localRobot, localRobot, {finder.getDataDir()}))
165 {
166 robotFile = localRobot;
167 }
168
169 if (robotStateComponent)
170 {
171 for (auto package : robotStateComponent->getArmarXPackages())
172 {
173 auto path = robotStateComponent->getRobotFilename();
174 armarx::CMakePackageFinder finder(package);
175 if (finder.packageFound())
176 {
178 path, path, {finder.getDataDir()}, false))
179 {
180 robotFile = path;
181 }
182 }
183 }
184 }
185
186
187 std::string objectFile(ui->editManipulationFile->text().toStdString());
188 GraspEditorDialog* dialog = new GraspEditorDialog(objectFile, robotFile, this);
189 dialog->exec();
190 }
191}
192
193void
195{
196 // update controls of object visulization and collision model
197 const bool moFile = ui->rbManipulationFile->isChecked();
198 ui->editManipulationFile->setEnabled(moFile);
199 ui->lblManipulationFile->setEnabled(moFile);
200 ui->btnSelectManipulationFile->setEnabled(moFile);
201 ui->btnEditGrasps->setEnabled(moFile);
202
203 ui->editVisuFile->setEnabled(!moFile);
204 ui->lblVisuFile->setEnabled(!moFile);
205 ui->btnSelectVisuFile->setEnabled(!moFile);
206
207 ui->editCollisionFile->setEnabled(!moFile);
208 ui->lblCollisionFile->setEnabled(!moFile);
209 ui->btnSelectCollisionFile->setEnabled(!moFile);
210}
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
bool packageFound() const
Returns whether or not this package was found with cmake.
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
ManipulationAttributesEditTab(armarx::RobotStateComponentInterfacePrx robotStateComponent, QWidget *parent=0)
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
void updateGui(const EntityPtr &entity) override
Pure virtual method.
ArmarX Headers.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
IceInternal::Handle< SimoxObjectWrapper > SimoxObjectWrapperPtr
VirtualRobot headers.
IceInternal::Handle< ObjectClass > ObjectClassPtr
Definition ObjectClass.h:35
IceInternal::Handle< Entity > EntityPtr
Typedef of EntityPtr as IceInternal::Handle<Entity> for convenience.
Definition Entity.h:45