concepts.simulator.pybullet.components.robot_base.Robot#

class Robot[source]#

Bases: BulletComponent

Methods

do(action_name, *args, **kwargs)

Execute an action primitive.

fk(qpos[, link_name_or_id])

Forward kinematics.

get_ee_home_pos()

Get the home position of the end effector.

get_ee_home_quat()

Get the home orientation of the end effector.

get_ee_pose()

Get the pose of the end effector.

get_gripper_state()

Get the gripper state.

get_home_qpos()

Get the home joint configuration.

get_qpos()

Get the current joint configuration.

get_robot_body_id()

Get the pybullet body ID of the robot.

get_robot_ee_link_id()

Get the pybullet link ID of the robot end effector.

ik(pos, quat[, force, max_distance, ...])

Inverse kinematics.

ik_pybullet(pos, quat[, force, verbose])

Inverse kinematics using pybullet.

ikfast(pos, quat[, last_qpos, max_attempts, ...])

Inverse kinematics using IKFast.

move_home([timeout])

Move the robot to the home configuration.

move_pose(pos, quat[, speed, force, verbose])

Move the end effector to the given pose.

move_qpos(target_qpos[, speed, timeout, ...])

Move the robot to the given joint configuration.

move_qpos_trajectory(qpos_trajectory[, ...])

Move the robot along the given joint configuration trajectory.

register_action(name, func[, interface])

Register an action primitive.

replay_qpos_trajectory(qpos_trajectory[, ...])

Replay a joint confifguartion trajectory.

reset_home_qpos()

Reset the home joint configuration.

set_ik_method(ik_method)

set_qpos(qpos)

Set the joint configuration.

set_qpos_with_holding(qpos)

Set the joint configuration with the gripper holding the object.

suppress_warnings()

Attributes

p

w

world

__init__(client, body_name=None, gripper_objects=None, current_interface='pybullet', ik_method='pybullet')[source]#
Parameters:
__new__(**kwargs)#
do(action_name, *args, **kwargs)[source]#

Execute an action primitive.

Parameters:

action_name (str) – Name of the action primitive.

Returns:

True if the action primitive is successful.

Return type:

bool

fk(qpos, link_name_or_id=None)[source]#

Forward kinematics.

Parameters:
  • qpos (np.ndarray) – Joint configuration.

  • link_name_or_id (Union[str, int], optional) – name or id of the link. If not specified, the pose of the end effector is returned.

Returns:

3D position and 4D quaternion of the end effector.

Return type:

Tuple[np.ndarray, np.ndarray]

get_ee_home_pos()[source]#

Get the home position of the end effector.

Return type:

ndarray

get_ee_home_quat()[source]#

Get the home orientation of the end effector.

Return type:

ndarray

get_ee_pose()[source]#

Get the pose of the end effector.

Returns:

3D position and 4D quaternion of the end effector.

Return type:

Tuple[np.ndarray, np.ndarray]

get_gripper_state()[source]#

Get the gripper state.

Returns:

True if the gripper is activated.

Return type:

Optional[bool]

get_home_qpos()[source]#

Get the home joint configuration.

Return type:

ndarray

get_qpos()[source]#

Get the current joint configuration.

Returns:

Current joint configuration.

Return type:

np.ndarray

get_robot_body_id()[source]#

Get the pybullet body ID of the robot.

Returns:

Body ID of the robot.

Return type:

int

Get the pybullet link ID of the robot end effector.

Returns:

Link ID of the robot end effector.

Return type:

int

ik(pos, quat, force=False, max_distance=float('inf'), max_attempts=1000, verbose=False)[source]#

Inverse kinematics.

Parameters:
  • pos (np.ndarray) – 3D position of the end effector.

  • quat (np.ndarray) – 4D quaternion of the end effector.

  • force (bool, optional) – Whether to force the IK solver to return a solution. Defaults to False. If set, the IK solve may return a solution even if the end effector is not at the given pose. This function is useful for debugging and for moving towards a certain direction.

  • max_distance (float, optional) – Maximum distance between the last qpos and the solution (Only used for IKFast). Defaults to float(‘inf’).

  • max_attempts (int, optional) – Maximum number of attempts (only used for IKFast). Defaults to 1000.

  • verbose (bool, optional) – Whether to print debug information.

Returns:

Joint configuration.

Return type:

np.ndarray

ik_pybullet(pos, quat, force=False, verbose=False)[source]#

Inverse kinematics using pybullet.

Parameters:
  • pos (np.ndarray) – 3D position of the end effector.

  • quat (np.ndarray) – 4D quaternion of the end effector.

  • force (bool, optional) – Whether to force the IK solver to return a solution. Defaults to False. If set, the IK solve may return a solution even if the end effector is not at the given pose. This function is useful for debugging and for moving towards a certain direction.

  • verbose (bool, optional) – Whether to print debug information.

Returns:

Joint configuration.

Return type:

np.ndarray

ikfast(pos, quat, last_qpos=None, max_attempts=1000, max_distance=float('inf'), error_on_fail=True, verbose=False)[source]#

Inverse kinematics using IKFast.

Parameters:
  • pos (np.ndarray) – 3D position of the end effector.

  • quat (np.ndarray) – 4D quaternion of the end effector.

  • last_qpos (Optional[np.ndarray], optional) – Last joint configuration. Defaults to None. If None, the current joint configuration is used.

  • max_attempts (int, optional) – Maximum number of IKFast attempts. Defaults to 1000.

  • max_distance (float, optional) – Maximum distance between the target pose and the end effector. Defaults to float(‘inf’).

  • error_on_fail (bool, optional) – Whether to raise an error if the IKFast solver fails. Defaults to True.

  • verbose (bool, optional) – Whether to print debug information.

Returns:

Joint configuration.

Return type:

np.ndarray

move_home(timeout=10.0)[source]#

Move the robot to the home configuration.

Parameters:

timeout (float) –

Return type:

bool

move_pose(pos, quat, speed=0.01, force=False, verbose=False)[source]#

Move the end effector to the given pose.

Parameters:
  • pos (np.ndarray) – 3D position of the end effector.

  • quat (np.ndarray) – 4D quaternion of the end effector.

  • speed (float, optional) – Speed of the movement. Defaults to 0.01.

  • force (bool, optional) – Whether to force the IK solver to return a solution. Defaults to False. If set, the IK solve may return a solution even if the end effector is not at the specified pose.

  • verbose (bool) –

Returns:

True if the movement is successful.

Return type:

bool

move_qpos(target_qpos, speed=0.01, timeout=10.0, local_smoothing=True)[source]#

Move the robot to the given joint configuration.

Parameters:
  • target_qpos (np.ndarray) – Target joint configuration.

  • speed (float, optional) – Speed of the movement. Defaults to 0.01.

  • timeout (float, optional) – Timeout of the movement. Defaults to 10.

  • local_smoothing (bool) –

Returns:

True if the movement is successful.

Return type:

bool

move_qpos_trajectory(qpos_trajectory, speed=0.01, timeout=10, first_timeout=None, local_smoothing=True, verbose=False)[source]#

Move the robot along the given joint configuration trajectory.

Parameters:
  • qpos_trajectory (Iterable[np.ndarray]) – Joint configuration trajectory.

  • speed (float, optional) – Speed of the movement. Defaults to 0.01.

  • timeout (float, optional) – Timeout of the movement. Defaults to 10.

  • first_timeout (float, optional) – Timeout of the first movement. Defaults to None (same as timeout).

  • local_smoothing (bool) –

  • verbose (bool) –

Returns:

True if the movement is successful.

Return type:

bool

register_action(name, func, interface=None)[source]#

Register an action primitive.

Parameters:
  • name (str) – Name of the action primitive.

  • func (Callable) – Function that implements the action primitive.

  • interface (Optional[str], optional) – Interface of the action primitive. Defaults to None. If None, the action primitive is registered for the current interface.

Raises:

ValueError – If the action primitive is already registered.

Return type:

None

replay_qpos_trajectory(qpos_trajectory, verbose=True)[source]#

Replay a joint confifguartion trajectory. This function is useful for debugging a generated joint trajectory.

Parameters:
  • qpos_trajectory (Iterable[ndarray]) – joint configuration trajectory.

  • verbose (bool) – whether to print debug information.

reset_home_qpos()[source]#

Reset the home joint configuration.

set_ik_method(ik_method)[source]#
Parameters:

ik_method (str | IKMethod) –

set_qpos(qpos)[source]#

Set the joint configuration.

Parameters:

qpos (np.ndarray) – Joint configuration.

Return type:

None

set_qpos_with_holding(qpos)[source]#

Set the joint configuration with the gripper holding the object.

Parameters:

qpos (np.ndarray) – Joint configuration.

Return type:

None

suppress_warnings()[source]#
property p#
property w#
property world#