From ad965e494da6d0985bd63200da01c71f055acb3a Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Sat, 27 Apr 2019 22:43:10 -0700 Subject: [PATCH] Enable robot update on/off to osgPointCloud example --- examples/osgExamples/osgPointCloud/main.cpp | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/osgExamples/osgPointCloud/main.cpp b/examples/osgExamples/osgPointCloud/main.cpp index 7af169f63cead..942ebf56088bc 100644 --- a/examples/osgExamples/osgPointCloud/main.cpp +++ b/examples/osgExamples/osgPointCloud/main.cpp @@ -72,6 +72,9 @@ class PointCloudWorld : public gui::osg::WorldNode if (!mRobot) return; + if (!mUpdate) + return; + // Set robot pose Eigen::VectorXd pos = mRobot->getPositions(); pos += 0.01 * Eigen::VectorXd::Random(pos.size()); @@ -105,11 +108,22 @@ class PointCloudWorld : public gui::osg::WorldNode { return mPointCloudVisualAspect; } + dynamics::VisualAspect* getVoxelGridVisualAspect() { return mVoxelGridVisualAspect; } + void setUpdate(bool update) + { + mUpdate = update; + } + + bool getUpdate() const + { + return mUpdate; + } + protected: octomap::Pointcloud generatePointCloud(std::size_t numPoints) { @@ -173,6 +187,8 @@ class PointCloudWorld : public gui::osg::WorldNode dynamics::VisualAspect* mPointCloudVisualAspect; dynamics::VisualAspect* mVoxelGridVisualAspect; + + bool mUpdate{true}; }; class PointCloudWidget : public dart::gui::osg::ImGuiWidget @@ -247,6 +263,15 @@ class PointCloudWidget : public dart::gui::osg::ImGuiWidget if (ImGui::RadioButton("Pause", &e, 1) && mViewer->isSimulating()) mViewer->simulate(false); } + + int robotUpdate = mNode->getUpdate() ? 0 : 1; + if (ImGui::RadioButton("Run Robot Updating", &robotUpdate, 0) + && mNode->getUpdate()) + mNode->setUpdate(true); + ImGui::SameLine(); + if (ImGui::RadioButton("Stop Robot Updating", &robotUpdate, 1) + && mNode->getUpdate()) + mNode->setUpdate(false); } if (ImGui::CollapsingHeader("View", ImGuiTreeNodeFlags_DefaultOpen))