fsm_multiple


Overview

The fsm_multiple application manages multiple finite state machines (FSMs) that control the robot’s behavior, such as localization, navigation, and interaction with different environments like the living room, studio, and bedroom. It uses FSMs to decide the robot’s next actions and transitions between them based on predefined states.

Execution

The application can be executed with the following command:

python3 fsm_multiple/ --auto-run

The application will initialize the main task FSM, which includes states for localization, navigation, and interaction. Based on the current state, it may call other FSMs, such as LIVING_ROOM, STUDIO, and BEDROOM, and transitions between these states until it finishes.

States in Main Task FSM

The main FSM of the application includes the following states:

  • LOCALIZING: Checks if the robot is localized and has the correct map. If not, it updates the map and asks the user to localize the robot.

  • NAV_TO_HOME: Once the robot is localized, it navigates to a predefined home location.

  • IDLE: Displays an interface on the chest, allowing the user to select the next task.

  • LIVING_ROOM: Starts the LIVING_ROOM FSM.

  • STUDIO: Starts the STUDIO FSM.

  • BEDROOM: Starts the BEDROOM FSM.

  • GOODBYE: Finishes the application.

  • NAV_ERROR: If an error occurs while navigating to home, it displays an error message on the chest and terminates the application.

  • END: Marks the end of the FSM.

States in LIVING_ROOM FSM

The LIVING_ROOM FSM includes the following states:

  • NAV_TO_LIVING_ROOM: Navigates to the living room point.

  • INSPECT: Rotates 360 degrees to inspect the room.

  • CELEBRATE: Displays a celebration message on the chest and plays a sound.

  • NAV_TO_HOME: Navigates back to the home location.

  • NAV_ERROR: If the robot can’t go home, it asks the user on the chest whether they want to try another FSM.

  • END: Marks the end of the LIVING_ROOM FSM.

States in STUDIO FSM

The STUDIO FSM includes the following states:

  • NAV_TO_STUDIO: Navigates to the studio point.

  • LOOK_FOR_NOTEBOOK: Displays a message on the chest saying it is looking for a notebook.

  • ANALYZE: Displays a message on the chest saying it is analyzing the situation.

  • NAV_TO_HOME: Navigates back to the home location.

  • NAV_ERROR: If the robot can’t go home, it asks the user on the chest whether they want to try another FSM.

  • END: Marks the end of the STUDIO FSM.

States in BEDROOM FSM

The BEDROOM FSM includes the following states:

  • NAV_TO_BEDROOM: Navigates to the bedroom point.

  • SLEEP: Displays a message on the chest saying the robot is sleeping and shows a button to wake it up.

  • NAV_TO_HOME: If the user wakes up the robot, it navigates back to the home location.

  • NAV_ERROR: If the robot can’t go home, it asks the user on the chest whether they want to try another FSM.

  • END: Marks the end of the BEDROOM FSM.

Behavior

  • The application starts by initializing the main task FSM, which transitions through various states such as LOCALIZING, NAV_TO_HOME, and IDLE.

  • If the robot is localized and navigates to home, it will proceed to show the IDLE state, allowing the user to select the next task.

  • The robot can be sent to different environments, such as the living room, studio, or bedroom, where the corresponding FSM is triggered.

  • Each environment FSM includes states for navigation, tasks specific to the environment (e.g., inspecting the living room, analyzing the studio), and handling navigation errors.

  • After completing any environment FSM, the robot returns to the IDLE state in the main FSM.

  • If the robot encounters navigation errors, it will prompt the user with a question on the chest, asking if they want to try another FSM.

Inputs

  • User input for FSM selection: The user selects the next FSM to execute (living room, studio, bedroom).

  • Navigation errors: If navigation fails the app asks if the user wants to try another FSM.

Outputs

  • The application logs transitions between states and FSMs.

  • Displays a chest interface for user input and notifications.

  • Executes tasks such as navigation and environment-specific actions.

Example Logs

# python3 fsm_multiple/ --auto-run
[INFO] [timestamp] [pyraya.fsm_multiple]: Auto running the app
[INFO] [timestamp] [pyraya.fsm.main_task]: Initializing FSM
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition:  -> LOCALIZING
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition: LOCALIZING -> NAV_TO_HOME
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition: NAV_TO_HOME -> IDLE
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition: IDLE -> LIVING_ROOM
[INFO] [timestamp] [pyraya.fsm.living_room]: Initializing FSM
...
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition: LIVING_ROOM -> IDLE
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition: IDLE -> STUDIO
[INFO] [timestamp] [pyraya.fsm.studio]: Initializing FSM
...
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition: STUDIO -> IDLE
[INFO] [timestamp] [pyraya.fsm.main_task]: Transition: IDLE -> GOODBYE
[INFO] [timestamp] [pyraya.fsm.main_task]: Application finished