Updating model visuals from ROS/Gazebo plugin


#21

I get it “working” by hard-coding the blue value in the setRGB() instructions of the setMaterial function. Now I realise that the diffuse values of your mesh material are not the expected ones and it is only the material of the parent which is updated properly. So there is another problem and I need to investigate further.


#22

Dear Jakob,

Unlike createGeom(), the function updateVisualFromMsg() does not recurse through the mesh children of an Object3D with an existing material.

This can be addressed in the following way (line 6230 of gz3d.js):

if (obj && mat) {
  var allChildren = obj.children; // To traverse all descendants, like in createGeom: var allDescendants = []; getDEscendants(allDescendants);
  this.scene.setMaterial(obj, mat);
  for (var c = 0; c < allChildren.length; ++c)
  {
    if (allChildren[c] instanceof THREE.Mesh)
    {
      this.scene.setMaterial(allChildren[c],
          mat);
    }
  }
}

Here is what I obtain now:

Is it the expected result?

Best regards,
Luc


#23

Hi @lguyot,

Yes, that is exactly what I was looking for!
I will set that up on my machine straight away.

Thanks a lot!


#24

I have now successfully edited my gz3d.js file to allow for controlling pose, scale, color and opacity through a visual message and all of my troubles are sorted - until I update NRP again :wink:

A diff of mine vs. original can be found here: https://bitbucket.org/jakobwelner/nrp_gzweb_custom/commits/ebe9a5c5efa4670a0b38536788b98ed0693283d3
It’s partly a custom solution and ignores a few cases for now, so I wouldn’t do a pull-request. However, I would appreciate if something similar could be added eventually :smile:

Thanks again for all of the help. It was very much appreciated!

Cheers