append spawn objects

This commit is contained in:
Даниил Грабарь
2026-09-18 12:37:28 +10:00
parent 9dc1073f42
commit b1b8cedef1
26 changed files with 124049 additions and 77 deletions
@@ -1,4 +1,5 @@
import json
from dataclasses import asdict
from launch_ros.actions import Node
from webots_ros2_driver.webots_controller import WebotsController
@@ -7,12 +8,23 @@ from iiwa_utils.camera_spawner import load_camera_config, build_ros_urdf # type
def make_simulation_nodes(settings) -> list:
"""Возвращает ноды камер для симуляции: [camera_spawner, *camera_controllers].
Если камеры не заданы в настройках — возвращает пустой список.
"""
"""Create the configured object spawner and camera nodes for Webots."""
nodes = []
webots = settings.digital_twin.webots
if webots.objects.enabled and webots.objects.count:
nodes.append(Node(
package="iiwa_utils",
executable="object_spawner",
name="object_spawner",
output="screen",
parameters=[{
"objects_config": json.dumps(asdict(webots.objects)),
"robot_translation": webots.transform,
"robot_rotation": webots.rotation,
}],
))
if not settings.digital_twin.webots.cameras:
return []
return nodes
camera_spawner = Node(
package="iiwa_utils",
@@ -37,4 +49,4 @@ def make_simulation_nodes(settings) -> list:
respawn=True,
))
return [camera_spawner, *camera_controllers]
return [*nodes, camera_spawner, *camera_controllers]