import json import asynctest from asynctest import patch from common.utils import logger_create from tasks import tasks from app.state_machine.state_machine import StateMachine, SystemState from app.state_machine.state_machine_inputs import StateMachineInputs from app.log_store import LogStore from jetson_io.uart import LogPacket # Create a logger _LOGGER = logger_create(__name__, "unit_test") logging.disable(level=logging.DEBUG) _LOG_TEST_FUNC = lambda : _LOGGER.unit_test(inspect.stack()[1].function) class TestTask_ConsumeLoggingPackets(asynctest.TestCase): """ Tests the class StateMachine """ TEST_JSON_FILE = "test.json" TEST_JSON_CONTENTS = { "type" : { "info" : 0, "error" : 1, "status" : 2,
# Public libraries from enum import Enum from common.utils import logger_create _LOGGER = logger_create(__name__, "debug") class SystemState(Enum): """ Enumerates the different states of the state machine """ NAVIGATING_SIDEWALK = 0 # Still on the sidewalk LOOKING_FOR_PATH = 1 # Found house but looking for path to the door FOUND_PATH_TO_HOUSE = 2 # Found the path to door, need to pivot and start on it NAVIGATING_PATH = 3 # Going down the path to the door REACHED_DOOR = 4 # Got to the end of the path DELIVER_PACKAGE = 5 # Activate delivery actuators """ @purpose: Each of these functions are a callback for the state machine Each function is given the current state and all the potential inputs """ async def _navigating_sidewalk_state_callback(current_state, state_inputs): _LOGGER.debug("navigating_sidewalk_state_callback") if state_inputs.found_house: return SystemState.LOOKING_FOR_PATH else: