append spawn objects
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user