def _create_model(): joints = [ Joint('joint_x', 'prismatic', parent='rfl', child='bridge'), Joint('joint_y', 'prismatic', parent='bridge', child='vertical'), Joint('joint_z', 'prismatic', parent='vertical', child='base_link'), Joint('joint_1', 'revolute', parent='base_link', child='link_1'), Joint('joint_2', 'revolute', parent='link_1', child='link_2'), Joint('joint_3', 'revolute', parent='link_2', child='link_3'), Joint('joint_4', 'revolute', parent='link_3', child='link_4'), Joint('joint_5', 'revolute', parent='link_4', child='link_5'), Joint('joint_6', 'revolute', parent='link_5', child='link_6'), ] links = [ Link('rfl'), Link('bridge'), Link('vertical'), Link('base_link'), Link('link_1'), Link('link_2'), Link('link_3'), Link('link_4'), Link('link_5'), Link('link_6'), ] return joints, links
def test_mimic_calculate_position(): multiplier = 5.0 offset = 100. j1 = Joint('j1', 'prismatic', None, None, axis=Axis('1 0 0')) j1.position = 200 mimic = Mimic(j1, multiplier=multiplier, offset=offset) result = mimic.calculate_position(j1.position) assert result == multiplier * j1.position + offset
def ur5(): """Return a UR5 created programatically instead of from a file.""" return RobotModel('ur5', joints=[ Joint('shoulder_pan_joint', 'revolute', 'base_link', 'shoulder_link'), Joint('shoulder_lift_joint', 'revolute', 'shoulder_link', 'upper_arm_link'), Joint('elbow_joint', 'revolute', 'upper_arm_link', 'forearm_link'), Joint('wrist_1_joint', 'revolute', 'forearm_link', 'wrist_1_link'), Joint('wrist_2_joint', 'revolute', 'wrist_1_link', 'wrist_2_link'), Joint('wrist_3_joint', 'revolute', 'wrist_2_link', 'wrist_3_link'), ], links=[ Link('base_link'), Link('shoulder_link'), Link('upper_arm_link'), Link('forearm_link'), Link('wrist_1_link'), Link('wrist_2_link'), Link('wrist_3_link'), ])
from compas.robots import RobotModel from compas.robots import Joint from compas.robots import Link robot = RobotModel('ur10e', joints=[ Joint('shoulder_pan_joint', 'revolute', parent='base_link', child='shoulder_link'), Joint('shoulder_lift_joint', 'revolute', parent='shoulder_link', child='upper_arm_link'), Joint('elbow_joint', 'revolute', parent='upper_arm_link', child='forearm_link'), Joint('wrist_1_joint', 'revolute', parent='forearm_link', child='wrist_1_link'), Joint('wrist_2_joint', 'revolute', parent='wrist_1_link', child='wrist_2_link'), Joint('wrist_3_joint', 'revolute', parent='wrist_2_link', child='wrist_3_link'), ],
def test_prismatic_calculate_transformation(): limit = Limit(lower=0, upper=1000) j1 = Joint('j1', 'prismatic', None, None, axis=Axis('1 0 0'), limit=limit) t = j1.calculate_transformation(550) assert t == Translation([550, 0, 0])
def test_revolute_calculate_transformation(): limit = Limit(lower=-2 * pi, upper=2 * pi) j1 = Joint('j1', 'revolute', None, None, limit=limit) transformation = j1.calculate_transformation(2*pi) assert transformation == Transformation()
def test_constructor_joint_type_guard_int(): with pytest.raises(ValueError): Joint("weld", 620, "base_metal1", "base_metal2")
def test_constructor_joint_type_guard_str(): with pytest.raises(ValueError): Joint("joint", "synovial", "femur", "tibia")
def test_constructor_joint_type_int(): assert Joint("joint", Joint.REVOLUTE, "parent_joint", "child_joint") assert Joint("joint", Joint.CONTINUOUS, "parent_joint", "child_joint") assert Joint("joint", Joint.PRISMATIC, "parent_joint", "child_joint") assert Joint("joint", Joint.FIXED, "parent_joint", "child_joint")
def test_constructor_joint_type_str(): assert Joint("joint", 'revolute', "parent_joint", "child_joint") assert Joint("joint", 'continuous', "parent_joint", "child_joint") assert Joint("joint", 'prismatic', "parent_joint", "child_joint") assert Joint("joint", 'fixed', "parent_joint", "child_joint")