33 #include <Inventor/Qt/SoQt.h>
38 #define MAIN_LOOP_SLEEP_MS 33
41 #define MAX_RENDER_TIME_WARNING_MS 33
59 VirtualRobot::init(
"SimulatorViewerApp");
65 if (getProperty<bool>(
"UseDebugDrawer").getValue())
67 std::stringstream ddName;
68 ddName <<
getName() <<
"_EntityDrawer";
69 debugDrawer = Component::create<memoryx::EntityDrawerComponent>(properties, ddName.str());
74 std::stringstream svName;
75 svName <<
getName() <<
"_PhysicsWorldVisualization";
76 simVisu = Component::create<ArmarXPhysicsWorldVisualization>(properties, svName.str());
83 std::stringstream swName;
84 swName <<
getName() <<
"_SimulationWindow";
85 mainWindow = Component::create<ArmarXSimulatorWindow>(properties, swName.str());
100 mainWindow.get(), SIGNAL(closeRequest()),
this, SLOT(closeRequest_sent()));
106 std::cout <<
"Started ArmarXSimulatorViewerApp" << std::endl;
120 memoryx::EntityDrawerInterfacePrx prxDD = armarXManager->getIceManager()->getTopic<memoryx::EntityDrawerInterfacePrx>(
"DebugDrawerUpdates");
121 memoryx::PriorKnowledgeInterfacePrx priorKnowledgePrx = armarXManager->getIceManager()->getProxy<memoryx::PriorKnowledgeInterfacePrx>(
"PriorKnowledge");
123 std::string objClassName =
"vitaliscereal";
124 memoryx::PersistentObjectClassSegmentBasePrx classesSegmentPrx = priorKnowledgePrx->getObjectClassesSegment();
125 memoryx::EntityBasePtr classesEntity = classesSegmentPrx->getEntityByName(objClassName);
133 prxDD->setObjectVisu(
"debug",
"vitalis", objectClass, gp);
138 IceUtil::Time::secondsDouble(1.0 / getProperty<float>(
"UpdateRate").getValue()));
146 color = (color + 1) % 1000;
151 col.a =
float(color) / 1000.0f;
153 prxDD->updateObjectColor(
"debug",
"vitalis", col);
186 auto startTime1 = IceUtil::Time::now();
189 if (duration1.toMilliSecondsDouble() > 5)
192 <<
" mainWindow->getScopedLock() took long:"
193 << duration1.toMilliSecondsDouble();
195 simVisu->synchronizeVisualizationData();
199 auto startTime1 = IceUtil::Time::now();
203 if (duration1.toMilliSecondsDouble() > 20)
206 <<
" qApplication->processEvents took long:"
207 << duration1.toMilliSecondsDouble();
211 mainWindow->setDrawTimeMeasured((
float)duration.toMilliSecondsDouble());
213 <<
"*** END paint, drawTimeMS:" << duration.toMilliSecondsDouble();
217 IceUtil::Time lastWarnDuration = IceUtil::Time::now() - lastWarnTimeRender;
219 if (lastWarnDuration.toSecondsDouble() > 4.0)
221 lastWarnTimeRender = IceUtil::Time::now();
222 ARMARX_DEBUG <<
"*** Rendering slow !! Render time in ms:"
223 << duration.toMilliSecondsDouble();
238 armarXManager->shutdown();
240 armarXManager->waitForShutdown();
258 SimulatorViewerApp::closeRequest_sent()