Files
motorDriverTests/tests/move.py
2025-07-23 16:23:30 +02:00

53 lines
1.6 KiB
Python
Executable File

import time
def move_to_low_limit_switch(motor):
low_limit = motor.limits()[0]
motor.move_and_wait(low_limit)
assert motor.at_target()
# Field is currently not set in our drivers
#assert motor.read_field('lowlimitswitch') == 1
assert not motor.has_error()
def move_to_high_limit_switch(motor):
low_limit = motor.limits()[1]
motor.move_and_wait(low_limit)
assert motor.at_target()
# Field is currently not set in our drivers
#assert motor.read_field('highlimitswitch') == 1
assert not motor.has_error()
def move_while_move(motor, first_target, second_target):
"""
Start moving to a position which is sufficiently far away, then interrupt
this move command with another move command. This function assumes a
sufficiently large distance between the current motor position and
first_target so it has enough time to issue the second move command.
"""
motor.write_field('writepv', first_target)
time.sleep(2)
motor.move_and_wait(second_target)
assert motor.at_target()
assert not motor.has_error()
def stop_then_move(motor, target):
motor.write_field('stop', 1)
motor.write_field('writepv', target)
def stop(motor, target):
"""
Stop an motor while it is moving to a target. This function assumes a
sufficiently large distance between the current motor position and target.
"""
motor.write_field('writepv', target)
time.sleep(1)
motor.write_field('stop', 1)
motor.wait_for_done()
assert not motor.at_target(target)
assert not motor.has_error()