grasp_generator

Main grasp processing

Author:

Lukas Rustler

class pybullet_grasper.grasp_generator.ClientProcess(client: Client, id: int, gripper_poses: List[Any], score: Any, after_grasp_poses: Any)[source]

Bases: Process

Worker process that evaluates a batch of candidate grasp poses.

Parameters:
  • client (Client) – shared simulation client template

  • id (int) – worker/process identifier

  • gripper_poses (list[Any]) – pose candidates assigned to this worker

  • score (Any) – shared array storing pose quality scores

  • after_grasp_poses (Any) – shared array storing object poses after grasping

Returns:

None

Return type:

None

handle_timeout(signum: int, frame: Any) None[source]

Raises timeout exception from signal alarm callback.

Parameters:
  • signum (int) – POSIX signal number

  • frame (Any) – interrupted frame

Returns:

None

Return type:

None

run() int[source]

Executes grasp evaluation over all assigned poses.

Returns:

0 when worker exits

Return type:

int

test_grasp(gripper_pose: Any, pose_id: int) int[source]

Simulates one grasp attempt and stores its score.

Parameters:
  • gripper_pose (Any) – candidate end-effector pose

  • pose_id (int) – index into shared result arrays

Returns:

0 after evaluation completes

Return type:

int

class pybullet_grasper.grasp_generator.GraspGenerator(object_name: str = 'object_0.obj', init_position: List[float] | ndarray = [0, 0, 0], config_name: str = 'default.yaml', ros: bool = True)[source]

Bases: object

Creates grasp candidates and prepares simulation resources.

Parameters:
  • object_name (str, optional, default="object_0.obj") – object mesh name or path

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

  • config_name (str, optional, default="default.yaml") – configuration file name or path

  • ros (bool, optional, default=True) – whether ROS message types should be used

Returns:

None

Return type:

None

load_gripper() None[source]

Loads and composes simplified gripper collision geometry for pre-checks.

Returns:

None

Return type:

None

run(custom_pose: Any | None = None) Any[source]

Runs grasp evaluation either for all generated poses or one custom pose.

Parameters:

custom_pose (Any, optional, default=None) – optional pose override for one-off evaluation

Returns:

grasp response with poses and quality metrics

Return type:

Any

pybullet_grasper.grasp_generator.quaternion_multiply(q1: List[float] | ndarray, q2: List[float] | ndarray) ndarray[source]

Multiplies two quaternions [x, y, z, w].

Parameters:
  • q1 (list[float] | np.ndarray) – first quaternion

  • q2 (list[float] | np.ndarray) – second quaternion

Returns:

quaternion product [x, y, z, w]

Return type:

np.ndarray

pybullet_grasper.grasp_generator.signal_handler(signal: int, frame: Any) None[source]

Handler for killing the program :param signal: signal type :type signal: int :param frame: current frame where signal interrupted execution :type frame: Any :return: None :rtype: None

pybullet_grasper.grasp_generator.str_to_bool(str_bool: str) bool[source]

Converts a string value to boolean.

Parameters:

str_bool (str) – string representation of boolean

Returns:

True for common truthy values, otherwise False

Return type:

bool