MotionAttributesEditTab.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 <MemoryX/gui-plugins/PriorMemoryEditor/ui_MotionAttributesEditTab.h>
29
30using namespace memoryx;
31using namespace memoryx::EntityWrappers;
32
35{
36 ui->setupUi(this);
37
38 // init feature file dialog
39 connect(ui->comboBoxMotionModel,
40 SIGNAL(currentIndexChanged(const QString&)),
41 this,
42 SLOT(motionModelChanged(const QString&)));
43 connect(ui->comboBoxSimulationType,
44 SIGNAL(currentIndexChanged(const QString&)),
45 this,
46 SLOT(simulationTypeChanged(const QString&)));
47
50}
51
56
57void
59{
60 ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
61
62 ObjectRecognitionWrapperPtr objectRecognitionWrapper =
63 objectClass->getWrapper<ObjectRecognitionWrapper>();
64 int index = ui->comboBoxMotionModel->findText(
65 QString(objectRecognitionWrapper->getDefaultMotionModel().c_str()));
66 if (index != -1)
67 {
68 ui->comboBoxMotionModel->setCurrentIndex(index);
69 }
70
71 SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
72 VirtualRobot::SceneObject::Physics::SimulationType simType =
73 simoxWrapper->getManipulationObject()->getSimulationType();
74 index = ui->comboBoxSimulationType->findText(simTypeToString(simType));
75 if (index != -1)
76 {
77 ui->comboBoxSimulationType->setCurrentIndex(index);
78 }
79}
80
81void
82MotionAttributesEditTab::updateEntity(const EntityPtr& entity, std::string filesDBName)
83{
84 ObjectClassPtr objectClass = ObjectClassPtr::dynamicCast(entity);
85
86 ObjectRecognitionWrapperPtr objectRecognitionWrapper =
87 objectClass->getWrapper<ObjectRecognitionWrapper>();
88 std::string motionModelName = ui->comboBoxMotionModel->currentText().toStdString();
89 ARMARX_INFO << "Setting motion model: " << motionModelName;
90 objectRecognitionWrapper->setDefaultMotionModel(motionModelName);
91
92 SimoxObjectWrapperPtr simoxWrapper = objectClass->getWrapper<SimoxObjectWrapper>();
93 VirtualRobot::ManipulationObjectPtr mo = simoxWrapper->getManipulationObject();
94 QString simulationTypeName = ui->comboBoxSimulationType->currentText();
95
96 ARMARX_INFO << simoxWrapper->getManipulationObjectFileName();
97 ARMARX_INFO << "Setting simulation type: " << simulationTypeName.toStdString();
98 mo->setSimulationType(stringToSimType(simulationTypeName));
99 simoxWrapper->setAndStoreManipulationObject(mo, filesDBName);
100}
101
102void
104{
105}
106
107void
109{
110}
111
112QString
113MotionAttributesEditTab::simTypeToString(VirtualRobot::SceneObject::Physics::SimulationType simType)
114{
115 switch (simType)
116 {
117 case VirtualRobot::SceneObject::Physics::eStatic:
118 return "Static";
119 case VirtualRobot::SceneObject::Physics::eKinematic:
120 return "Kinematic";
121 case VirtualRobot::SceneObject::Physics::eDynamic:
122 return "Dynamic";
123 default:
124 return "Unknown";
125 }
126}
127
128VirtualRobot::SceneObject::Physics::SimulationType
129MotionAttributesEditTab::stringToSimType(const QString& string)
130{
131 if (string == "Static")
132 {
133 return VirtualRobot::SceneObject::Physics::eStatic;
134 }
135 else if (string == "Kinematic")
136 {
137 return VirtualRobot::SceneObject::Physics::eKinematic;
138 }
139 else if (string == "Dynamic")
140 {
141 return VirtualRobot::SceneObject::Physics::eDynamic;
142 }
143 else
144 {
145 return VirtualRobot::SceneObject::Physics::eUnknown;
146 }
147}
uint8_t index
SimoxObjectWrapper offers a simplified access to the Simox ManipulationObject (i.e visualization,...
void simulationTypeChanged(const QString &method)
void motionModelChanged(const QString &method)
void updateEntity(const EntityPtr &entity, std::string filesDBName) override
Pure virtual method.
void updateGui(const EntityPtr &entity) override
Pure virtual method.
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
ArmarX Headers.
IceInternal::Handle< SimoxObjectWrapper > SimoxObjectWrapperPtr
IceInternal::Handle< ObjectRecognitionWrapper > ObjectRecognitionWrapperPtr
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