def test_transform(default_rotation, robot_frame, asset_frame): with pytest.raises(ValueError): translation = Translation(1, 1, from_=robot_frame, to_=asset_frame) Transform(translation, rotation=default_rotation, from_=asset_frame, to_=robot_frame)
def test_transform_position_error(from_, to_, error_expected): p_robot = Positions.from_array( np.array([ [1, 2, 3], [-1, -2, -3], [0, 0, 0], [100000, 1, -100000], ], ), frame=Frame("robot"), ) euler = np.array([0, 0, 0]) translation = Translation(x=0, y=0, from_=Frame("robot"), to_=Frame("asset")) transform = Transform.from_euler_array(euler=euler, translation=translation, from_=Frame("robot"), to_=Frame("asset")) if error_expected: with pytest.raises(ValueError): transform.transform_position(p_robot, from_=from_, to_=to_) else: transform.transform_position(p_robot, from_=from_, to_=to_)
def test_no_transformation_when_equal_frames(): p_expected = Position.from_array(np.array([1, 2, 3]), frame=Frame("robot")) translation = Translation(x=2, y=3, from_=Frame("robot"), to_=Frame("asset")) transform = Transform.from_euler_array( euler=np.array([1.0, 0, 0]), translation=translation, from_=translation.from_, to_=translation.to_, ) p_robot = Position.from_array(np.array([1, 2, 3]), frame=Frame("robot")) position = transform.transform_position(p_robot, from_=Frame("robot"), to_=Frame("robot")) assert position.frame == p_expected.frame assert np.allclose(p_expected.to_array(), position.to_array())
def test_transform_without_rotation(): with pytest.raises(ValueError): translation = Translation(1, 1, from_="robot", to_="asset") Transform(translation=translation, from_="asset", to_="robot")
def test_transform(): with pytest.raises(ValueError): euler = Euler(from_="robot", to_="asset") translation = Translation(1, 1, from_="robot", to_="asset") Transform.from_euler_ZYX(translation, euler=euler, from_="asset", to_="robot")
def test_translation(): with pytest.raises(ValueError): Translation.from_array(np.array([1, 1]), from_="robot", to_="asset")
def test_translation_array(robot_frame, asset_frame): expected_array = np.array([1, 1, 1]) translation: Translation = Translation.from_array( expected_array, from_=robot_frame, to_=asset_frame ) assert np.allclose(expected_array, translation.to_array())
def test_translation_invalid_array(robot_frame, asset_frame): with pytest.raises(ValueError): Translation.from_array(np.array([1, 1]), from_=robot_frame, to_=asset_frame)
import numpy as np import pytest from alitra import AlignFrames, Euler, FrameTransform, PointList, Translation, Transform @pytest.mark.parametrize( "eul_rot, ref_translations, p_robot,rotation_axes", [ ( Euler(psi=np.pi * -0.0, from_="robot", to_="asset"), Translation(x=200030, y=10000, from_="robot", to_="asset"), PointList.from_array( np.array([ [10, 1, 0], [20, 2, 0], [30, 7, 0], [40, 5, 0], ]), frame="robot", ), "z", ), ( Euler(psi=np.pi / 2, from_="robot", to_="asset"), Translation(x=10, y=0, from_="robot", to_="asset"), PointList.from_array( np.array([[5, 0, 0], [5, 2, 0], [7, 5, 0], [3, 5, 0]]), frame="robot", ), "z",
def default_translation(robot_frame, asset_frame): return Translation(x=0, y=0, z=0, from_=robot_frame, to_=asset_frame)
translation = Translation(1, 1, from_=robot_frame, to_=asset_frame) Transform(translation=translation, from_=asset_frame, to_=robot_frame) import numpy as np import pytest from alitra import Frame, Orientation, Pose, Position, Positions, Transform, Translation @pytest.mark.parametrize( "euler_array, translation, expected_position", [ ( np.array([0, 0, 0]), Translation(x=0, y=0, from_=Frame("robot"), to_=Frame("asset")), Positions.from_array( np.array([ [1, 2, 3], [-1, -2, -3], [0, 0, 0], [100000, 1, -100000], ]), frame=Frame("asset"), ), ), ( np.array([np.pi * -0.0, 0, 0]), Translation(x=10, y=10, from_=Frame("robot"), to_=Frame("asset")), Positions.from_array( np.array([