Skip to content

Commit 609ad8f

Browse files
committed
Adding world type for tools
1 parent c09d361 commit 609ad8f

5 files changed

Lines changed: 21 additions & 26 deletions

File tree

manager/libs/launch_world_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class ConfigurationModel(BaseModel):
9-
world: str
9+
type: str
1010
launch_file_path: str
1111

1212

manager/manager/launcher/launcher_robot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666

6767

6868
class LauncherRobot(BaseModel):
69-
world: str
69+
type: str
7070
launch_file_path: str
7171
module: str = ".".join(__name__.split(".")[:-1])
7272
ros_version: int = get_ros_version()
@@ -76,7 +76,7 @@ class LauncherRobot(BaseModel):
7676
def run(self, start_pose=None):
7777
if start_pose != None:
7878
self.start_pose = start_pose
79-
for module in worlds[self.world][str(self.ros_version)]:
79+
for module in worlds[self.type][str(self.ros_version)]:
8080
module["launch_file"] = self.launch_file_path
8181
launcher = self.launch_module(module)
8282
self.launchers.append(launcher)

manager/manager/launcher/launcher_tools.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,23 @@
4646
},
4747
}
4848

49+
simulator = {
50+
"gazebo": {"tool": "gazebo"},
51+
"gz": {"tool": "gzsim"},
52+
}
53+
4954

5055
class LauncherTools(BaseModel):
5156
module: str = ".".join(__name__.split(".")[:-1])
57+
world_type: str
5258
tools: list[str]
5359
tools_config: Optional[dict] = None
5460
launchers: Optional[ILauncher] = []
5561

5662
def run(self, consumer):
5763
for tool in self.tools:
64+
if tool == "simulator":
65+
tool = simulator[self.world_type]["tool"]
5866
module = tools[tool]
5967
launcher = self.launch_module(tool, module, consumer)
6068
self.launchers.append(launcher)

manager/manager/launcher/launcher_world.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,11 @@
1616
}
1717
],
1818
},
19-
"drones": {
19+
"gz": {
2020
"2": [
2121
{
2222
"type": "module",
23-
"module": "drones_ros2",
24-
"resource_folders": [],
25-
"model_folders": [],
26-
"plugin_folders": [],
27-
"parameters": [],
28-
"launch_file": [],
29-
}
30-
],
31-
},
32-
"gzsimdrones": {
33-
"2": [
34-
{
35-
"type": "module",
36-
"module": "drones_gzsim",
37-
"resource_folders": [],
38-
"model_folders": [],
39-
"plugin_folders": [],
23+
"module": "ros2_api",
4024
"parameters": [],
4125
"launch_file": [],
4226
}
@@ -47,14 +31,14 @@
4731

4832

4933
class LauncherWorld(BaseModel):
50-
world: str
34+
type: str
5135
launch_file_path: str
5236
module: str = ".".join(__name__.split(".")[:-1])
5337
ros_version: int = get_ros_version()
5438
launchers: Optional[ILauncher] = []
5539

5640
def run(self):
57-
for module in worlds[self.world][str(self.ros_version)]:
41+
for module in worlds[self.type][str(self.ros_version)]:
5842
module["launch_file"] = self.launch_file_path
5943
launcher = self.launch_module(module)
6044
self.launchers.append(launcher)

manager/manager/manager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def __init__(self, host: str, port: int):
188188
self.queue = Queue()
189189
self.consumer = ManagerConsumer(host, port, self.queue)
190190
self.world_launcher = None
191+
self.world_type = None
191192
self.robot_launcher = None
192193
self.tools_launcher = None
193194
self.application_process = None
@@ -270,7 +271,7 @@ def on_launch_world(self, event):
270271

271272
# Launch world
272273
try:
273-
if world_cfg["world"] == None:
274+
if world_cfg["type"] == None:
274275
self.world_launcher = None
275276
LogManager.logger.info("Launch transition finished")
276277
return
@@ -285,14 +286,16 @@ def on_launch_world(self, event):
285286
except ValueError as e:
286287
LogManager.logger.error(f"Configuration validation failed: {e}")
287288

289+
self.world_type = world_cfg["type"]
290+
288291
self.world_launcher = LauncherWorld(**cfg.model_dump())
289292
LogManager.logger.info(str(self.world_launcher))
290293
self.world_launcher.run()
291294
LogManager.logger.info("Launch transition finished")
292295

293296
# Launch robot
294297
try:
295-
if robot_cfg["world"] == None:
298+
if robot_cfg["type"] == None:
296299
self.robot_launcher = None
297300
LogManager.logger.info("Launch transition finished")
298301
return
@@ -346,7 +349,7 @@ def on_prepare_tools(self, event):
346349
tools = cfg_dict["tools"]
347350
config = cfg_dict["config"]
348351

349-
self.tools_launcher = LauncherTools(tools=tools, tools_config=config)
352+
self.tools_launcher = LauncherTools(world_type= self.world_type ,tools=tools, tools_config=config)
350353

351354
self.tools_launcher.run(self.consumer)
352355
LogManager.logger.info("Tools transition finished")

0 commit comments

Comments
 (0)