Skip to content

Commit

Permalink
Fix code generator for bridges launch
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-nhg committed May 15, 2024
1 parent 7f82fbf commit 89480a8
Showing 1 changed file with 53 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
])
'''
}

0 comments on commit 89480a8

Please sign in to comment.