ArmarXSimulatorWindow.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#pragma once
25
26// Qt
27#include <QActionGroup>
28#include <QComboBox>
29#include <QDialog>
30#include <QDialogButtonBox>
31#include <QDir>
32#include <QDockWidget>
33#include <QGridLayout>
34#include <QHBoxLayout>
35#include <QList>
36#include <QListWidget>
37#include <QMainWindow>
38#include <QMdiArea>
39#include <QModelIndex>
40#include <QMutex>
41#include <QPainter>
42#include <QPlainTextEdit>
43#include <QPluginLoader>
44#include <QProxyStyle>
45#include <QSignalMapper>
46#include <QSplitter>
47#include <QStackedWidget>
48#include <QStringList>
49#include <QVector3D>
50
51#ifdef foreach
52#undef foreach
53#endif
54
55// Coin3D & SoQt
56#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
57#include <Inventor/nodes/SoNode.h>
58#include <Inventor/nodes/SoSeparator.h>
59
60// ArmarX
64
66
68
69#include <ArmarXSimulation/applications/SimulatorViewer/ui_ArmarXSimulatorWindow.h>
71#include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
72
73#include <SimDynamics/DynamicsEngine/BulletEngine/BulletEngine.h>
74#include <SimDynamics/DynamicsEngine/DynamicsEngine.h>
75#include <SimDynamics/DynamicsEngine/DynamicsObject.h>
76#include <SimDynamics/DynamicsEngine/DynamicsRobot.h>
77#include <SimDynamics/DynamicsWorld.h>
78
79// project
80namespace armarx
81{
82
83 class CoinViewer;
84
85 /*!
86 * \class ArmarXSimulatorWindowPropertyDefinitions
87 * \brief
88 */
90 {
91 public:
94 {
96 "ShowBaseCoordSystem",
97 false,
98 "Enable/disbale a coordinate visualization at the global root.");
99 defineOptionalProperty<int>("AntiAliasingRenderPasses",
100 4,
101 "If >0 anti aliasing is enabled (may slow down the "
102 "visualization). Defines the number of render passes.");
103
105 "Camera.x", 0.f, "x component of initial camera position (mm)");
107 "Camera.y", 0.f, "y component of initial camera position (mm)");
109 "Camera.z", 0.f, "z component of initial camera position (mm)");
111 "Camera.roll", 0.f, "Initial camera pose: roll component of RPY angles (radian)");
113 "Camera.pitch", 0.f, "Initial camera pose: pitch component of RPY angles (radian)");
115 "Camera.yaw", 0.f, "Initial camera pose: yaw component of RPY angles (radian)");
117 "TempDir", "/tmp", "Local temp directory. Used for storing video files.");
119 false,
120 "Enable/disbale video recording (video is stored to tmp "
121 "directory, currently only BMP files are supported.");
123 "Background.r", 1.f, "r component of initial background color [0, 1]");
125 "Background.g", 1.f, "g component of initial background color [0, 1]");
127 "Background.b", 1.f, "b component of initial background color [0, 1]");
128 }
129 };
130
132 public QMainWindow,
133 virtual public SimulatorViewerControlInterface,
134 virtual public Component
135 {
136 Q_OBJECT
137
138 public:
140 ~ArmarXSimulatorWindow() override;
141
142 // inherited from Component
143 std::string
144 getDefaultName() const override
145 {
146 return "ArmarXSimulatorWindow";
147 }
148
149 void onInitComponent() override;
150 void onConnectComponent() override;
151 void onDisconnectComponent() override;
152 void onExitComponent() override;
153
154 /**
155 * @see PropertyUser::createPropertyDefinitions()
156 */
163
166
167 /**
168 * emits the closeRequest signal
169 */
170 void closeEvent(QCloseEvent* event) override;
171
172 // called by world (when its safe to access scene graph)
173 //void updateContacts(std::vector<SimDynamics::DynamicsEngine::DynamicsContactInfo> &c);
174
175 Eigen::Matrix4f getCamPose();
176
178
179 SoNode* getScene();
180
181 /*!
182 * \brief Protect access with this lock
183 * \return The lock that is automatically destructed when leaving the current scope.
184 */
186
188
189
190 /* Inherited from SimulatorViewerControlInterface. */
191 void enableSimulatorWindow(bool show, const Ice::Current& c = Ice::emptyCurrent) override;
192 void showDebugDrawLayer(bool show, const Ice::Current& c = Ice::emptyCurrent) override;
193 void clearDebugDrawLayer(const Ice::Current& c = Ice::emptyCurrent) override;
194
195 void clearLayer(const std::string& layerName,
196 const ::Ice::Current& = Ice::emptyCurrent) override;
197 void removeLayer(const std::string& layerName,
198 const ::Ice::Current& = Ice::emptyCurrent) override;
199 void enableLayerVisu(const std::string& layerName,
200 bool visible,
201 const ::Ice::Current& = Ice::emptyCurrent) override;
202 ::armarx::LayerInformationSequence
203 layerInformation(const ::Ice::Current& = Ice::emptyCurrent) override;
204
205 void setTempPath(const std::string& p, const ::Ice::Current& = Ice::emptyCurrent) override;
206 void saveScreenshots(bool enable, const ::Ice::Current& = Ice::emptyCurrent) override;
207
208
209 //! Switch between full/collision model
210 void selectVisuType(bool fullModel, const Ice::Current& c = Ice::emptyCurrent) override;
211 void showBaseCoordSystem(bool show,
212 float scale = 1.0,
213 const Ice::Current& c = Ice::emptyCurrent) override;
214 //void showContacts(bool show, const Ice::Current& c = Ice::emptyCurrent);
215 SimulatorViewerInformation
216 getSimulatorInformation(const Ice::Current& c = Ice::emptyCurrent) override;
217
218 void setAntiAliasing(int steps, const Ice::Current& c = Ice::emptyCurrent) override;
219
220 PoseBasePtr getCameraPose(const Ice::Current& c = Ice::emptyCurrent) override;
221
222 void setDrawTimeMeasured(float ms);
223
224 void setCamPose(float x, float y, float z, float roll, float pitch, float yaw);
226
227 public slots:
228 void slotEnableDebugDrawLayer(bool show);
230 void slotClearLayer(const QString layerName);
231 void slotRemoveLayer(const QString layerName);
232 void slotEnableLayerVisu(const QString layerName, bool visible);
233 void slotSelectVisuType(bool visible);
234
235 void viewAll();
236
237 // setup anti aliasing passes (0 == disable)
238 void setupAntiAliasing(int numPasses);
239
240 void slotShowBaseCoord(bool show, float scale);
241
242 signals:
243 /**
244 * emitted, when the main window should be closed
245 */
247
248 protected:
249 Ui::MainWindowArmarXSimulator ui;
250
252
255
256 void setupUI();
257
258
259 static void timerCB(void* data, SoSensor* sensor);
260 void saveScreenshot();
261
262 SoSeparator* sceneSep;
263
265
266 armarx::SimulatorViewerInformation info;
267
269
270 bool saveVideo = false;
271 std::string tmpDir;
272
273 private:
274 QString guiWindowBaseName;
275 };
276
278} // namespace armarx
constexpr T c
void onInitComponent() override
Pure virtual hook for the subclass.
void showDebugDrawLayer(bool show, const Ice::Current &c=Ice::emptyCurrent) override
PoseBasePtr getCameraPose(const Ice::Current &c=Ice::emptyCurrent) override
void setAntiAliasing(int steps, const Ice::Current &c=Ice::emptyCurrent) override
void slotShowBaseCoord(bool show, float scale)
void saveScreenshots(bool enable, const ::Ice::Current &=Ice::emptyCurrent) override
void enableLayerVisu(const std::string &layerName, bool visible, const ::Ice::Current &=Ice::emptyCurrent) override
void initialize(ArmarXPhysicsWorldVisualizationPtr physicsVisu, DebugDrawerComponentPtr debugDrawer)
armarx::SimulatorViewerInformation info
void onDisconnectComponent() override
Hook for subclass.
void setMutex(CoinViewer::RecursiveMutexPtr const &m)
::armarx::LayerInformationSequence layerInformation(const ::Ice::Current &=Ice::emptyCurrent) override
DebugDrawerComponentPtr debugDrawer
void closeRequest()
emitted, when the main window should be closed
void closeEvent(QCloseEvent *event) override
emits the closeRequest signal
void slotClearLayer(const QString layerName)
void setCamPose(float x, float y, float z, float roll, float pitch, float yaw)
CoinViewer::RecursiveMutexLockPtr getScopedLock()
Protect access with this lock.
void onConnectComponent() override
Pure virtual hook for the subclass.
PropertyDefinitionsPtr createPropertyDefinitions() override
CoinViewer::RecursiveMutexPtr mutex
void selectVisuType(bool fullModel, const Ice::Current &c=Ice::emptyCurrent) override
Switch between full/collision model.
void clearDebugDrawLayer(const Ice::Current &c=Ice::emptyCurrent) override
void slotRemoveLayer(const QString layerName)
void clearLayer(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
void setTempPath(const std::string &p, const ::Ice::Current &=Ice::emptyCurrent) override
void slotEnableLayerVisu(const QString layerName, bool visible)
void enableSimulatorWindow(bool show, const Ice::Current &c=Ice::emptyCurrent) override
void onExitComponent() override
Hook for subclass.
void removeLayer(const std::string &layerName, const ::Ice::Current &=Ice::emptyCurrent) override
Ui::MainWindowArmarXSimulator ui
void showBaseCoordSystem(bool show, float scale=1.0, const Ice::Current &c=Ice::emptyCurrent) override
SimulatorViewerInformation getSimulatorInformation(const Ice::Current &c=Ice::emptyCurrent) override
ArmarXPhysicsWorldVisualizationPtr physicsVisu
std::string getDefaultName() const override
Retrieve default name of component.
static void timerCB(void *data, SoSensor *sensor)
std::shared_ptr< RecursiveMutexLock > RecursiveMutexLockPtr
Definition CoinViewer.h:53
std::shared_ptr< RecursiveMutex > RecursiveMutexPtr
Definition CoinViewer.h:51
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
Component()
Protected default constructor. Used for virtual inheritance. Use createManagedIceObject() instead.
Definition Component.cpp:66
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:90
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ArmarXSimulatorWindow > ArmarXSimulatorWindowPtr
IceInternal::Handle< DebugDrawerComponent > DebugDrawerComponentPtr
IceInternal::Handle< ArmarXPhysicsWorldVisualization > ArmarXPhysicsWorldVisualizationPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.