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

Direct collocation not correctly converting scene graph configuration values #22312

Open
marip8 opened this issue Dec 14, 2024 · 2 comments
Open
Assignees
Labels
component: multibody plant MultibodyPlant and supporting code type: bug

Comments

@marip8
Copy link

marip8 commented Dec 14, 2024

What happened?

After updating from Drake 1.35.0 to 1.36.0, I encounter a run-time error when using the DirectCollocation optimization that says:

RuntimeError: Exception while evaluating SNOPT costs and constraints: 'GetPropertyOrDefault(): The property ('material', 'hunt_crossley_dissipation') exists, but is of a different type. Requested 'drake::AutoDiffXd', but found 'double''

and

RuntimeError: Exception while evaluating SNOPT costs and constraints: 'GetPropertyOrDefault(): The property ('material', 'point_contact_stiffness') exists, but is of a different type. Requested 'drake::AutoDiffXd', but found 'double''

It appears that this might be caused to the changes in default values in the scene graph configuration added by this PR. If I reset the values to hunt_crossley_dissipation=None and point_contact_stiffness=None (their values in Drake 1.35.0), then my DirectCollocation optimization runs correctly again.

Is the issue that the DirectCollocation class is not properly casting these scene graph configuration values from double to AutoDiffXd, or is there just a fundamental conceptual problem using these two values in the optimization?

Version

1.36.0

What operating system are you using?

Ubuntu 22.04

What installation option are you using?

pip install drake

Relevant log output

No response

@jwnimmer-tri
Copy link
Collaborator

I think the problem is MultibodyPlant accessing the values using the wrong type annotation. The properties should be accessed using double (not T) or could be omitted and double would be correctly inferred:

return std::pair(prop->template GetPropertyOrDefault<T>(
geometry::internal::kMaterialGroup,
geometry::internal::kPointStiffness,
penalty_method_contact_parameters_.geometry_stiffness),
prop->template GetPropertyOrDefault<T>(
geometry::internal::kMaterialGroup,
geometry::internal::kHcDissipation,
penalty_method_contact_parameters_.dissipation));

I think you found the best workaround for now, by setting hunt_crossley_dissipation=None and point_contact_stiffness=None in the config.

@jwnimmer-tri
Copy link
Collaborator

Hmm, I just found #13630 which led me to the docs at https://drake.mit.edu/doxygen_cxx/classdrake_1_1multibody_1_1_multibody_plant.html#accessing_contact_properties, which specifies that the properties are of type T not double. So maybe the code which sets defaults in SceneGraph is actually what's wrong.

@rpoyner-tri rpoyner-tri added the component: multibody plant MultibodyPlant and supporting code label Dec 17, 2024
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