Ejemplo n.º 1
0
def speed_test(robot: MelfaRobot, speed: float) -> None:
    start = Coordinate([-150, -150, 400, 180, 0, 0], robot.AXES)  # pragma: no mutate
    vector = Coordinate([200, 300, -350, 0, 0, 0], robot.AXES)  # pragma: no mutate
    finish = start + vector  # pragma: no mutate

    # Back to start
    robot.protocol.reset_linear_speed()
    robot.linear_move_poll(start)

    # Test distance
    start_time = time.clock()
    t, v = robot.linear_move_poll(finish, speed * 60, track_speed=True)
    finish_time = time.clock()

    # Average velocity
    velocity = vector.vector_len() / (finish_time - start_time)

    # Draw speed
    draw_speed(speed, t, v)

    print("Velocity is: " + str(velocity))
Ejemplo n.º 2
0
 def test_vector_len_none(self):
     a = Coordinate([3, 2, None], "XYZ")
     with pytest.raises(TypeError):
         a.vector_len()
Ejemplo n.º 3
0
 def test_vector_len(self, axes, values, expected):
     a = Coordinate(values, axes)
     assert a.vector_len() == pytest.approx(expected, abs=0.01)