Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering engine must be added to scene graph before building diagram #22616

Open
marip8 opened this issue Feb 12, 2025 · 0 comments
Open

Rendering engine must be added to scene graph before building diagram #22616

marip8 opened this issue Feb 12, 2025 · 0 comments

Comments

@marip8
Copy link

marip8 commented Feb 12, 2025

What happened?

It appears that rendering engines must be added to the scene graph before the diagram which contains the scene graph is built. If not, some system (I think it's the RgbdSensor) raise the following exception: RuntimeError: No renderer exists with name: 'camera'.

This is not especially problematic for me, but it does not appear to be documented anywhere that this is the case. I'm not sure if this is a bug or the intended functionality, but it would be helpful for this to be more clearly documented.

Here is some pseudo-code for re-creating this issue.

from pydrake.all import RobotDiagramBuilder, MakeRenderEngineGl, RenderEngineGlParams, DiagramBuilder

rdb = RobotDiagramBuilder(time_step=0)
rdb.AddModelsFromURL(...)

# Add a renderer to the scene graph
# Results in correct behavior because this is called before `rdb.Build()`
rdb.scene_graph().AddRenderer('camera', MakeRenderEngineGl(RenderEngineGlParams())

robot = rdb.Build()

# Create a higher level diagram with other systems
builder = DiagramBuilder()
builder.AddNamedSystem('robot', robot)

# Add a renderer to the scene graph here instead
# Technically succeeds, but ultimately results in **incorrect** behavior because this is called after `rdb.Build()` where scene graph is built into robot diagram
# robot.scene_graph().AddRenderer('camera', MakeRenderEngineGl(RenderEngineGlParams())

# The following assert also succeeds, even though the end result at `ForcedPublish` is an exception that says no renderer by the same name can be found
# assert robot.scene_graph().HasRenderer('camera')

# Add a camera
...

# Add a system that connects to the camera 
...

# Connect subsystems together
...

# Build the diagram
diagram = builder.Build()

# Publish to trigger image generation
context = diagram.CreateDefaultContext()
diagram.ForcedPublish(context)

Version

v1.36.0

What operating system are you using?

Ubuntu 22.04

What installation option are you using?

pip install drake

Relevant log output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant