Drake: Drake camera not showing texture.

Created on 30 Apr 2020  路  5Comments  路  Source: RobotLocomotion/drake

Hi,

I am unable to see texture in the Camera view of drake. However it loads correctly in drake visualizer.

drake_camera

The code that generates the scene is here

Is this a known issue? If not, what I could be doing incorrectly?

Best,

Michael

dynamics

Most helpful comment

I can't 100% explain your problem, but I'm 99% sure the problem comes down to a horrible trap that most people fall into. drake_visualzier and the RenderEngine interface handle material specifications very differently.

  • RenderEngineVtk has two ways to associate a color texture with an obj file:

    • takes the obj name (my_file.obj) and looks for my_file.png. In this case, your obj is named 003_cracker_box_textured_updated.obj and your texture is named 003_cracker_box_textured.png.

    • In the SDF if you assign the tag:

      <drake:diffuse_map>../meshes/003_cracker_box_texture.png</drake:diffuse_map>

      that will explicitly inform the render engine that you want that texture (of arbitrary name) associated with that obj.

    • drake_visualizer actually does a passable job respecting the mtl file and is acquiring the texture association that way.

(This is a known issue and once resources free up RenderEngine will respect the mtl file as well.)

I have a big request. This is a common-enough question that if you could post it in stack overflow with the drake tag, others will be able to benefit from your question and this answer.

P.S. Some notes on your code:

  • You don't have to declare both CameraProperties and DepthCameraProperties. If the two sets of properties have identical values for their common properties, then an instance of the latter is an instance of the former.
  • frame_id = world_id only works by accident. world_id should be a BodyIndex and frame id should be an instance of FrameId. What you really want is frame_id = scene_graph.world_frame_id()

All 5 comments

Sherm, I don't know who currently owns the renderers (@SeanCurtis-TRI ?) so I'm handing this to you to reassign.

I can't 100% explain your problem, but I'm 99% sure the problem comes down to a horrible trap that most people fall into. drake_visualzier and the RenderEngine interface handle material specifications very differently.

  • RenderEngineVtk has two ways to associate a color texture with an obj file:

    • takes the obj name (my_file.obj) and looks for my_file.png. In this case, your obj is named 003_cracker_box_textured_updated.obj and your texture is named 003_cracker_box_textured.png.

    • In the SDF if you assign the tag:

      <drake:diffuse_map>../meshes/003_cracker_box_texture.png</drake:diffuse_map>

      that will explicitly inform the render engine that you want that texture (of arbitrary name) associated with that obj.

    • drake_visualizer actually does a passable job respecting the mtl file and is acquiring the texture association that way.

(This is a known issue and once resources free up RenderEngine will respect the mtl file as well.)

I have a big request. This is a common-enough question that if you could post it in stack overflow with the drake tag, others will be able to benefit from your question and this answer.

P.S. Some notes on your code:

  • You don't have to declare both CameraProperties and DepthCameraProperties. If the two sets of properties have identical values for their common properties, then an instance of the latter is an instance of the former.
  • frame_id = world_id only works by accident. world_id should be a BodyIndex and frame id should be an instance of FrameId. What you really want is frame_id = scene_graph.world_frame_id()

I just want to upvote Sean's suggestion of putting this question to stack overflow. I have fallen into this trap twice :(.

Thanks @SeanCurtis-TRI for the suggestion. Yes this was indeed the thing. I renamed the files and it worked.

drake_camera_new

Also thanks for the helpful comments about the code. It would have been really helpful if it was mentioned in the documentation under the RGBDSensor or CameraProperties class.

To finish resolving this PR, there are two keynotes.

  1. We need to respect the mtl file. There is already an issue for that #11949.
  2. Until that happens, the explanation in this issue needs to be discoverable in the documentation (#13314).

With those two topics covered by other issues, I'm closing this one.

Was this page helpful?
0 / 5 - 0 ratings