ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to remove the existing point cloud from viewer created using ros3djs

asked 2018-09-26 00:42:47 -0600

sharath gravatar image

I have multiple sub-clouds created after processing the parent cloud. The sub-clouds are being sent over the topics to be displayed on the 3D viewer in a browser using ros3djs, roslibjs. Since, the number of sub-clouds keeps varying i'll have to remove few clouds after unsubscription of topics.There is no function/option to remove an existing cloud from the viewer after unsubscription. Does anyone know how to do it?

I've tried the option of clearing all the objects in the viewer using "viewer.scene.children = [];" but it also removes other things like the co-ordinate frame, markers which i would like to retain.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-02-11 03:08:17 -0600

sharath gravatar image

updated 2019-02-11 03:13:17 -0600

Clearing an existing point cloud from the viewer can be done by first removing the children of points scene associated with the point cloud and then removing points scene from the 3D viewer.

var viewer = new ROS3D.Viewer({ 
  divID : 'webViewer',
  width : 800,
  height : 600,
  antialias : true,
});
tfClient = new ROSLIB.TFClient({
  ros : ros,
  angularThres : 0.01,
  transThres : 0.01,
  rate : 10.0,
  fixedFrame : '/camera_link'
});
var cloudClient = new ROS3D.PointCloud2({
  ros: ros,
  tfClient: tfClient,
  rootObject: viewer.scene,
  topic: '/point_cloud_topic',
});
function removeCloud(){
  for(var j=cloudClient.points.sn.children.length; j>0; j--){
    cloudClient.points.sn.remove(cloudClient.points.sn.children[j-1]);
  viewer.scene.remove(cloudClient.points.sn);
  }
}
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2018-09-26 00:42:47 -0600

Seen: 613 times

Last updated: Feb 11 '19