bullet_classes

Classes for pyBullet grasper containing the Client, Object and Robotiq 2F-85 Gripper and Barrett Hand

Author:

Lukas Rustler

class pybullet_grasper.bullet_classes.Barrett(client: Client, position: List[float] | ndarray = [0, 0, 1], orientation: List[float] | ndarray = [0, 0, 0, 1])[source]

Bases: object

Runtime controller for the Barrett Hand gripper loaded in pyBullet.

Class for the Barrett Hand gripper

Parameters:
  • client (Client) – instance of Client, holding info about the scene

  • position (list[float] | np.ndarray, optional, default=[0, 0, 1]) – spawn position of the gripper base in world frame

  • orientation (list[float] | np.ndarray, optional, default=[0, 0, 0, 1]) – spawn orientation quaternion of the gripper base

Returns:

None

Return type:

None

JOINTS = ['bh_j32_joint', 'bh_j12_joint', 'bh_j22_joint', 'bh_j11_joint']
MIMICS = {'bh_j11_joint': [1, 'bh_j21_joint'], 'bh_j12_joint': [0.3442622950819672, 'bh_j13_joint'], 'bh_j22_joint': [0.3442622950819672, 'bh_j23_joint'], 'bh_j32_joint': [0.3442622950819672, 'bh_j33_joint']}
load_gripper() int[source]

Loads the grippers URDF into the scene

Returns:

body id of the loaded gripper

Return type:

int

motion_done(eps: float = 0.01, object_id: int = -1, method: str = 'force', contact_threshold: float = 10) int[source]

Checks whether gripper is in goal position

Parameters:
  • eps (float, optional, default=1e-2) – tolerance around the commanded joint value

  • object_id (int, optional, default=-1) – kept for API compatibility with other detectors

  • method (str, optional, default="force") – kept for API compatibility with other detectors

  • contact_threshold (float, optional, default=10) – torque threshold used to classify object contact

Returns:

1 for normal closure, 2 for collision, 3 for timeout, 0 for no closure

Return type:

int

move(joint: int, target: float, velocity: float = 0.1) int[source]

Move joint to target position

Parameters:
  • joint (int) – id of the joint

  • target (float) – target position

  • velocity (float, optional, default=0.1) – maximum joint speed during the move command

Returns:

0 when target is reached, -1 when timeout is reached

Return type:

int

prepare_gripper() Tuple[List[int], List[int], List[Tuple[Any, ...]], List[str]][source]

Sets constraints for joints to works as mimic joint in URDF

Returns:

created constraints, moveable joint ids, joint info, and joint names

Return type:

tuple[list, list, list, list]

reset_constraints() None[source]

Remove all constraints

Returns:

None

Return type:

None

set_gripper_pose(position: float, pose: int = 0, velocity: float | None = None, wait: bool = False) int[source]

Set goal position of gripper

Parameters:
  • position (float) – position of the gripper

  • pose (int, optional, default=0) – 0 for two-finger mode, 1 to fold one finger out of the way

  • velocity (float | None, optional, default=None) – unused placeholder for API compatibility

  • wait (bool, optional, default=False) – whether to wait for the motion to finish

Returns:

motion result code, or 0 when command is issued without waiting

Return type:

int

stop() None[source]

Holds all actuated finger joints at their current positions.

Returns:

None

Return type:

None

class pybullet_grasper.bullet_classes.Client(config_path: str, object_name: str = '', init_position: List[float] | ndarray = [0, 0, 0])[source]

Bases: BulletClient

Wrapper around pybullet_utils.bullet_client.BulletClient used by the grasper pipeline.

The class initializes the simulation world, loads the active graspable object, and stores convenience indices for pyBullet tuple-based APIs.

Client class which inherits from BulletClient. Runs the physics client with desired mode and prepares dicts for easier access to things

Parameters:
  • config_path (str) – path to the config file

  • object_name (str, optional, default="") – name of the object; can be relative to the calling script; relative to source_code/objects or an absolute path

  • init_position (list[float] | np.ndarray, optional, default=[0, 0, 0]) – initial position of the object

Returns:

None

Return type:

None

contactPoints = {'DISTANCE': 8, 'FLAG': 0, 'FORCE': 9, 'FRICTION1': 10, 'FRICTION2': 12, 'FRICTIONDIR1': 11, 'FRICTIONDIR2': 13, 'IDA': 1, 'IDB': 2, 'INDEXA': 3, 'INDEXB': 4, 'NORMAL': 7, 'POSITIONA': 5, 'POSITIONB': 6}
dynamicsInfo = {'BODYTYPE': 10, 'DAMPING': 8, 'FRICTION': 1, 'INERTIAOR': 4, 'INERTIAPOS': 3, 'INTERTIADIAGONAL': 2, 'MARGIN': 11, 'MASS': 0, 'RESTITUTION': 5, 'ROLLINGFRICTION': 6, 'SPINNINGFRICTION': 7, 'STIFFNESS': 9}
is_alive() bool[source]

Checks whether the engine is still running

Returns:

True when running

Return type:

bool

jointInfo = {'AXIS': 13, 'DAMPING': 6, 'FLAGS': 5, 'FRICTION': 7, 'INDEX': 0, 'LINKNAME': 12, 'LOWERLIMIT': 8, 'MAXFORCE': 10, 'MAXVELOCITY': 11, 'NAME': 1, 'PARENTINDEX': 16, 'PARENTORN': 15, 'PARENTPOS': 14, 'QINDEX': 3, 'TYPE': 2, 'UINDEX': 4, 'UPPERLIMIT': 9}
jointStates = {'FORCES': 2, 'POSITION': 0, 'TORQUE': 3, 'VELOCITY': 1}
linkInfo = {'ANGVEL': 7, 'INERTIAORI': 3, 'INERTIAPOS': 2, 'LINVEL': 6, 'URDFORI': 5, 'URDFPOS': 4, 'WORLDORI': 1, 'WORLDPOS': 0}
load_objects(path: str = '', init_position: List[float] | ndarray = [0, 0, 0]) None[source]

Load graspable objects. With possibility of convex decomposition with V-HACD

Parameters:
  • path (str, optional, default="") – path to the mesh

  • init_position (list[float] | np.ndarray, optional, default=[0, 0, 0]) – initial position of the object

Returns:

None

Return type:

None

lower_the_plane(target: float) int[source]

Moves the support plane joint to the requested position.

Parameters:

target (float) – desired prismatic joint position of the plane

Returns:

0 when target is reached, -1 when timeout is reached

Return type:

int

read_info(obj_id: int) int[source]

Add mesh to the visualizer

Parameters:

obj_id (int) – id of the object; given by pybullet

Returns:

0 for success

Return type:

int

reset() None[source]

Function to reset simulation to default state

Returns:

None

Return type:

None

step_simulation(sleep_duration: float | None = None) None[source]

Updates the simulation

Parameters:

sleep_duration (float, optional, default=None) – duration to sleep before the next simulation step

Returns:

None

Return type:

None

visualShapeData = {'COLOR': 7, 'DIMS': 3, 'FILE': 4, 'GEOMTYPE': 2, 'ID': 0, 'LINK': 1, 'ORI': 6, 'POS': 5, 'TEXTURE': 8}
class pybullet_grasper.bullet_classes.GraspableBody(client: Client, init_position: List[float] | ndarray)[source]

Bases: object

Stores geometry, sampling and runtime metadata for one graspable object.

Initializes an empty graspable object container.

Parameters:
  • client (Client) – active physics client

  • init_position (list[float] | np.ndarray) – initial translation used when loading the object

Returns:

None

Return type:

None

prepare_body(model: str, do_init: bool = True) None[source]

Load graspable objects. With possibility of convex decomposition with V-HACD

Parameters:
  • model (str) – path to the .obj file

  • do_init (bool, optional, default=True) – whether to regenerate VHACD/URDF assets before loading

Returns:

None

Return type:

None

prepare_mesh(model: str) None[source]

Prepares information about the object

Parameters:

model (str) – path to the .obj file

Returns:

None

Return type:

None

class pybullet_grasper.bullet_classes.Robotiq_2f_85(client: Client, position: List[float] | ndarray = [0, 0, 1], orientation: List[float] | ndarray = [0, 0, 0, 1])[source]

Bases: object

Runtime controller for the Robotiq 2F-85 gripper loaded in pyBullet.

Class for the Robotiq 2f-85 gripper

Parameters:
  • client (Client) – instance of Client, holding info about the scene

  • position (list[float] | np.ndarray, optional, default=[0, 0, 1]) – spawn position of the gripper base in world frame

  • orientation (list[float] | np.ndarray, optional, default=[0, 0, 0, 1]) – spawn orientation quaternion of the gripper base

Returns:

None

Return type:

None

JOINTS = ['left_inner_knuckle_joint', 'left_inner_finger_joint', 'right_outer_knuckle_joint', 'right_inner_knuckle_joint', 'right_inner_finger_joint']
SIGNS = [1, -1, 1, 1, -1, 1, -1]
load_gripper() int[source]

Loads the grippers URDF into the scene

Returns:

body id of the loaded gripper

Return type:

int

motion_done(eps: float = 0.01, object_id: int = -1, method: str = 'force', contact_threshold: float = 10) int[source]

Checks whether gripper is in goal position

Parameters:
  • eps (float, optional, default=1e-2) – tolerance around the commanded joint value

  • object_id (int, optional, default=-1) – kept for API compatibility with other detectors

  • method (str, optional, default="force") – kept for API compatibility with other detectors

  • contact_threshold (float, optional, default=10) – torque threshold used to classify object contact

Returns:

1 for normal closure, 2 for collision, 3 for timeout, 0 for no closure

Return type:

int

move(joint: int, target: float, velocity: float = 0.1) int[source]

Move joint to target position

Parameters:
  • joint (int) – id of the joint

  • target (float) – target position

  • velocity (float, optional, default=0.1) – maximum joint speed during the move command

Returns:

0 when target is reached, -1 when timeout is reached

Return type:

int

prepare_gripper() Tuple[List[int], int, Tuple[Any, ...]][source]

Sets constraints for joints to works as mimic joint in URDF

Returns:

created constraints, driver joint id, and driver joint info tuple

Return type:

tuple[list, int, tuple]

reset_constraints() None[source]

Remove all constraints

Returns:

None

Return type:

None

reset_joints() None[source]

Reset gripper joints to default

Returns:

None

Return type:

None

set_gripper_pose(position: float, wait: bool = False) int[source]

Set goal position of gripper

Parameters:
  • position (float) – position of the gripper, 0 - closed, 1-open

  • wait (bool, optional, default=False) – whether to wait for the motion to finish

Returns:

motion result code, or 0 when command is issued without waiting

Return type:

int

stop() None[source]

Holds the current finger joint position using position control.

Returns:

None

Return type:

None