Skip to content

Commit

Permalink
Kinematic moved to base
Browse files Browse the repository at this point in the history
  • Loading branch information
stepjam committed Apr 7, 2024
1 parent 94c1e0d commit 736ca4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
7 changes: 0 additions & 7 deletions mojo/elements/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ def joints(self) -> list[joint.Joint]:
joints = self.mjcf.find_all("joint") or []
return [joint.Joint(self._mojo, mjcf) for mjcf in joints]

def set_kinematic(self, value: bool):
if value and not self.is_kinematic():
self.mjcf.add("freejoint")
self._mojo.mark_dirty()
if not value and self.is_kinematic() and self.mjcf.freejoint is not None:
self.mjcf.freejoint.remove()

def set_euler(self, euler: np.ndarray):
self.set_quaternion(
quaternion.as_float_array(
Expand Down
12 changes: 12 additions & 0 deletions mojo/elements/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def get_quaternion(self) -> np.ndarray:
mujoco.mju_mat2Quat(quat, self._mojo.physics.bind(self.mjcf).xmat)
return quat

def set_kinematic(self, value: bool):
if value and not self.is_kinematic():
self.mjcf.add("freejoint")
self._mojo.mark_dirty()
if (
not value
and self.is_kinematic()
and hasattr(self.mjcf, "freejoint")
and self.mjcf.freejoint is not None
):
self.mjcf.freejoint.remove()

def is_kinematic(self) -> bool:
return _is_kinematic(self.mjcf)

Expand Down
7 changes: 0 additions & 7 deletions mojo/elements/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ def is_collidable(self) -> bool:
and self._mojo.physics.bind(self.mjcf).conaffinity == 1
)

def set_kinematic(self, value: bool):
if value and not self.is_kinematic():
self.mjcf.parent.add("freejoint")
self._mojo.mark_dirty()
if not value and self.is_kinematic() and self.mjcf.parent.freejoint is not None:
self.mjcf.parent.freejoint.remove()

def has_collided(self, other: Geom = None):
if other is not None and not other.is_kinematic() and not self.is_kinematic():
warnings.warn("You are checking collisions of two non-kinematic bodies.")
Expand Down

0 comments on commit 736ca4e

Please sign in to comment.