I'd like to have two plants in the same builder and scene graph. (I don't want them on the same plant because I'd like to separate their dynamics, but I'd like them to affect each other, hence keeping them on the same builder and scene graph.)
My implementation is the following:
from pydrake.multibody.plant import AddMultibodyPlantSceneGraph
from pydrake.systems.framework import DiagramBuilder
builder = DiagramBuilder()
plant1, scene_graph = AddMultibodyPlantSceneGraph(builder, 0.0)
plant2 = AddMultibodyPlantSceneGraph(builder, 0.0, scene_graph)
When I run this, I get the error:
Traceback (most recent call last):
File "/filepath/2plants1scene.py", line 6, in <module>
plant2 = AddMultibodyPlantSceneGraph(builder, 0.0, scene_graph)
RuntimeError: C++ object must be owned by pybind11 when attempting to release to C++
Is this a bindings issue? The documentation for AddMultibodyPlantSceneGraph
makes it seem as though it can add plants to already existing scenes.
The error messages look similar to this issue from 2018: https://github.com/RobotLocomotion/drake/issues/8160
Thanks in advance for any ideas.