Skip to content

Commit 98f80ec

Browse files
committed
Add start pose
1 parent 09511f1 commit 98f80ec

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ The `Manager` class is the core of RAM, orchestrating operations and managing tr
3939
- `terminate`: Stops the application and goes back to `visualization_ready`.
4040
- `stop`: Completely stops the application.
4141
- `disconnect`: Disconnects from the current session and returns to `idle`.
42+
- **Stateless Transitions**:
43+
- `style_check`: Triggers on_style_check.
44+
- `code_analysis`: Triggers on_code_analysis.
45+
- `code_format`: Triggers on_code_format.
46+
- `code_autocomplete`: Triggers on_code_autocomplete.
4247

4348
### Key Methods
4449

@@ -50,6 +55,10 @@ The `Manager` class is the core of RAM, orchestrating operations and managing tr
5055
- `on_resume(self, msg)`: Resumes the paused application.
5156
- `on_terminate(self, event)`: Terminates the running application.
5257
- `on_disconnect(self, event)`: Handles disconnection and cleanup.
58+
- `on_style_check(self, event)`: Check the style of the user code.
59+
- `on_code_analysis(self, event)`: Analyzes the style and format of the user code using pylint.
60+
- `on_code_format(self, event)`: Formats the user code using black.
61+
- `on_code_autocomplete(self, event)`: Searches for all available code completions using Jedi.
5362
- **Exception Handling**: Details how specific errors are managed in each method.
5463

5564
### Interactions with Other Components

manager/manager/launcher/launcher_robot.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ class LauncherRobot(BaseModel):
7171
module: str = ".".join(__name__.split(".")[:-1])
7272
ros_version: int = get_ros_version()
7373
launchers: Optional[ILauncher] = []
74+
start_pose: Optional[list] = []
7475

75-
def run(self):
76+
def run(self, start_pose = None):
77+
if (start_pose != None):
78+
self.start_pose = start_pose
7679
for module in worlds[self.world][str(self.ros_version)]:
7780
module["launch_file"] = self.launch_file_path
7881
launcher = self.launch_module(module)
@@ -98,7 +101,8 @@ def process_terminated(name, exit_code):
98101
launcher_module = f"{self.module}.launcher_{launcher_module_name}.Launcher{class_from_module(launcher_module_name)}"
99102
launcher_class = get_class(launcher_module)
100103
launcher = launcher_class.from_config(launcher_class, configuration)
101-
launcher.run(process_terminated)
104+
105+
launcher.run(self.start_pose, process_terminated)
102106
return launcher
103107

104108
def launch_command(self, configuration):

manager/manager/launcher/launcher_robot_ros2_api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LauncherRobotRos2Api(ILauncher):
1616
launch_file: str
1717
threads: List[Any] = []
1818

19-
def run(self, callback):
19+
def run(self, robot_pose, callback):
2020
DRI_PATH = self.get_dri_path()
2121
ACCELERATION_ENABLED = self.check_device(DRI_PATH)
2222

@@ -27,12 +27,14 @@ def run(self, callback):
2727
xserver_thread.start()
2828
self.threads.append(xserver_thread)
2929

30+
ROBOT_POSE = f"ROBOT_X={robot_pose[0]} ROBOT_Y={robot_pose[1]} ROBOT_Z={robot_pose[2]} ROBOT_ROLL={robot_pose[3]} ROBOT_PITCH={robot_pose[4]} ROBOT_YAW={robot_pose[5]}"
31+
3032
if ACCELERATION_ENABLED:
3133
exercise_launch_cmd = (
32-
f"export VGL_DISPLAY={DRI_PATH}; vglrun ros2 launch {self.launch_file}"
34+
f"export VGL_DISPLAY={DRI_PATH}; vglrun {ROBOT_POSE} ros2 launch {self.launch_file}"
3335
)
3436
else:
35-
exercise_launch_cmd = f"ros2 launch {self.launch_file}"
37+
exercise_launch_cmd = f"{ROBOT_POSE} ros2 launch {self.launch_file}"
3638

3739
exercise_launch_thread = DockerThread(exercise_launch_cmd)
3840
exercise_launch_thread.start()

manager/manager/manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def on_launch_world(self, event):
286286

287287
self.robot_launcher = LauncherRobot(**cfg.model_dump())
288288
LogManager.logger.info(str(self.robot_launcher))
289-
self.robot_launcher.run()
289+
self.robot_launcher.run(robot_cfg['start_pose'])
290290
LogManager.logger.info("Launch transition finished")
291291

292292
def prepare_custom_universe(self, cfg_dict):
@@ -760,7 +760,7 @@ def unpause_sim(self):
760760
def reset_sim(self):
761761
if self.robot_launcher:
762762
self.robot_launcher.terminate()
763-
763+
764764
if self.visualization_type in ["gzsim_rae", "bt_studio_gz"]:
765765
if self.is_ros_service_available("/drone0/platform/state_machine/_reset"):
766766
self.call_service("/drone0/platform/state_machine/_reset", "std_srvs/srv/Trigger", "{}")

0 commit comments

Comments
 (0)