RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.25k stars 1.25k forks source link

plant.CalcDiscreteValueUpdates() crashes python (with no helpful error) if a SceneGraph is attached #11450

Closed RussTedrake closed 4 years ago

RussTedrake commented 5 years ago

Another new user pain point -- they call a method on the plant, passing in only the plant's context. But the plant is a subsystem in a diagram, with (most critically) a SceneGraph attached. I will try to reproduce the exact failure, but anecdotally, the user is confused because the python interpreter simply crashes with no helpful error.

e.g.

from pydrake.all import (
    DiagramBuilder, 
    FindResourceOrThrow,
    Parser,
    AddMultibodyPlantSceneGraph,
)

builder = DiagramBuilder()
plant, scene_graph = AddMultibodyPlantSceneGraph(builder, time_step=0.0005)
# Build the plant
Parser(plant).AddModelFromFile(FindResourceOrThrow("drake/examples/acrobot/Acrobot.urdf"))
plant.Finalize()

diagram = builder.Build()
context = plant.CreateDefaultContext()
plant.CalcDiscreteVariableUpdates(
    context = context,
    discrete_state = context.get_mutable_discrete_state())

EDIT(eric): Updated to use Drake-only resources.

EricCousineau-TRI commented 4 years ago

FYI @sherm1 This is still reproducible (e.g. segfault), with Drake-only resources. Used the same setup as mentioned here: https://github.com/RobotLocomotion/drake/issues/11457#issuecomment-622985019

Drake version:

In [1]: !cat /opt/drake/share/doc/drake/VERSION.TXT
Out [1]: 20200430074549 26c38c92d871567f333eb8ece2677bcfc4ab165f

Not assigning component: pydrake until there's a C++ flavor that shows it's a Python problem.

sherm1 commented 4 years ago

This was fixed in #13536.