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

CalcSpatialInertia segfaults if passed a frame that isn't part of the plant #22636

Open
nepfaff opened this issue Feb 15, 2025 · 2 comments
Open
Assignees
Labels
component: multibody plant MultibodyPlant and supporting code type: bug

Comments

@nepfaff
Copy link
Member

nepfaff commented Feb 15, 2025

What happened?

The following segfaults:

from manipulation.station import LoadScenario
from pydrake.all import DiagramBuilder, RobotDiagram, RigidTransform, FixedOffsetFrame


from manipulation.station import LoadScenario, MakeHardwareStation


def main():
    builder = DiagramBuilder()

    scenario_str = """
    directives:
    - add_model:
        name: iiwa
        file: package://drake_models/iiwa_description/sdf/iiwa14_polytope_collision.sdf
    - add_weld:
        parent: world
        child: iiwa::iiwa_link_0
    """
    scenario = LoadScenario(data=scenario_str)
    station: RobotDiagram = builder.AddSystem(MakeHardwareStation(scenario))
    diagram = builder.Build()

    plant = station.plant()
    link7 = plant.GetBodyByName(f"iiwa_link_7")
    test_frame = FixedOffsetFrame(
        name="test_frame",
        P=link7.body_frame(),
        X_PF=RigidTransform(p=[0, 0, 0.1]),
    )
    plant.CalcSpatialInertia(
        context=plant.CreateDefaultContext(),
        frame_F=test_frame,
        body_indexes=[link7.index()],
    )


if __name__ == "__main__":
    main()

The reason seems to be that test_frame isn't part of the plant. No segfault if I add it to plant first.

Version

1.37.0

What operating system are you using?

Ubuntu 22.04

What installation option are you using?

pip install drake

Relevant log output

@ggould-tri ggould-tri added the component: multibody plant MultibodyPlant and supporting code label Feb 18, 2025
@ggould-tri
Copy link
Contributor

Assigning component multibody plant; assigning @amcastro-tri for triage.

@jwnimmer-tri
Copy link
Collaborator

FYI I believe this is one concrete example of the larger issue #17734.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: multibody plant MultibodyPlant and supporting code type: bug
Projects
None yet
Development

No branches or pull requests

4 participants