|
|
@@ -4,20 +4,33 @@ from robot_control.src.robot.controller import RobotController, Cell, CellStatus
|
|
|
from robot_control.src.utils.config import ConfigParser
|
|
|
from robot_control.src.api.grbl_handler import GRBLHandler
|
|
|
from robot_control.src.api.gpio import MockGPIO
|
|
|
+import asyncio
|
|
|
|
|
|
@pytest.fixture
|
|
|
def robot_movement():
|
|
|
config = ConfigParser().config
|
|
|
grbl = config.grbl
|
|
|
+ grbl.port = "debug"
|
|
|
grbl_handler = GRBLHandler(grbl.port, grbl.baudrate)
|
|
|
return RobotMovement(config.movement, grbl_handler)
|
|
|
|
|
|
@pytest.fixture
|
|
|
def robot_controller():
|
|
|
config = ConfigParser().config
|
|
|
+ config.grbl.port = "debug"
|
|
|
config.mqtt.broker = "debug" # connects to test mqtt broker
|
|
|
mock_gpio = MockGPIO()
|
|
|
- controller = RobotController(config, gpio_handler=mock_gpio)
|
|
|
+ feeder_queue = asyncio.Queue(config.feeder.max_capacity)
|
|
|
+ defeeder_queue = asyncio.Queue(config.defeeder.max_capacity)
|
|
|
+ controller = RobotController(
|
|
|
+ config,
|
|
|
+ gpio_handler=mock_gpio,
|
|
|
+ i2c=None,
|
|
|
+ vision=None,
|
|
|
+ pump_controller=None,
|
|
|
+ feeder_queue=feeder_queue,
|
|
|
+ defeeder_queue=defeeder_queue
|
|
|
+ )
|
|
|
return controller
|
|
|
|
|
|
class TestRobotMovement:
|
|
|
@@ -28,11 +41,12 @@ class TestRobotMovement:
|
|
|
@pytest.mark.asyncio
|
|
|
async def test_set_speed(self, robot_movement: RobotMovement):
|
|
|
await robot_movement.grbl.connect()
|
|
|
- await robot_movement.set_speed(200.0)
|
|
|
- assert robot_movement.speed == 200.0
|
|
|
+ speed_mmin = 400
|
|
|
+ await robot_movement.set_speed(speed_mmin)
|
|
|
+ assert robot_movement.default_speed_mmmin == speed_mmin
|
|
|
|
|
|
with pytest.raises(ValueError):
|
|
|
- await robot_movement.set_speed(-100.0)
|
|
|
+ await robot_movement.set_speed(-400)
|
|
|
|
|
|
# TODO [SG]: Getting current position currently does not work in debug mode
|
|
|
@pytest.mark.asyncio
|
|
|
@@ -66,8 +80,9 @@ class TestRobotController:
|
|
|
@pytest.mark.asyncio
|
|
|
async def test_insert_and_pick_cell(self, robot_controller: RobotController):
|
|
|
# Test cell insertion
|
|
|
- cell = Cell(id="test_cell", status=CellStatus.WAITING)
|
|
|
+ cell = Cell(id=1234, status=CellStatus.WAITING)
|
|
|
slot = robot_controller.get_next_free_slot()
|
|
|
+ assert slot is not None
|
|
|
robot_controller.gripper_occupied = True
|
|
|
|
|
|
await robot_controller.insert_cell_to_slot(cell, slot)
|
|
|
@@ -83,7 +98,7 @@ class TestRobotController:
|
|
|
@pytest.mark.asyncio
|
|
|
async def test_sort_empty_gripper(self, robot_controller: RobotController):
|
|
|
cell = Cell(
|
|
|
- id="test_cell",
|
|
|
+ id=1234,
|
|
|
status=CellStatus.COMPLETED,
|
|
|
capacity=3000.0
|
|
|
)
|
|
|
@@ -104,7 +119,7 @@ class TestRobotController:
|
|
|
async def test_sort_cell_by_capacity(self, robot_controller: RobotController):
|
|
|
# Test sorting a cell with capacity that matches a grade
|
|
|
cell = Cell(
|
|
|
- id="test_cell",
|
|
|
+ id=0,
|
|
|
status=CellStatus.COMPLETED,
|
|
|
capacity=3000.0
|
|
|
)
|
|
|
@@ -114,7 +129,7 @@ class TestRobotController:
|
|
|
|
|
|
# Test sorting a cell with capacity that doesn't match any grade
|
|
|
low_cap_cell = Cell(
|
|
|
- id="low_cap_cell",
|
|
|
+ id=1234,
|
|
|
status=CellStatus.COMPLETED,
|
|
|
capacity=0.0
|
|
|
)
|