fix unit tests
This commit is contained in:
@@ -50,9 +50,15 @@ def test_robot(tmpdir, request, robot_type, mock):
|
|||||||
# TODO(rcadene): add compatibility with other robots
|
# TODO(rcadene): add compatibility with other robots
|
||||||
from lerobot.common.robot_devices.robots.manipulator import ManipulatorRobot
|
from lerobot.common.robot_devices.robots.manipulator import ManipulatorRobot
|
||||||
|
|
||||||
# Save calibration preset
|
if robot_type == "aloha" and mock:
|
||||||
tmpdir = Path(tmpdir)
|
# To simplify unit test, we do not rerun manual calibration for Aloha mock=True.
|
||||||
calibration_dir = tmpdir / robot_type
|
# Instead, we use the files from '.cache/calibration/aloha_default'
|
||||||
|
overrides_calibration_dir = None
|
||||||
|
else:
|
||||||
|
# Create an empty calibration directory to trigger manual calibration
|
||||||
|
tmpdir = Path(tmpdir)
|
||||||
|
calibration_dir = tmpdir / robot_type
|
||||||
|
overrides_calibration_dir = [f"calibration_dir={calibration_dir}"]
|
||||||
|
|
||||||
# Test connecting without devices raises an error
|
# Test connecting without devices raises an error
|
||||||
robot = ManipulatorRobot()
|
robot = ManipulatorRobot()
|
||||||
@@ -76,9 +82,9 @@ def test_robot(tmpdir, request, robot_type, mock):
|
|||||||
# Test deleting the object without connecting first
|
# Test deleting the object without connecting first
|
||||||
del robot
|
del robot
|
||||||
|
|
||||||
# Test connecting
|
# Test connecting (triggers manual calibration)
|
||||||
robot = make_robot(robot_type, overrides=[f"calibration_dir={calibration_dir}"])
|
robot = make_robot(robot_type, overrides=overrides_calibration_dir)
|
||||||
robot.connect() # run the manual calibration precedure
|
robot.connect()
|
||||||
assert robot.is_connected
|
assert robot.is_connected
|
||||||
|
|
||||||
# Test connecting twice raises an error
|
# Test connecting twice raises an error
|
||||||
@@ -89,8 +95,9 @@ def test_robot(tmpdir, request, robot_type, mock):
|
|||||||
del robot
|
del robot
|
||||||
|
|
||||||
# Test teleop can run
|
# Test teleop can run
|
||||||
robot = make_robot(robot_type, overrides=[f"calibration_dir={calibration_dir}"])
|
robot = make_robot(robot_type, overrides=overrides_calibration_dir)
|
||||||
robot.calibration_dir = calibration_dir
|
if overrides_calibration_dir is not None:
|
||||||
|
robot.calibration_dir = calibration_dir
|
||||||
robot.connect()
|
robot.connect()
|
||||||
robot.teleop_step()
|
robot.teleop_step()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user