RobotWebTools / ros3djs

3D Visualization Library for use with the ROS JavaScript Libraries
https://robotwebtools.github.io/ros3djs
Other
366 stars 215 forks source link

Trying to understand why SceneNode objects are created/visibility is reset for every message #264

Open J-Rojas opened 5 years ago

J-Rojas commented 5 years ago

Hi, I'm attempting to visualize markers with smooth motion animations. I noticed that for every ROS message, a new SceneNode object is created for all Object3d objects. Visibility is also reset to false for every message received. This causes the objects to become invisible between publishing of TF messages and leads to flickering in motions animations that is not smooth.

Why doesn't the implementation reuse the SceneNodes and just update the original objects in the scene directly? Any rationale for this?

mvollrath commented 5 years ago

I'm not familiar with the ros3d logic for markers, but do recall that markers in ros3d were not working the same as rviz. I see a MarkerArrayClient change in #262 which might be relevant.

J-Rojas commented 5 years ago

I don't think those checkins address the issue. The markers shouldn't become invisible between TF updates. For example the web republisher also throttles tf updates and will only send updates to the browser when a tf changes vs tf typically being published constantly on a local system. That's probably the difference between ros3d and rviz. I would classify this invisibility problem as a bug, if you agree.

lisaeb commented 3 years ago

Anything new here? I'm having the same issue when creating one object (tried with MarkerClient and MarkerArrayClient). However as soon as I have more than one object my objects stay visible. I also traced this back to the visibility initially set to false in SceneNode. If there is more than one object the visibility is set to true afterwards by SceneNodes' TF handler tfUpdate. This function is passed to the subscribe function of the TFClient object in roslibjs. As it can be seen there it is only called if this.frameInfos[frameID].transform exists. Apparently the transform is calculated after subscribing to the TFClient so the very first message received would not be shown but the second one would. Before the new SceneNode e.g. for a MarkerClient is created the old node unsubscribes the TFClient. If there was only one object in ´this.frameInfos[map]´ which is removed due to unsubscribing the whole this.frameInfos[frameID] object is deleted as it empty then. Therefore also the calculated transform, which means the tfUpdate function from above is never called if only one object should be shown. With more than one object this function is never emptied which means calculated transforms are not deleted, tfUpdate called and the visibility is set to true. I found two ways to work around this problem: Either setting the visibility in the SceneNode to true or preventing empty `this.frameInfos[frameID] objects from being deleted.