1+ """LauncherRobot module for managing robot launchers in different simulation worlds."""
2+
13from typing import Optional
24from pydantic import BaseModel
35
6668
6769
6870class LauncherRobot (BaseModel ):
71+ """Class for managing robot launchers in different simulation worlds."""
72+
6973 world : str
7074 launch_file_path : str
7175 module : str = "." .join (__name__ .split ("." )[:- 1 ])
@@ -74,7 +78,8 @@ class LauncherRobot(BaseModel):
7478 start_pose : Optional [list ] = []
7579
7680 def run (self , start_pose = None ):
77- if start_pose != None :
81+ """Run the robot launcher with an optional start pose."""
82+ if start_pose is not None :
7883 self .start_pose = start_pose
7984 for module in worlds [self .world ][str (self .ros_version )]:
8085 module ["launch_file" ] = self .launch_file_path
@@ -83,13 +88,16 @@ def run(self, start_pose=None):
8388 LogManager .logger .info (self .launchers )
8489
8590 def terminate (self ):
91+ """Terminate all robot launchers and clear the launchers list."""
8692 LogManager .logger .info ("Terminating robot launcher" )
8793 if self .launchers :
8894 for launcher in self .launchers :
8995 launcher .terminate ()
9096 self .launchers = []
9197
9298 def launch_module (self , configuration ):
99+ """Launch a robot module based on the provided configuration."""
100+
93101 def process_terminated (name , exit_code ):
94102 LogManager .logger .info (
95103 f"LauncherEngine: { name } exited with code { exit_code } "
@@ -98,17 +106,24 @@ def process_terminated(name, exit_code):
98106 self .terminated_callback (name , exit_code )
99107
100108 launcher_module_name = configuration ["module" ]
101- launcher_module = f"{ self .module } .launcher_{ launcher_module_name } .Launcher{ class_from_module (launcher_module_name )} "
109+ launcher_module = (
110+ f"{ self .module } .launcher_{ launcher_module_name } ."
111+ f"Launcher{ class_from_module (launcher_module_name )} "
112+ )
102113 launcher_class = get_class (launcher_module )
103114 launcher = launcher_class .from_config (launcher_class , configuration )
104115
105116 launcher .run (self .start_pose , process_terminated )
106117 return launcher
107118
108119 def launch_command (self , configuration ):
120+ """Launch a robot command based on the provided configuration."""
109121 pass
110122
111123
112124class LauncherRobotException (Exception ):
125+ """Exception class for errors related to LauncherRobot."""
126+
113127 def __init__ (self , message ):
128+ """Initialize the LauncherRobotException with a message."""
114129 super (LauncherRobotException , self ).__init__ (message )
0 commit comments