Skip to content

Commit

Permalink
test Robot cell and state
Browse files Browse the repository at this point in the history
  • Loading branch information
yck011522 committed Sep 13, 2024
1 parent c56e280 commit ab29b38
Showing 1 changed file with 46 additions and 20 deletions.
66 changes: 46 additions & 20 deletions tests/robots/test_robot_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,63 @@
from compas_fab.robots import RobotLibrary
from compas_robots import RobotModel

import pytest

from copy import deepcopy


def test_copy():
@pytest.fixture
def ur10e_gripper_one_beam():
return RobotCellLibrary.ur10e_gripper_one_beam()


@pytest.fixture
def abb_irb4600_40_255_gripper_one_beam():
return RobotCellLibrary.abb_irb4600_40_255_gripper_one_beam()


@pytest.fixture
def abb_irb4600_40_255_printing_tool():
return RobotCellLibrary.abb_irb4600_40_255_printing_tool()


def test_robot_cell_copy(ur10e_gripper_one_beam, abb_irb4600_40_255_gripper_one_beam, abb_irb4600_40_255_printing_tool):
"""Test to comply with Data.copy() mechanism"""

robot_cell, robot_cell_state = RobotCellLibrary.ur10e_gripper_one_beam()
def test(robot_cell, robot_cell_state):
robot_cell_copy = robot_cell.copy()
assert robot_cell.robot.name == robot_cell_copy.robot.name
assert robot_cell.tool_ids == robot_cell_copy.tool_ids
assert robot_cell.rigid_body_ids == robot_cell_copy.rigid_body_ids

robot_cell_copy = robot_cell.copy()
assert robot_cell.robot.name == robot_cell_copy.robot.name
assert robot_cell.tool_ids == robot_cell_copy.tool_ids
assert robot_cell.rigid_body_ids == robot_cell_copy.rigid_body_ids
robot_cell_state_copy = robot_cell_state.copy()
assert robot_cell_state.tool_ids == robot_cell_state_copy.tool_ids
assert robot_cell_state.rigid_body_ids == robot_cell_state_copy.rigid_body_ids

robot_cell_state_copy = robot_cell_state.copy()
assert robot_cell_state.tool_ids == robot_cell_state_copy.tool_ids
assert robot_cell_state.rigid_body_ids == robot_cell_state_copy.rigid_body_ids
test(*ur10e_gripper_one_beam)
test(*abb_irb4600_40_255_gripper_one_beam)
test(*abb_irb4600_40_255_printing_tool)


def test_deepcopy():
def test_robot_cell_deepcopy(
ur10e_gripper_one_beam, abb_irb4600_40_255_gripper_one_beam, abb_irb4600_40_255_printing_tool
):
"""Test to make sure copy.deepcopy works"""
robot_cell, robot_cell_state = RobotCellLibrary.ur10e_gripper_one_beam()
robot_cell_copy = deepcopy(robot_cell)

assert robot_cell.robot.name == robot_cell_copy.robot.name
assert robot_cell.tool_ids == robot_cell_copy.tool_ids
assert robot_cell.rigid_body_ids == robot_cell_copy.rigid_body_ids
def test(robot_cell, robot_cell_state):

robot_cell_copy = deepcopy(robot_cell)
assert robot_cell.robot.name == robot_cell_copy.robot.name
assert robot_cell.tool_ids == robot_cell_copy.tool_ids
assert robot_cell.rigid_body_ids == robot_cell_copy.rigid_body_ids

robot_cell_state_copy = deepcopy(robot_cell_state)
assert robot_cell_state.tool_ids == robot_cell_state_copy.tool_ids
assert robot_cell_state.rigid_body_ids == robot_cell_state_copy.rigid_body_ids

robot_cell_state_copy = deepcopy(robot_cell_state)
assert robot_cell_state.tool_ids == robot_cell_state_copy.tool_ids
assert robot_cell_state.rigid_body_ids == robot_cell_state_copy.rigid_body_ids
test(*ur10e_gripper_one_beam)
test(*abb_irb4600_40_255_gripper_one_beam)
test(*abb_irb4600_40_255_printing_tool)


if __name__ == "__main__":
test_copy_robot()
# TODO: test remaining functions within RobotCell

0 comments on commit ab29b38

Please sign in to comment.