Skip to content

Commit

Permalink
[examples/multibody] Hydroelastic-representation option for rolling s…
Browse files Browse the repository at this point in the history
…phere (RobotLocomotion#16258)

- Add option `hydro_rep` for contact-surface representation in hydroelastics.
  • Loading branch information
DamrongGuoy authored Jan 6, 2022
1 parent 6b41c67 commit ab94e3d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/multibody/rolling_sphere/rolling_sphere_run_dynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ DEFINE_double(simulation_time, 2.0,
// Contact model parameters.
DEFINE_string(contact_model, "point",
"Contact model. Options are: 'point', 'hydroelastic', 'hybrid'.");
DEFINE_string(hydro_rep, "tri",
"Contact-surface representation for hydroelastics. "
"Options are: 'tri' for triangles, 'poly' for polygons. "
"Default is 'tri'. It has no effect on point contact.");
DEFINE_double(hydroelastic_modulus, 5.0e4,
"For hydroelastic (and hybrid) contact, "
"hydroelastic modulus, [Pa].");
Expand Down Expand Up @@ -135,6 +139,17 @@ int do_main() {
std::move(illus_prop));
}

if (FLAGS_hydro_rep == "tri") {
plant.set_contact_surface_representation(
geometry::HydroelasticContactRepresentation::kTriangle);
} else if (FLAGS_hydro_rep == "poly") {
plant.set_contact_surface_representation(
geometry::HydroelasticContactRepresentation::kPolygon);
} else {
throw std::runtime_error("Invalid choice of contact-surface representation "
"for hydroelastics '" + FLAGS_hydro_rep + "'.");
}

// Set contact model and parameters.
if (FLAGS_contact_model == "hydroelastic") {
plant.set_contact_model(ContactModel::kHydroelastic);
Expand Down

0 comments on commit ab94e3d

Please sign in to comment.