Skip to content

hylo.manip.collision

Package: hylo-manip · Core contracts

collision

Collision checking of an arm and its hand: the model's collision geoms (as surface samples) against the table plane and observed points (KD-tree, a margin), and self-collision from MuJoCo contacts.

G module-attribute

G = mujoco.mjtGeom

Obstacles dataclass

Obstacles(table: float | None = None, clearance: float = 0.01, points: ndarray | None = None, margin: float = 0.01, check_self: bool = True, attached: ndarray | None = None, soft_fingers: bool = False)

What an arm must not touch: the table plane (z, with a clearance) and points (KD-tree, a margin).

table class-attribute instance-attribute

table: float | None = None

clearance class-attribute instance-attribute

clearance: float = 0.01

points class-attribute instance-attribute

points: ndarray | None = None

margin class-attribute instance-attribute

margin: float = 0.01

check_self class-attribute instance-attribute

check_self: bool = True

attached class-attribute instance-attribute

attached: ndarray | None = None

soft_fingers class-attribute instance-attribute

soft_fingers: bool = False

relaxed

relaxed(**kw) -> 'Obstacles'

hits

hits(pts: ndarray) -> str | None

Collider

Collider(arm: ArmModel, robot_bodies: set[int], spacing: float = 0.01, seed: int = 0)

Collision geoms of one arm's model: those of the bodies its joints move (with the hand) are checked against obstacles; self-collision uses MuJoCo contacts between robot geoms, minus pairs already touching at home and pairs within the hand.

arm instance-attribute

arm = arm

moving instance-attribute

moving = set().union(*(_subtree(m, b) for b in joint_bodies))

hand_bodies instance-attribute

hand_bodies = _subtree(m, arm.ee)

robot_bodies instance-attribute

robot_bodies = robot_bodies | self.moving

geoms instance-attribute

geoms = np.array(geoms, dtype=int)

samples instance-attribute

samples = np.concatenate(samples) if samples else np.zeros((0, 3))

owner instance-attribute

owner = np.concatenate(owner) if owner else np.zeros(0, int)

hand_sample instance-attribute

hand_sample = np.isin(m.geom_bodyid[self.geoms][self.owner], list(self.hand_bodies))

finger_sample instance-attribute

finger_sample = np.isin(m.geom_bodyid[self.geoms][self.owner], list(finger_bodies))

robot_geoms instance-attribute

robot_geoms = {g for g in range(m.ngeom) if collidable[g] and m.geom_bodyid[g] in self.robot_bodies}

seen_samples instance-attribute

seen_samples = np.concatenate(seen) if seen else np.zeros((0, 3))

seen_geom instance-attribute

seen_geom = np.concatenate(seen_owner) if seen_owner else np.zeros(0, int)

allowed instance-attribute

allowed: set[tuple[int, int]] = set(self._contacts())

points_world

points_world(hand_only: bool = False) -> np.ndarray

Surface samples in the world at the current model state (after arm.forward()).

seen_world

seen_world() -> np.ndarray

Surface samples of every robot geom (visual and collision, moving and fixed) in the world at the current model state (after arm.forward()): what cameras see of the robot.

check

check(q, obstacles: Obstacles, attached: ndarray | None = None) -> str | None

None when q is free, else "self", "table" or "points". attached: points held in the TCP frame (default: the obstacles' attached).

hand_points_in_tcp

hand_points_in_tcp(cmd, spacing: float = 0.005) -> np.ndarray

Hand surface samples (about spacing apart) in the TCP frame with the fingers at command cmd.

geom_surface

geom_surface(m: MjModel, g: int, h: float, rng: Generator) -> np.ndarray

Points on the surface of geom g in its own frame, about h apart.

geom_surface_box

geom_surface_box(center, half, h) -> np.ndarray