Skip to content

Commit

Permalink
[gym_jiminy/common] More robust projected support polygon computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
duburcqa committed Dec 8, 2024
1 parent 6377e04 commit 145488d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/gym_jiminy/common/gym_jiminy/common/envs/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ def has_terminated(self, info: InfoType) -> Tuple[bool, bool]:
"No simulation running. Please start one before calling this "
"method.")

# Check if the observation is out-of-bounds in debug mode only
# Check if the observation is out-of-bounds
truncated = not self._contains_observation()

return False, truncated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dataclasses import dataclass

import numpy as np
from scipy.spatial import ConvexHull
from scipy.spatial import ConvexHull, QhullError

from jiminy_py.core import ( # pylint: disable=no-name-in-module
multi_array_copyto)
Expand Down Expand Up @@ -124,11 +124,15 @@ def initialize(self) -> None:
# separately rather than all at once.
candidate_xy_refs: List[np.ndarray] = []
for positions in contact_positions:
convhull = ConvexHull(np.stack(positions, axis=0))
candidate_indices = set(
range(len(positions))).intersection(convhull.vertices)
candidate_xy_refs += (
positions[j][:2] for j in candidate_indices)
try:
convhull = ConvexHull(np.stack(positions, axis=0))
candidate_indices = set(
range(len(positions))).intersection(convhull.vertices)
candidate_xy_refs += (
positions[j][:2] for j in candidate_indices)
except QhullError:
# Assuming all the candidate points are part of the convex hull
candidate_xy_refs += (position[:2] for position in positions)
self._candidate_xy_refs = tuple(candidate_xy_refs)

# Allocate memory for stacked position of candidate contact points.
Expand Down

0 comments on commit 145488d

Please sign in to comment.