Zum Inhalt

CubeState

The current state of the cube.

This class holds the necessary state information of a cube for usage with a robot.

Attributes:

Name Type Description
cube_is_gripped bool

Flag, indicating whether the cube is currently gripped.

cube_coordinate_system spatial.CoordinateSystem

The coordinate system of the cube relative to its parent (either mount or tool).

grip_position Optional[grip_target_generation.GripPosition]

The current grip position of the robot.

cube_is_in_mount: bool property readonly

Flag, indicating whether the cube is located in the mount.

Returns:

Type Description
bool

whether the cube is located in the mount.

exposed_faces: List[core.cube.FacePosition.FacePosition] property readonly

The currently exposed faces.

Returns:

Type Description
List[core.cube.FacePosition.FacePosition]

a list of all exposed faces in the order of grip_target_generation.GripperFace.ALL_ACCESSIBLE_GRIPPER_FACES

mounted_face: FacePosition property readonly

The face which is currently mounted in the mount.

Returns:

Type Description
FacePosition

the mounted face

tool_coordinate_system: Optional[core.spatial.CoordinateSystem.CoordinateSystem] property readonly

The coordinate system of the tool relative to the grip position.

Returns:

Type Description
Optional[core.spatial.CoordinateSystem.CoordinateSystem]

The coordinate system of the tool relative to the grip position.

exposed_face(self, gripper_face)

Returns the absolute FacePosition (i.e. a color) for a given GripperFace.

Parameters:

Name Type Description Default
gripper_face GripperFace

the relative gripper face to get the color of

required

Returns:

Type Description
FacePosition

the absolute face

Source code in core/manipulator/CubeState.py
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def exposed_face(self, gripper_face: grip_target_generation.GripperFace) -> cube.FacePosition:
    """Returns the absolute FacePosition (i.e. a color) for a given GripperFace.

    Args:
        gripper_face: the relative gripper face to get the color of
    Returns:
        the absolute face
    """

    assert self.cube_is_gripped, 'Cube is not gripped.'
    assert gripper_face in grip_target_generation.GripperFace.ALL_ACCESSIBLE_GRIPPER_FACES

    # inverse of childs base * parent vector
    cube_base_inv = np.linalg.inv(self.cube_coordinate_system.base)
    return cube.FacePosition.from_vector(np.matmul(cube_base_inv, gripper_face.to_vector()))

mount_to_tool(self)

Converts the coordinate system of a mounted cube into the tool coordinate system.

Source code in core/manipulator/CubeState.py
116
117
118
119
120
121
122
123
124
def mount_to_tool(self):
    """Converts the coordinate system of a mounted cube into the tool coordinate system."""
    assert not self.cube_is_gripped and self.tool_coordinate_system is not None

    cube_rel_cs_in_mount = self.cube_coordinate_system
    cube_base_in_tool_cs = np.matmul(np.linalg.inv(self.tool_coordinate_system.base), cube_rel_cs_in_mount.base)
    self.cube_coordinate_system.base = cube_base_in_tool_cs

    self.cube_is_gripped = True

tool_to_mount(self)

Converts the coordinate system of a gripped cube into the mount coordinate system.

Source code in core/manipulator/CubeState.py
104
105
106
107
108
109
110
111
112
def tool_to_mount(self):
    """Converts the coordinate system of a gripped cube into the mount coordinate system."""
    assert self.cube_is_gripped and self.tool_coordinate_system is not None

    cube_rel_cs_in_gripper = self.cube_coordinate_system
    cube_base_in_mount_cs = np.matmul(self.tool_coordinate_system.base, cube_rel_cs_in_gripper.base)
    self.cube_coordinate_system.base = cube_base_in_mount_cs

    self.cube_is_gripped = False