Skip to content

Commit

Permalink
Enable robot update on/off to osgPointCloud example
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Apr 28, 2019
1 parent 95f0667 commit ad965e4
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/osgExamples/osgPointCloud/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit ad965e4

Please sign in to comment.