def test_shift_conversion(self):
        conv = Converter(shift_z_offset=0.0, box=self.box)

        image = OrthographicImage(
            self.read_image(self.file_path / self.image_name), 2000.0, 0.22,
            0.4, '', Config.default_image_pose)

        action = Action()
        action.type = 'shift'
        action.pose = RobotPose()
        action.pose.x = -0.02
        action.pose.y = 0.105
        action.pose.a = 1.52
        action.pose.d = 0.078
        action.index = 1
        action.shift_motion = [0.03, 0.0]

        draw_pose(image, action.pose, convert_to_rgb=True)
        draw_around_box(image, box=self.box, draw_lines=True)
        imageio.imwrite(str(self.file_path / 'gen-shift-draw-pose.png'),
                        image.mat)

        self.assertTrue(conv.shift_check_safety(action, [image]))

        conv.calculate_pose(action, [image])
        self.assertLess(action.pose.z, 0.0)
示例#2
0
    def to_action(self, action: Action) -> None:
        gripper_index = action.index // len(self.angles)
        angle_index = action.index % len(self.angles)

        aff = Affine(b=self.angles[angle_index][0], c=self.angles[angle_index][1]) * action.pose
        action.pose.b = aff.b
        action.pose.c = aff.c
        action.pose.d = self.gripper_classes[gripper_index]
        action.type = 'grasp'
    def test_grasp_conversion(self):
        conv = Converter(grasp_z_offset=0.0, box=self.box)

        image = OrthographicImage(
            self.read_image(self.file_path / self.image_name), 2000.0, 0.22,
            0.4, '', Config.default_image_pose)

        action = Action()
        action.type = 'grasp'
        action.pose.x = -0.06
        action.pose.y = 0.099
        action.pose.a = 0.523
        action.pose.d = 0.078
        action.index = 1

        draw_pose(image, action.pose, convert_to_rgb=True)
        draw_around_box(image, box=self.box, draw_lines=True)
        imageio.imwrite(str(self.file_path / 'gen-grasp-draw-pose.png'),
                        image.mat)

        self.assertTrue(conv.grasp_check_safety(action, [image]))

        conv.calculate_pose(action, [image])
        self.assertLess(action.pose.z, 0.0)
 def to_action(self, action: Action) -> None:
     action.direction = self.directions[action.index]
     action.shift_motion = self.shift_motions[action.index]
     action.pose.d = 0.0
     action.type = 'shift'
 def to_action(self, action: Action) -> None:
     action.pose.d = self.gripper_classes[action.index]
     action.type = 'grasp'
 def to_action(self, action: Action) -> None:
     gripper_index = action.index % len(self.gripper_classes)
     action.pose.d = self.gripper_classes[gripper_index]
     action.type = 'grasp'