Skip to content

Commit

Permalink
Provide working configuration with soft-like contact models
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Oct 24, 2024
1 parent 0017d38 commit dffd6e8
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/comodo/jaxsimSimulator/jaxsimSimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def load_model(
case JaxsimContactModelEnum.VISCO_ELASTIC | JaxsimContactModelEnum.SOFT:
contact_params = js.contact.estimate_good_contact_parameters(
model=self._model,
number_of_active_collidable_points_steady_state=16,
max_penetration=0.002,
number_of_active_collidable_points_steady_state=8,
max_penetration=0.002_5,
damping_ratio=1.0,
static_friction_coefficient=1.0,
)
Expand Down Expand Up @@ -363,11 +363,10 @@ def step(self, n_step: int = 1, dry_run=False) -> None:
pass

# Update link contact forces
if (
not dry_run
and self._contact_model_type is not JaxsimContactModelEnum.VISCO_ELASTIC
):
if not dry_run:

with self._data.switch_velocity_representation(VelRepr.Mixed):

self._link_contact_forces = js.model.link_contact_forces(
model=self._model,
data=self._data,
Expand Down Expand Up @@ -405,15 +404,12 @@ def close(self) -> None:

@property
def feet_wrench(self) -> tuple[npt.NDArray, npt.NDArray]:
# TODO: remove this check as soon as Jaxsim adds support for it
if self._contact_model_type is JaxsimContactModelEnum.VISCO_ELASTIC:
raise ValueError(
"Link contact forces are only available for non visco-elastic contact models."
)

if self._link_contact_forces is None:
raise ValueError(
"Link contact forces are only available after calling the step method."
)

wrenches = self.link_contact_forces

left_foot = np.array(wrenches[self._left_foot_link_idx])
Expand Down Expand Up @@ -444,15 +440,12 @@ def simulation_time(self) -> float:

@property
def link_contact_forces(self) -> npt.NDArray:

if self._link_contact_forces is None:
raise ValueError(
"Link contact forces are only available after calling the step method."
)
# TODO: remove this check as soon as Jaxsim adds support for it
if self._contact_model_type is JaxsimContactModelEnum.VISCO_ELASTIC:
raise ValueError(
"Link contact forces are only available for non visco-elastic contact models."
)

return self._link_contact_forces

@property
Expand Down

0 comments on commit dffd6e8

Please sign in to comment.