The Robotics Application Manager (RAM) is an advanced manager for executing robotic applications. It operates as a state machine, managing the lifecycle of robotic applications from initialization to termination.
The Manager
class is the core of RAM, orchestrating operations and managing transitions between various application states.
- States:
idle
: The initial state, waiting for a connection.connected
: Connected and ready to initiate processes.world_ready
: The world environment is set up and ready.visualization_ready
: Visualization tools are prepared and ready.application_running
: A robotic application is actively running.paused
: The application is paused.
- Transitions:
connect
: Moves fromidle
toconnected
.launch_world
: Initiates the world setup fromconnected
.prepare_visualization
: Prepares the visualization tools inworld_ready
.run_application
: Starts the application invisualization_ready
orpaused
.pause
: Pauses the running application.resume
: Resumes a paused application.terminate
: Stops the application and goes back tovisualization_ready
.stop
: Completely stops the application.disconnect
: Disconnects from the current session and returns toidle
.
on_connect(self, event)
: Manages the transition to the 'connected' state.on_launch_world(self, event)
: Prepares and launches the robotic world.on_prepare_visualization(self, event)
: Sets up visualization tools.on_run_application(self, event)
: Executes the robotic application.on_pause(self, msg)
: Pauses the running application.on_resume(self, msg)
: Resumes the paused application.on_terminate(self, event)
: Terminates the running application.on_disconnect(self, event)
: Handles disconnection and cleanup.- Exception Handling: Details how specific errors are managed in each method.
- Message Queue Integration:
ManagerConsumer
puts received messages intomanager_queue
forManager
to process. - State Updates and Commands:
Manager
sends state updates or commands to the client throughManagerConsumer
. - Client Connection Handling:
Manager
relies onManagerConsumer
for client connection and disconnection handling. - Error Handling:
ManagerConsumer
communicates exceptions back to the client andManager
. - Lifecycle Management:
Manager
controls the start and stop of theManagerConsumer
WebSocket server.
- World Initialization and Launching:
Manager
initializesLauncherWorld
with specific configurations, such as world type (e.g.,gazebo
,drones
) and the launch file path. - Dynamic Module Management:
LauncherWorld
dynamically launches modules based on the world configuration and ROS version, as dictated byManager
. - State Management and Transition: The state of
Manager
is updated in response to the actions performed byLauncherWorld
. For example, once the world is ready,Manager
may transition to theworld_ready
state. - Termination and Cleanup:
Manager
can instructLauncherWorld
to terminate the world environment through itsterminate
method.LauncherWorld
ensures a clean and orderly shutdown of all modules and resources involved in the world setup. - Error Handling and Logging:
Manager
handles exceptions and errors that may arise during the world setup or termination processes, ensuring robust operation.
- Visualization Setup:
Manager
initializesLauncherVisualization
with a specific visualization configuration, which can include types likeconsole
,gazebo_gra
,gazebo_rae
, etc. - Module Launching for Visualization:
LauncherVisualization
dynamically launches visualization modules based on the configuration provided byManager
. - State Management and Synchronization: Upon successful setup of the visualization tools,
Manager
can update its state (e.g., tovisualization_ready
) to reflect the readiness of the visualization environment. - Termination of Visualization Tools:
Manager
can instructLauncherVisualization
to terminate the current visualization setup using itsterminate
method. - Error Handling and Logging:
Manager
is equipped to manage exceptions and errors that might occur during the setup or termination of visualization tools.
- Application Execution:
Manager
initiates theapplication_process
when transitioning to theapplication_running
state. - Application Configuration and Launching: Before launching the
application_process
,Manager
configures the necessary parameters. - Process Management:
Manager
monitors and controls theapplication_process
. - Error Handling and Logging:
Manager
is responsible for handling any errors or exceptions that occur during the execution of theapplication_process
. - State Synchronization: The state of the
application_process
is closely synchronized with the state machine inManager
.
- Dedicated WebSocket Server for GUI Updates:
Server
is used exclusively for RoboticsAcademy applications that require real-time interaction with a web-based GUI. - Client Communication for GUI Module: For RoboticsAcademy applications with a GUI module,
Server
handles incoming and outgoing messages. - Real-time Interaction and Feedback:
Server
allows for real-time feedback and interaction within the browser-based GUI. - Conditional Operation Based on Application Type:
Manager
initializes and controlsServer
based on the specific needs of the RoboticsAcademy application being executed. - Error Handling and Logging:
Manager
ensures robust error handling forServer
.
-
Connecting to RAM:
- Initially, the RAM is in the
idle
state. - A client (e.g., a user interface or another system) connects to RAM, triggering the
connect
transition and moving RAM to theconnected
state.
- Initially, the RAM is in the
-
Launching the World:
- Once connected, the client can request RAM to launch a robotic world by sending a
launch_world
command. - RAM transitions to the
world_ready
state after successfully setting up the world environment.
- Once connected, the client can request RAM to launch a robotic world by sending a
-
Setting Up Visualization:
- After the world is ready, the client requests RAM to prepare the visualization tools with a
prepare_visualization
command. - RAM transitions to the
visualization_ready
state, indicating that visualization tools are set up and ready.
- After the world is ready, the client requests RAM to prepare the visualization tools with a
-
Running an Application:
- The client then requests RAM to run a specific robotic application, moving RAM into the
application_running
state. - The application executes, and RAM handles its process management, including monitoring and error handling.
- The client then requests RAM to run a specific robotic application, moving RAM into the
-
Pausing and Resuming Application:
- The client can send
pause
andresume
commands to RAM to control the application's execution. - RAM transitions to the
paused
state when paused and returns toapplication_running
upon resumption.
- The client can send
-
Stopping the Application:
- Finally, the client can send a
stop
command to halt the application. - RAM stops the application and transitions back to the
visualization_ready
state, ready for new commands.
- Finally, the client can send a
-
Disconnecting:
- Once all tasks are completed, the client can disconnect from RAM, which then returns to the
idle
state, ready for a new session.
- Once all tasks are completed, the client can disconnect from RAM, which then returns to the