pyrcareworld.attributes package

Contents

pyrcareworld.attributes package#

Submodules#

pyrcareworld.attributes.activelightsensor_attr module#

class pyrcareworld.attributes.activelightsensor_attr.ActiveLightSensorAttr(env, id: int, data=None)[source]#

Bases: CameraAttr

Class of IR-based depth sensor, which can simulate the noise of real-world depth camera and produce depth image in similar pattern.

GetActiveDepth(main_intrinsic_matrix_local: ndarray, ir_intrinsic_matrix_local: ndarray)[source]#

Get IR-based depth image.

Parameters:
  • main_intrinsic_matrix_local – np.ndarray The intrinsic matrix of main camera.

  • ir_intrinsic_matrix_local – np.ndarray The intrinsic matrix of IR-based camera.

parse_message(data: dict)[source]#

Parse messages. This function is called by an internal function.

Parameters:

data – Dictionary containing the message data.

Returns:

A dict containing useful information of this class.

Return type:

dict

pyrcareworld.attributes.base_attr module#

class pyrcareworld.attributes.base_attr.BaseAttr(env, id: int, data: dict = {})[source]#

Bases: object

Base attribute class, which includes general functions such as object loading, setting transform, setting parent, etc.

Copy(new_id: int)[source]#

Duplicate an object.

Parameters:

new_id – Int, the ID of the new object.

Returns:

The new duplicated object.

Destroy()[source]#

Destroy this object.

DoComplete()[source]#

Complete tween movement/rotation directly.

DoKill()[source]#

Stop tween movement/rotation.

DoMove(position: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Tween movement.

Parameters:
  • position – A list of length 3, representing the position.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool, determines if the movement is speed-based.

  • relative – Bool, if True, position is relative; otherwise, position is absolute.

DoRotate(rotation: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Tween rotation.

Parameters:
  • rotation – A list of length 3, representing the rotation.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool, determines if the rotation is speed-based.

  • relative – Bool, if True, rotation is relative; otherwise, rotation is absolute.

DoRotateQuaternion(quaternion: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Tween rotation using quaternion.

Parameters:
  • quaternion – A list of length 4, representing the quaternion.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool, determines if the rotation is speed-based.

  • relative – Bool, if True, quaternion is relative; otherwise, quaternion is absolute.

GetLocalPointFromWorld(point: list)[source]#

Transform a point from local coordinates to world coordinates. After calling this method and stepping once, the result will be saved in self.data[β€˜result_local_point’].

Parameters:

point – A list of length 3, representing the position of a point.

GetWorldPointFromLocal(point: list)[source]#

Transform a point from world coordinates to local coordinates. After calling this method and stepping once, the result will be saved in self.data[β€˜result_world_point’].

Parameters:

point – A list of length 3, representing the position of a point.

LookAt(target: list, world_up: list = None)[source]#

Rotate the transform so the forward vector points at the target’s current position.

Parameters:
  • target – A list of length 3, target to point towards.

  • world_up – A list of length 3, vector specifying the upward direction.

Rotate(rotation: list, is_world: bool = True)[source]#

Rotate this object.

Parameters:
  • rotation – A list of length 3, representing the euler-angle-format rotation from the current euler angle.

  • is_world – Bool, True for world coordinate, False for local coordinate.

SetActive(active: bool)[source]#

Activate/Deactivate this object.

Parameters:

active – Bool, True for active, False for inactive.

SetLayer(layer: int)[source]#

Set the layer in Unity of this object. Check https://docs.unity3d.com/Manual/Layers.html to get an idea about layers.

Parameters:

layer – Int, the number of the layer.

SetParent(parent_id: int, parent_name: str = '')[source]#

Set the parent of this object.

Parameters:
  • parent_id – Int, the ID of the parent object.

  • parent_name – Str, the name of the parent object.

SetPosition(position: list = None, is_world: bool = True)[source]#

Set the position of this object.

Parameters:
  • position – A list of length 3, representing the target position value of the object.

  • is_world – Bool, True for world coordinate, False for local coordinate.

SetRotation(rotation: list = None, is_world: bool = True)[source]#

Set the rotation of this object.

Parameters:
  • rotation – A list of length 3, representing the target euler angle value of the object.

  • is_world – Bool, True for world coordinate, False for local coordinate.

SetRotationQuaternion(quaternion: list = None, is_world: bool = True)[source]#

Set the rotation of this object using quaternion.

Parameters:
  • quaternion – A list of length 4, representing the quaternion from the current pose.

  • is_world – Bool, True for world coordinate, False for local coordinate.

SetScale(scale: list = None)[source]#

Set the scale of this object.

Parameters:

scale – A list of length 3, representing the target scale value of the object.

SetTransform(position: list = None, rotation: list = None, scale: list = None, is_world: bool = True)[source]#

Set the transform of this object, including position, rotation, scale, and coordinate.

Parameters:
  • position – A list of length 3, representing the target position value of the object.

  • rotation – A list of length 3, representing the target euler angle value of the object.

  • scale – A list of length 3, representing the target scale value of the object.

  • is_world – Bool, True for world coordinate, False for local coordinate.

SetType(attr_type: type)[source]#

Set the attribute type of this object.

Parameters:

attr_type – Any attribute in pyrcareworld.attributes.

Returns:

The target attribute.

Translate(translation: list, is_world: bool = True)[source]#

Translate this object.

Parameters:
  • translation – A list of length 3, representing the translation from the current position.

  • is_world – Bool, True for world coordinate, False for local coordinate.

WaitDo()[source]#

Wait for the native IK target movement/rotation to complete.

parse_message(data: dict)[source]#

Parse messages. This function handles the data sent from Unity and stores it in self.data, which contains the keys in data. This function is called by an internal function at each timestep, so the data is updated every timestep.

Parameters:

data – Dictionary containing the message data. The keys are: - β€˜name’: The name of the object. - β€˜position’: The position of the object in world coordinates. - β€˜rotation’: The euler angle of the object in world coordinates. - β€˜quaternion’: The quaternion of the object in world coordinates. - β€˜local_position’: The position of the object in its parent’s local coordinates. - β€˜local_rotation’: The euler angle of the object in its parent’s local coordinates. - β€˜local_quaternion’: The quaternion of the object in its parent’s local coordinates. - β€˜local_to_world_matrix’: The transformation matrix from local to world coordinates. - β€˜result_local_point’: The result of transforming the object from local to world coordinates. - β€˜result_world_point’: The result of transforming the object from world to local coordinates.

pyrcareworld.attributes.camera_attr module#

class pyrcareworld.attributes.camera_attr.CameraAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Camera class. This class is used to control the camera and obtain visual information from the simulation environment.

The data stored in self.data is a dictionary containing the following keys:
  • β€˜name’: The name of the object.

  • β€˜position’: The position of the object in world coordinates.

  • β€˜rotation’: The euler angle of the object in world coordinates.

  • β€˜quaternion’: The quaternion of the object in world coordinates.

  • β€˜local_position’: The position of the object in its parent’s local coordinates.

  • β€˜local_rotation’: The euler angle of the object in its parent’s local coordinates.

  • β€˜local_quaternion’: The quaternion of the object in its parent’s local coordinates.

  • β€˜local_to_world_matrix’: The transformation matrix from local to world coordinates.

  • β€˜result_local_point’: The result of transforming the object from local to world coordinates.

  • β€˜result_world_point’: The result of transforming the object from world to local coordinates.

AlignView()[source]#

Make the camera in rcareworld align with the current view in GUI.

EndHeatMapRecord()[source]#

End the heat map recording.

Get2DBBox(width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the 2D bounding box of objects in the current camera view.

Parameters:
  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

Get3DBBox()[source]#

Get the 3D bounding box of objects in world coordinates.

GetAmodalMask(target_id: int, width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the amodal mask image for the target object.

Parameters:
  • target_id – The target object ID.

  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

GetDepth(zero_dis: float = 0.0, one_dis: float = 1.0, width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the depth 8-bit PNG image from the camera. Since each pixel of the depth image returned from this function is 8-bit, the user should limit the depth range (zero_dis and one_dis) for more accurate results.

Parameters:
  • zero_dis – The minimum distance in calculation.

  • one_dis – The maximum distance in calculation.

  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

GetDepth16Bit(zero_dis: float = 0.0, one_dis: float = 1.0, width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the depth 16-bit PNG image from the camera. Since each pixel of the depth image returned from this function is 16-bit, the user should limit the depth range (zero_dis and one_dis) for more accurate results.

Parameters:
  • zero_dis – The minimum distance in calculation.

  • one_dis – The maximum distance in calculation.

  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

GetDepthEXR(width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the depth EXR image from the camera. This function returns EXR format image bytes and each pixel is 32-bit.

Parameters:
  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

GetHeatMap(width: int = None, height: int = None, radius: int = 50, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the heat map image.

Parameters:
  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • radius – The radius of the heat map.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

GetID(width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the instance segmentation mask image. The color for each pixel is computed from object ID, see pyrcareworld.utils.rfunicerse_util.GetColorFromID for more details.

Parameters:
  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

GetNormal(width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the normal image in world coordinates.

Parameters:
  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

GetRGB(width: int = None, height: int = None, fov: float = 60.0, intrinsic_matrix: ndarray = None)[source]#

Get the camera RGB image.

Parameters:
  • width – Int, the width of the image.

  • height – Int, the height of the image.

  • fov – Float, the field of view for the camera.

  • intrinsic_matrix – A ndarray of shape 3x3, representing the camera intrinsic matrix. When this parameter is passed, width, height, and fov will be ignored.

StartHeatMapRecord(targets_id: list)[source]#

Start recording heat map data for the specified targets.

Parameters:

targets_id – List of target IDs to record heat map data for.

pyrcareworld.attributes.cloth_attr module#

class pyrcareworld.attributes.cloth_attr.ClothAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Obi cloth class.

AddAttach(id: int, max_dis: float = 0.03)[source]#

Add Attach clothing to attr object with the given ID.

Parameters:
  • id – Int, Target attr object ID.

  • max_dis – Float, max distance.

GetParticles()[source]#

Get the cloth particles.

RemoveAttach(id: int)[source]#

Remove Attach clothing from attr object with the given ID.

Parameters:

id – Int, Target attr object ID.

pyrcareworld.attributes.collider_attr module#

class pyrcareworld.attributes.collider_attr.ColliderAttr(env, id: int, data: dict = {})[source]#

Bases: GameObjectAttr

Collider class for objects that have a collider in Unity.

AddObiCollider()[source]#

Add an ObiCollider to this Collider. https://obi.virtualmethodstudio.com/manual/6.3/collisions.html

EnabledAllCollider(enabled: bool)[source]#

Enable or disable all colliders.

Parameters:

enabled – Bool, True to enable and False to disable.

GenerateVHACDColider()[source]#

Generate convex colliders using the VHACD algorithm.

SetPhysicMaterial(bounciness: float, dynamicFriction: float, staticFriction: float, frictionCombine: int, bounceCombine: int)[source]#

Set the physical material properties for the collider.

Parameters:
  • bounciness – Float, The coefficient of restitution or β€œbounciness” of the collider. A value of 0 means no bounce, while a value of 1 means a perfect bounce.

  • dynamicFriction – Float, The coefficient of friction when the collider is in motion relative to another collider.

  • staticFriction – Float, The coefficient of friction when the collider is at rest relative to another collider.

  • frictionCombine – Int, Defines how friction values should be combined when multiple colliders interact. Possible values: - 0: Average - 1: Maximum - 2: Minimum - 3: Multiply

  • bounceCombine – Int, Defines how bounce values should be combined when multiple colliders interact. Possible values: - 0: Average - 1: Maximum - 2: Minimum - 3: Multiply

SetRFMoveColliderActive(active: bool)[source]#

Set the collider active or inactive in RFMove.

Parameters:

active – Bool, True for active and False for inactive.

pyrcareworld.attributes.controller_attr module#

class pyrcareworld.attributes.controller_attr.ControllerAttr(env, id: int, data: dict = {})[source]#

Bases: ColliderAttr

Robot controller class, which will control robot arms, hands, mobile manipulators, etc. The data stored in self.data is a dictionary containing the following keys:

  • β€˜number_of_joints’: The number of joints in an articulation.

  • β€˜names’: The name of each part in an articulation.

  • β€˜types’: The joint type of each part in an articulation.

  • β€˜positions’: The position of each part in an articulation.

  • β€˜rotations’: The rotation of each part in an articulation.

  • β€˜quaternion’: The quaternion of each part in an articulation.

  • β€˜local_positions’: The local position of each part in an articulation.

  • β€˜local_rotations’: The local rotation of each part in an articulation.

  • β€˜local_quaternion’: The local quaternion of each part in an articulation.

  • β€˜velocities’: The velocity of each part in an articulation.

  • β€˜angular_velocities’: The angular velocity of each part in an articulation.

  • β€˜number_of_moveable_joints’: The number of moveable joints in an articulation.

  • β€˜joint_positions’: The joint position of each moveable joint in an articulation.

  • β€˜joint_velocities’: The joint velocity of each moveable joint in an articulation.

  • β€˜joint_accelerations’: The joint accelerations of each moveable joint in an articulation.

  • β€˜joint_force’: The joint force of each moveable joint in an articulation.

  • β€˜joint_lower_limit’: The joint lower limit of each moveable joint in an articulation.

  • β€˜joint_upper_limit’: The joint upper limit of each moveable joint in an articulation.

  • β€˜joint_stiffness’: The joint stiffness of each moveable joint in an articulation.

  • β€˜joint_damping’: The joint damping of each moveable joint in an articulation.

  • β€˜move_done’: Whether robot arm IK has finished moving.

  • β€˜rotate_done’: Whether robot arm IK has finished rotating.

  • β€˜gravity_forces’: Inverse dynamics force needed to counteract gravity.

  • β€˜coriolis_centrifugal_forces’: Inverse dynamics force needed to counteract coriolis centrifugal forces.

  • β€˜drive_forces’: Inverse dynamics drive forces.

AddJointForce(joint_forces: list)[source]#

Add force to each moveable joint.

Parameters:

joint_forces – A list of forces, representing the added forces.

AddJointForceAtPosition(joint_forces: list, force_positions: list)[source]#

Add force to each moveable joint at a given position.

Parameters:
  • joint_forces – A list of forces, representing the added forces.

  • force_positions – A list of positions, representing the positions for forces.

AddJointTorque(joint_torques: list)[source]#

Add torque to each moveable joint.

Parameters:

joint_torques – A list of torques, representing the added torques.

AddRoot6DOF(new_id: int = None)[source]#

Add a 6-DOF root joint to the articulation body. The articulation body is incapable of non-dynamic motion and requires the addition of a 6-DOF root joint for free motion. This must be called when the object is first created.

Parameters:

new_id – Int, optional new ID for the root joint.

Returns:

The new root joint as a ControllerAttr instance.

EnabledNativeIK(enabled: bool)[source]#

Enable or disable the native IK algorithm.

Parameters:

enabled – Bool, True to enable and False to disable. When enabled, use the IKTatGetDo*** interface to set the end pose. When disabled, use the SetJoint*** interface to move the joints. Native IK can only take effect when it is started during initialization.

GetIKTargetJointPosition(position: list = None, rotation: list = None, quaternion: list = None, iterate: int = 100)[source]#

Input IK target pose and get the IK calculation results. After calling this method and stepping once, the result will be saved in self.data[β€˜result_joint_position’]

Parameters:
  • position – A list of length 3, representing the position of the IK target.

  • rotation – A list of length 3, representing the euler angle of the IK target.

  • quaternion – A list of length 4, representing the quaternion of the IK target. If this parameter is specified, rotation will be ignored.

  • iterate – Int, the number of IK calculation iterations.

GetJointInverseDynamicsForce()[source]#

Get the joint inverse dynamics force of each moveable joint. Note that this function only works in Unity version >= 2022.1.

GetJointLocalPointFromWorld(joint_index: int, point: list)[source]#

Transform a point from joint local coordinates to world coordinates. After calling this method and stepping once, the result will be saved in self.data[β€˜result_joint_local_point’]

Parameters:
  • joint_index – Int, index of the joint.

  • point – A list of length 3, representing the position of a point.

GetJointWorldPointFromLocal(joint_index: int, point: list)[source]#

Transform a point from world coordinates to joint local coordinates. After calling this method and stepping once, the result will be saved in self.data[β€˜result_joint_world_point’]

Parameters:
  • joint_index – Int, index of the joint.

  • point – A list of length 3, representing the position of a point.

GripperClose()[source]#

Close the gripper.

GripperOpen()[source]#

Open the gripper.

IKTargetDoComplete()[source]#

Complete native IK target movement/rotation directly.

IKTargetDoKill()[source]#

Stop native IK target movement/rotation.

IKTargetDoMove(position: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Native IK target movement.

Parameters:
  • position – A list of length 3, representing the position.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool.

  • relative – Bool, if True, position is relative; otherwise, position is absolute.

IKTargetDoRotate(rotation: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Native IK target rotation.

Parameters:
  • rotation – A list of length 3, representing the rotation.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool.

  • relative – Bool, if True, rotation is relative; otherwise, rotation is absolute.

IKTargetDoRotateQuaternion(quaternion: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Native IK target rotation using quaternion.

Parameters:
  • quaternion – A list of length 4, representing the quaternion.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool.

  • relative – Bool, if True, quaternion is relative; otherwise, quaternion is absolute.

MoveBack(distance: float, speed: float)[source]#

Move the robot backward. Only works if the robot controller has a mobile platform.

Parameters:
  • distance – Float, distance.

  • speed – Float, velocity.

MoveForward(distance: float, speed: float)[source]#

Move the robot forward. Only works if the robot controller has a mobile platform.

Parameters:
  • distance – Float, distance.

  • speed – Float, velocity.

SetIKTargetOffset(position: list = None, rotation: list = None, quaternion: list = None)[source]#

Set the new IK target by setting offset to the original target of native IK.

Parameters:
  • position – A list of length 3, representing the position offset to the original target.

  • rotation – A list of length 3, representing the rotation offset to the original target.

  • quaternion – A list of length 4, representing the quaternion offset to the original target. If this parameter is specified, rotation will be ignored.

SetImmovable(immovable: bool)[source]#

Set whether the base of the articulation is immovable.

Parameters:

immovable – Bool, True for immovable, False for movable.

SetIndexJointPosition(index: int, joint_position: float)[source]#

Set the target joint position for a given joint and move with PD control.

Parameters:
  • index – Int, joint index.

  • joint_position – Float, the target joint position.

SetIndexJointPositionDirectly(index: int, joint_position: float)[source]#

Set the target joint position for a given joint and move directly.

Parameters:
  • index – Int, joint index.

  • joint_position – Float, the target joint position.

SetIndexJointVelocity(index: int, joint_velocity: float)[source]#

Set the target joint velocity for a given joint.

Parameters:
  • index – Int, joint index.

  • joint_velocity – A list of float, representing the target joint velocities.

SetJointDamping(joint_damping: list)[source]#

Set the joint damping for each moveable joint.

Parameters:

joint_damping – A list of float, each moveable joint damping.

SetJointDriveForce(joint_drive_forces: list)[source]#

Set the joint drive forces for each moveable joint.

Parameters:

joint_drive_forces – A list of float, representing the joint drive forces.

SetJointLimit(joint_upper_limit: list, joint_lower_limit: list)[source]#

Set the joint limit for each moveable joint.

Parameters:
  • joint_upper_limit – A list of float, each moveable joint upper limit.

  • joint_lower_limit – A list of float, each moveable joint lower limit.

SetJointPosition(joint_positions: list)[source]#

Set the joint position for each moveable joint and move with PD control.

Parameters:

joint_positions – A list of float, representing the target joint positions.

SetJointPositionContinue(interval: int, time_joint_positions: list)[source]#

Set the joint position for each moveable joint and move with PD control continuously.

Parameters:
  • interval – Float, the time interval.

  • time_joint_positions – A list of float list, representing the target joint positions at each time step.

SetJointPositionDirectly(joint_positions: list)[source]#

Set the joint position for each moveable joint and move directly.

Parameters:

joint_positions – A list of float, representing the target joint positions.

SetJointStiffness(joint_stiffness: list)[source]#

Set the joint stiffness for each moveable joint.

Parameters:

joint_stiffness – A list of float, each moveable joint stiffness.

SetJointUseGravity(use_gravity: bool)[source]#

Set all joints to use or not use gravity.

Parameters:

use_gravity – Bool, True to use gravity, False to not use gravity.

SetJointVelocity(joint_velocitys: list)[source]#

Set the joint velocity for each moveable joint.

Parameters:

joint_velocitys – A list of float, representing the target joint velocities.

TurnLeft(angle: float, speed: float)[source]#

Turn the robot left. Only works if the robot controller has a mobile platform.

Parameters:
  • angle – Float, rotation angle.

  • speed – Float, velocity.

TurnRight(angle: float, speed: float)[source]#

Turn the robot right. Only works if the robot controller has a mobile platform.

Parameters:
  • angle – Float, rotation angle.

  • speed – Float, velocity.

pyrcareworld.attributes.custom_attr module#

class pyrcareworld.attributes.custom_attr.CustomAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

This is an example of a custom attribute class, without actual functions.

The data stored in self.data is a dictionary containing the following keys:
  • β€˜custom_message’: a custom message.

CustomMessage(message: str)[source]#

Send a custom message.

Parameters:

message – Str, the custom message to be sent.

parse_message(data: dict)[source]#

Parse messages. This function is called by an internal function.

data[β€˜custom_message’]: A custom message.

pyrcareworld.attributes.digit_attr module#

class pyrcareworld.attributes.digit_attr.DigitAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Class for simulating DIGIT tactile sensor. https://digit.ml/ The data stored in self.data is a dictionary containing the following keys:

  • β€˜light’: Bytes of RGB light image in DIGIT.

  • β€˜depth’: Bytes of depth image in DIGIT.

GetData()[source]#

Get data from DIGIT.

parse_message(data: dict)[source]#

Parse messages. This function is called by an internal function.

Parameters:

data – Dictionary containing the message data.

pyrcareworld.attributes.gameobject_attr module#

class pyrcareworld.attributes.gameobject_attr.GameObjectAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Basic game object attribute class.

The data stored in self.data is a dictionary containing the following keys:
  • β€˜3d_bounding_box’: The 3D bounding box of objects.

EnabledRender(enabled: bool)[source]#

Enable or disable the rendering system.

Parameters:

enabled – Bool, True to enable rendering and False to disable rendering.

Get3DBBox()[source]#

Get the 3D bounding box of this object.

SetColor(color: list)[source]#

Set the object color.

Parameters:

color – A list of length 4, representing r, g, b, and a. Each float is in the range (0, 1).

SetTexture(path: str)[source]#

Set the texture of the object.

Parameters:

path – Str, the absolute path for the texture file.

pyrcareworld.attributes.gelslim_attr module#

class pyrcareworld.attributes.gelslim_attr.GelSlimAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Class for simulating GelSlim tactile sensor. https://arxiv.org/abs/1803.00628 The data stored in self.data is a dictionary containing the following keys: - β€˜light’: Bytes of RGB light image in GelSlim. - β€˜depth’: Bytes of depth image in GelSlim.

BlurGel(radius: int = 5, sigma: float = 2)[source]#

Blur Gel mesh. Simulate smooth deformation.

Parameters:
  • radius – Int, Gaussian blur radius.

  • sigma – Float, Gaussian blur sigma.

GetData()[source]#

Get data from GelSlim.

RestoreGel()[source]#

Restore Gel mesh.

parse_message(data: dict)[source]#

Parse messages. This function is called by an internal function.

Parameters:

data – Dictionary containing the message data.

pyrcareworld.attributes.graspsim_attr module#

class pyrcareworld.attributes.graspsim_attr.GraspSimAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Grasp pose simulation class.

The data stored in self.data is a dictionary containing the following keys: - β€˜done’: Whether the simulation is done. - β€˜points’: The list of grasp points. - β€˜quaternions’: The list of grasping pose quaternions. - β€˜width’: The list of gripper width of grasping pose. - β€˜success’: The list of success or failure of the grasping pose.

GenerateGraspPose(mesh: str, gripper: str, points: list, normals: list, depth_range_min: float, depth_range_max: float, depth_lerp_count: int, angle_lerp_count: int)[source]#

Generate grasp poses and visualize grasp results.

Parameters:
  • mesh – Str, the absolute path to .obj file.

  • gripper – Str, the name of the gripper.

  • points – A list of float, representing the grasping points.

  • normals – A list of float, representing the normals.

  • depth_range_min – Float, the minimum depth of grasp pose.

  • depth_range_max – Float, the maximum depth of grasp pose.

  • depth_lerp_count – Int, the interpolation count of depth.

  • angle_lerp_count – Int, the interpolation count of angle.

ShowGraspPose(mesh: str, gripper: str, positions: list, quaternions: list)[source]#

Display grasp poses.

Parameters:
  • mesh – Str, the absolute path to .obj file.

  • gripper – Str, the name of the gripper.

  • positions – A list of float, representing the grasping positions.

  • quaternions – A list of float, representing the quaternions.

StartGraspSim(mesh: str, gripper: str, points: list, normals: list, depth_range_min: float, depth_range_max: float, depth_lerp_count: int, angle_lerp_count: int, parallel_count: int = 100)[source]#

Start simulating grasping.

Parameters:
  • mesh – Str, the absolute path to .obj file.

  • gripper – Str, the name of the gripper.

  • points – A list of float, representing the grasping points.

  • normals – A list of float, representing the normals.

  • depth_range_min – Float, the minimum depth of grasp pose.

  • depth_range_max – Float, the maximum depth of grasp pose.

  • depth_lerp_count – Int, the interpolation count of depth.

  • angle_lerp_count – Int, the interpolation count of angle.

  • parallel_count – Int, the count of parallel grasping.

StartGraspTest(mesh: str, gripper: str, points: list, quaternions: list, parallel_count: int = 100)[source]#

Start testing the grasp based on current grasp poses.

Parameters:
  • mesh – Str, the absolute path to .obj file.

  • gripper – Str, the name of the gripper.

  • points – A list of float, representing the grasping points.

  • quaternions – A list of float, representing the quaternions.

  • parallel_count – Int, the count of parallel grasping.

pyrcareworld.attributes.humanbody_attr module#

class pyrcareworld.attributes.humanbody_attr.HumanbodyAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Human body Inverse Kinematic class.

The data stored in self.data is a dictionary containing the following keys: - β€˜move_done’: Whether the movement has finished. - β€˜rotate_done’: Whether the rotation has finished.

HumanIKTargetDoComplete(index: int)[source]#

Make the human body IK target movement/rotation complete directly.

Parameters:

index – Int, the target for movement. 0 for left hand, 1 for right hand, 2 for left foot, 3 for right foot, 4 for head.

HumanIKTargetDoKill(index: int)[source]#

Make the human body IK target movement/rotation stop.

Parameters:

index – Int, the target for movement. 0 for left hand, 1 for right hand, 2 for left foot, 3 for right foot, 4 for head.

HumanIKTargetDoMove(index: int, position: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Human body Inverse Kinematics target movement.

Parameters:
  • index – Int, the target for movement. 0 for left hand, 1 for right hand, 2 for left foot, 3 for right foot, 4 for head.

  • position – A list of length 3, representing the position.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool, if True, duration represents movement duration; otherwise, it represents movement speed.

  • relative – Bool, if True, position is relative; otherwise, position is absolute.

HumanIKTargetDoRotate(index: int, rotation: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Human body Inverse Kinematics target rotation.

Parameters:
  • index – Int, the target for movement. 0 for left hand, 1 for right hand, 2 for left foot, 3 for right foot, 4 for head.

  • rotation – A list of length 3, representing the rotation.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool, if True, duration represents movement duration; otherwise, it represents movement speed.

  • relative – Bool, if True, rotation is relative; otherwise, rotation is absolute.

HumanIKTargetDoRotateQuaternion(index: int, quaternion: list, duration: float, speed_based: bool = True, relative: bool = False)[source]#

Human body Inverse Kinematics target rotation using quaternion.

Parameters:
  • index – Int, the target for movement. 0 for left hand, 1 for right hand, 2 for left foot, 3 for right foot, 4 for head.

  • quaternion – A list of length 4, representing the quaternion.

  • duration – Float, if speed_based is True, it represents movement duration; otherwise, it represents movement speed.

  • speed_based – Bool, if True, duration represents movement duration; otherwise, it represents movement speed.

  • relative – Bool, if True, quaternion is relative; otherwise, quaternion is absolute.

pyrcareworld.attributes.light_attr module#

class pyrcareworld.attributes.light_attr.LightAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Light attribute class.

SetColor(color: list)[source]#

Set the color of the light.

Parameters:

color – A list of length 3, representing the R, G, and B channels, in range [0, 1].

SetIntensity(light_intensity: float)[source]#

Set the intensity of the light.

Parameters:

light_intensity – Float, the intensity of the light.

SetRange(light_range: float)[source]#

Set the range of the light. (Only available when the LightType is LightType.Spot or LightType.Point)

Parameters:

light_range – Float, the range of the light.

SetShadow(light_shadow: LightShadow)[source]#

Set the type of shadow.

Parameters:

light_shadow – LightShadow, the type of shadow.

SetSpotAngle(spot_angle: float)[source]#

Set the angle of the light. (Only available when the LightType is LightType.Spot)

Parameters:

spot_angle – Float, the angle of the light.

SetType(light_type: LightType)[source]#

Set the type of light.

Parameters:

light_type – LightType, the type of light.

class pyrcareworld.attributes.light_attr.LightShadow(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

The type of shadow, keeping the same name as LightShadows (https://docs.unity3d.com/ScriptReference/LightShadows.html) in Unity.

Hard = 1#
NoneShadow = 0#
Soft = 2#
class pyrcareworld.attributes.light_attr.LightType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

The type of light, keeping the same name as LightType (https://docs.unity3d.com/ScriptReference/LightType.html) in Unity.

Area = 3#
Directional = 1#
Disc = 4#
Point = 2#
Spot = 0#

pyrcareworld.attributes.omplmanager_attr module#

pyrcareworld.attributes.pointcloud_attr module#

class pyrcareworld.attributes.pointcloud_attr.PointCloudAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Point cloud rendering class.

SetRadius(radius: float)[source]#

Set the radius for points in a point cloud.

Parameters:

radius – Float, the radius.

ShowPointCloud(positions: ndarray = None, colors: ndarray = None, ply_path: str = None, radius: float = 0.01)[source]#

Display point cloud in Unity.

Parameters:
  • positions – A list of positions of points in a point cloud.

  • colors – A list of colors of points (range [0, 1]) in a point cloud.

  • ply_path – Str, the absolute path of .ply file. If this parameter is specified, positions and colors will be ignored.

  • radius – Float, the radius of the point cloud.

pyrcareworld.attributes.rigidbody_attr module#

class pyrcareworld.attributes.rigidbody_attr.RigidbodyAttr(env, id: int, data: dict = {})[source]#

Bases: ColliderAttr

Rigid body class.

The data stored in self.data is a dictionary containing the following keys: - β€˜velocity’: The velocity of the object. - β€˜angular_velocity’: The angular velocity of the object.

AddForce(force: list)[source]#

Add force to this rigid body object.

Parameters:

force – A list of length 3, representing the force added to this rigid body.

EnabledMouseDrag(enabled: bool)[source]#

Enable or disable the rigid body Mouse Drag.

Parameters:

enabled – Bool, enable Mouse Drag or not.

Link this rigidbody to another rigidbody or ArticulationBody.

Parameters:
  • target_id – Int, the ID of another rigidbody or ControllerAttr.

  • joint_index – Int, the ID of the ControllerAttr joint.

  • mass_scale – Float, the scale to apply to the inverse mass and inertia tensor of the body prior to solving the constraints.

  • connected_mass_scale – Float, the scale to apply to the inverse mass and inertia tensor of the connected body prior to solving the constraints.

SetAngularDrag(angular_drag: float)[source]#

Set the angular drag of this rigid body object.

Parameters:

angular_drag – Float, representing the angular drag of this rigid body.

SetAngularVelocity(angular_velocity: list)[source]#

Set the angular velocity of this rigid body object.

Parameters:

angular_velocity – A list of length 3, representing the angular velocity of this rigid body.

SetDrag(drag: float)[source]#

Set the drag of this rigid body object.

Parameters:

drag – Float, representing the drag of this rigid body.

SetKinematic(is_kinematic: bool)[source]#

Set the Rigidbody to be kinematic or not.

Parameters:

is_kinematic – Bool, True if the Rigidbody is kinematic, False otherwise.

SetMass(mass: float)[source]#

Set the mass of this rigid body object.

Parameters:

mass – Float, representing the mass of this rigid body.

SetUseGravity(use_gravity: bool)[source]#

Set the rigid body to use gravity or not.

Parameters:

use_gravity – Bool, use gravity or not.

SetVelocity(velocity: list)[source]#

Set the velocity of this rigid body object.

Parameters:

velocity – A list of length 3, representing the velocity of this rigid body.

pyrcareworld.attributes.softbody_attr module#

class pyrcareworld.attributes.softbody_attr.SoftBodyAttr(env, id: int, data: dict = {})[source]#

Bases: BaseAttr

Obi Softbody class.

parse_message(data: dict)[source]#

Parse messages. This function is called by an internal function.

Parameters:

data – Dictionary containing the message data.

Returns:

A dict containing useful information of this class.

Return type:

dict

Module contents#