grippers_mujoco

MuJoCo Grippers Module.

This module provides gripper implementations for the MuJoCo simmujoco simulator.

class robotblockset.mujoco.grippers_mujoco.gripper_mujoco(name: str, actuator_name: str, width_max: float, scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, ctrl_sign: float = 1.0, **kwargs: Any)[source]

Bases: gripper

MuJoCo-backed gripper interface using the mjInterface API.

Initialize a MuJoCo gripper interface.

Parameters:
  • name (str) – Gripper instance name.

  • actuator_name (str) – MuJoCo actuator name used to command the gripper.

  • width_max (float) – Maximum allowed opening width.

  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • port (int, optional) – Port number for the MuJoCo simulator connection.

  • ctrl_sign (float, optional) – Sign applied to actuator control commands.

  • **kwargs (Any) – Additional keyword arguments passed to gripper.__init__.

Raises:

Exception – If the configured actuator name does not resolve in the MJCF model.

Returns:

This constructor initializes the MuJoCo gripper object in place.

Return type:

None

__init__(name: str, actuator_name: str, width_max: float, scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, ctrl_sign: float = 1.0, **kwargs: Any) None[source]

Initialize a MuJoCo gripper interface.

Parameters:
  • name (str) – Gripper instance name.

  • actuator_name (str) – MuJoCo actuator name used to command the gripper.

  • width_max (float) – Maximum allowed opening width.

  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • port (int, optional) – Port number for the MuJoCo simulator connection.

  • ctrl_sign (float, optional) – Sign applied to actuator control commands.

  • **kwargs (Any) – Additional keyword arguments passed to gripper.__init__.

Raises:

Exception – If the configured actuator name does not resolve in the MJCF model.

Returns:

This constructor initializes the MuJoCo gripper object in place.

Return type:

None

Init() None[source]

Initialize MuJoCo actuator handles.

Returns:

This method caches the actuator handles.

Return type:

None

GetState() str[source]

Return the gripper state as a human-readable string.

Returns:

“Opened”, “Closed”, “Undefined”, or “Unknown”.

Return type:

str

Move(width: float, speed: float = 0.1, timeout: float = 1, check: bool = True, eps: float = 0.001) bool[source]

Move the gripper to a target width.

Parameters:
  • width (float) – Target gripper opening width.

  • speed (float, optional) – Motion speed (unused in MuJoCo backend).

  • timeout (float, optional) – Maximum time to wait for completion.

  • check (bool, optional) – If True, wait until the target is reached.

  • eps (float, optional) – Tolerance for reaching the target width.

Returns:

True if the target width is reached, False on timeout.

Return type:

bool

GetWidth() float[source]

Return the current gripper width.

Returns:

Current gripper opening width.

Return type:

float

AttachTo(robot: robot) None[source]

Attach the gripper to a robot and reuse its scene.

Parameters:

robot ('robot') – Robot instance providing the MuJoCo scene.

Returns:

This method stores the robot reference and reuses its scene.

Return type:

None

SendCmd(u: float) None[source]

Send a control command to the gripper actuator.

Parameters:

u (float) – Target control value for the gripper actuator.

Returns:

This method updates the actuator control signal in the MuJoCo scene.

Return type:

None

class robotblockset.mujoco.grippers_mujoco.panda_gripper(scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, actuator_name: str = 'panda_gripper', **kwargs: Any)[source]

Bases: gripper_mujoco

MuJoCo gripper wrapper for the Franka Panda hand.

Initialize a MuJoCo Panda gripper interface.

Parameters:
  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • actuator_name (str, optional) – Name of the MuJoCo actuator for the gripper, default is “panda_gripper”.

  • **kwargs (Any) – Additional keyword arguments passed to gripper_mujoco.__init__.

Returns:

This constructor initializes the Panda MuJoCo gripper in place.

Return type:

None

__init__(scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, actuator_name: str = 'panda_gripper', **kwargs: Any) None[source]

Initialize a MuJoCo Panda gripper interface.

Parameters:
  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • actuator_name (str, optional) – Name of the MuJoCo actuator for the gripper, default is “panda_gripper”.

  • **kwargs (Any) – Additional keyword arguments passed to gripper_mujoco.__init__.

Returns:

This constructor initializes the Panda MuJoCo gripper in place.

Return type:

None

class robotblockset.mujoco.grippers_mujoco.robotiq_gripper(scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, actuator_name: str = 'robotiq_gripper', **kwargs: Any)[source]

Bases: gripper_mujoco

MuJoCo gripper wrapper for the Robotiq 2f85 gripper.

Initialize a MuJoCo Robotiq gripper interface.

Parameters:
  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • actuator_name (str, optional) – Name of the MuJoCo actuator for the gripper, default is “robotiq_gripper”.

  • **kwargs (Any) – Additional keyword arguments passed to gripper_mujoco.__init__.

Returns:

This constructor initializes the Panda MuJoCo gripper in place.

Return type:

None

__init__(scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, actuator_name: str = 'robotiq_gripper', **kwargs: Any) None[source]

Initialize a MuJoCo Robotiq gripper interface.

Parameters:
  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • actuator_name (str, optional) – Name of the MuJoCo actuator for the gripper, default is “robotiq_gripper”.

  • **kwargs (Any) – Additional keyword arguments passed to gripper_mujoco.__init__.

Returns:

This constructor initializes the Panda MuJoCo gripper in place.

Return type:

None

class robotblockset.mujoco.grippers_mujoco.z1_gripper(scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, actuator_name: str = 'z1_gripper', **kwargs: Any)[source]

Bases: gripper_mujoco

MuJoCo gripper wrapper for the Unitree Z1 gripper.

Initialize a MuJoCo Unitree Z1 gripper interface.

Parameters:
  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • actuator_name (str, optional) – Name of the MuJoCo actuator for the gripper, default is “z1_gripper”.

  • **kwargs (Any) – Additional keyword arguments passed to gripper_mujoco.__init__.

Note

The joint position and control command are reversed.

Returns:

This constructor initializes the Z1 MuJoCo gripper in place.

Return type:

None

__init__(scene: mjInterface | None = None, host: str = 'localhost', port: int = 50000, actuator_name: str = 'z1_gripper', **kwargs: Any) None[source]

Initialize a MuJoCo Unitree Z1 gripper interface.

Parameters:
  • scene (mjInterface, optional) – Existing MuJoCo interface instance. If None, a new connection is created.

  • host (str, optional) – Hostname of the MuJoCo simulator.

  • actuator_name (str, optional) – Name of the MuJoCo actuator for the gripper, default is “z1_gripper”.

  • **kwargs (Any) – Additional keyword arguments passed to gripper_mujoco.__init__.

Note

The joint position and control command are reversed.

Returns:

This constructor initializes the Z1 MuJoCo gripper in place.

Return type:

None

Classes

gripper_mujoco(name, actuator_name, width_max)

MuJoCo-backed gripper interface using the mjInterface API.

panda_gripper([scene, host, port, actuator_name])

MuJoCo gripper wrapper for the Franka Panda hand.

robotiq_gripper([scene, host, port, ...])

MuJoCo gripper wrapper for the Robotiq 2f85 gripper.

z1_gripper([scene, host, port, actuator_name])

MuJoCo gripper wrapper for the Unitree Z1 gripper.