diff --git a/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/generator/BridgesLaunchFileCompiler_ROS2.xtend b/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/generator/BridgesLaunchFileCompiler_ROS2.xtend index 95238df5..8b2ac5ef 100644 --- a/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/generator/BridgesLaunchFileCompiler_ROS2.xtend +++ b/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/generator/BridgesLaunchFileCompiler_ROS2.xtend @@ -12,7 +12,7 @@ class BridgesLaunchFileCompiler_ROS2 { import os from launch import LaunchDescription from launch_ros.actions import Node -from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument +from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument, ExecuteProcess from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration, PythonExpression, PathJoinSubstitution, TextSubstitution @@ -25,59 +25,61 @@ def generate_launch_description(): get_package_share_directory('«system.getName().toLowerCase»'), 'config', 'ros1_bridges.yaml' - )«ENDIF»«IF TopicBridgeGenerated(system)» - ros1_topic_bridge_parameter_bridge = Node( - package='ros1_bridge', - executable='parameter_bridge', - name='ros1_topic_bridge_parameter_bridge', - namespace='bridge_«system.name»_topics', - output='screen', - parameters=[ - {'__ns': 'bridge_«system.name»_topics'}, - {'__name': 'bridge_«system.name»_topics'} - ], - arguments=[ - '--ros-args', '-r', '__name:=bridge_«system.name»_topics' - ] - )«ENDIF»«IF ServiceFromBridgeGenerated(system)» - ros1_service_from_bridge_parameter_bridge = Node( - package='ros1_bridge', - executable='parameter_bridge', - name='ros1_service_from_bridge_parameter_bridge', - namespace='bridge_«system.name»_from_services', - output='screen', - parameters=[ - {'__ns': 'bridge_«system.name»_from_services'}, - {'__name': 'bridge_«system.name»_from_services'} - ], - arguments=[ - '--ros-args', '-r', '__name:=bridge_«system.name»_from_services' - ] - )«ENDIF»«IF ServiceToBridgeGenerated(system)» - ros1_service_to_bridge_parameter_bridge = Node( - package='ros1_bridge', - executable='parameter_bridge', - name='ros1_service_to_bridge_parameter_bridge', - namespace='bridge_«system.name»_to_services', - output='screen', - parameters=[ - {'__ns': 'bridge_«system.name»_to_services'}, - {'__name': 'bridge_«system.name»_to_services'} - ], - arguments=[ - '--ros-args', '-r', '__name:=bridge_«system.name»_to_services' - ] - )«ENDIF» + ) + + load_bridge_params = ExecuteProcess( + cmd=['rosparam', load, «system.name»_ros1_bridge_config] + ) + «ENDIF» - # *** Add actions *** «IF TopicBridgeGenerated(system)» - ld.add_action(ros1_topic_bridge_parameter_bridge) + ros1_topic_bridge_parameter_bridge = ExecuteProcess( + cmd=['ros2', 'run', 'ros1_bridge', 'parameter_bridge', '__ns:=bridge_«system.name»_topics', '__name:=ros1_topic_bridge_parameter_bridge'] «ENDIF»«IF ServiceFromBridgeGenerated(system)» - ld.add_action(ros1_service_from_bridge_parameter_bridge) - «ENDIF»«IF ServiceToBridgeGenerated(system)» - ld.add_action(ros1_service_to_bridge_parameter_bridge) - «ENDIF» + ros1_service_from_bridge_parameter_bridge = ExecuteProcess( + cmd=['ros2', 'run', 'ros1_bridge', 'parameter_bridge', '__ns:=bridge_«system.name»_from_services', '__name:=ros1_service_from_bridge_parameter_bridge'] +«ENDIF»«IF ServiceToBridgeGenerated(system)» + ros1_service_to_bridge_parameter_bridge = ExecuteProcess( + cmd=['ros2', 'run', 'ros1_bridge', 'parameter_bridge', '__ns:=bridge_«system.name»_to_services', '__name:=ros1_service_to_bridge_parameter_bridge'] +«ENDIF» + - return ld + return LaunchDescription([ + «IF TopicBridgeGenerated(system)» + RegisterEventHandler( + event_handler=OnExecutionComplete( + target_action=load_bridge_params, + on_completion=[ + LogInfo(msg='Load bridge parameter finished'), + LogInfo(msg='launching bridge for topics'), + ros1_topic_bridge_parameter_bridge, + LogInfo(msg='Start loading bridge parameters'), + load_bridge_params] + ) + ),«ENDIF»«IF ServiceFromBridgeGenerated(system)» + RegisterEventHandler( + event_handler=OnExecutionComplete( + target_action=load_bridge_params, + on_completion=[ + LogInfo(msg='Load bridge parameter finished'), + LogInfo(msg='Launching bridge for FROM services'), + ros1_service_from_bridge_parameter_bridge, + LogInfo(msg='Start loading bridge parameters'), + load_bridge_params] + ) + ),«ENDIF»«IF ServiceFromBridgeGenerated(system)» + RegisterEventHandler( + event_handler=OnExecutionComplete( + target_action=load_bridge_params, + on_completion=[ + LogInfo(msg='Load bridge parameter finished'), + LogInfo(msg='Launching bridge for TO services'), + ros1_service_to_bridge_parameter_bridge, + LogInfo(msg='Start loading bridge parameters'), + load_bridge_params] + ) + ),«ENDIF» + load_bridge_params + ]) ''' }