""" rbs_bt_web ROS 2 launch program for Robossembler ```bash ros2 launch rbs_bt_executor rbs_bt_web.launch.py bt_path:= @shalenikol release 0.1 @shalenikol release 0.2 BT v.4 @shalenikol release 0.3 bt_path = os.path.dirname(bt_path) @shalenikol release 0.4 bt_path : either name of BT-file or path to default BT-file """ import os from launch import LaunchDescription from launch_ros.actions import Node from launch.actions import DeclareLaunchArgument, OpaqueFunction, RegisterEventHandler from launch.substitutions import LaunchConfiguration from launch.event_handlers import OnExecutionComplete FILE_BT = "bt.xml" FILE_SKILLS = "skills.json" def launch_setup(context, *args, **kwargs): # Initialize Arguments bt_path = LaunchConfiguration("bt_path") bt_path = bt_path.perform(context) if bt_path[-4:] == ".xml": bt_file = bt_path skills_file = os.path.join(os.path.dirname(bt_path), FILE_SKILLS) else: bt_file = os.path.join(bt_path, FILE_BT) skills_file = os.path.join(bt_path, FILE_SKILLS) # rbs_bt = Node( # package = "rbs_bt_executor", # executable = "rbs_bt_executor", # parameters = [ # { # "plugins": ["rbs_bt_executor/bt_plugins"] # # "behavior_trees": [bt_path] # } # ] # ) bt_exec = Node( package="rbs_bt_executor", executable="bt_exec", arguments=[bt_file] # prefix=['gdbserver localhost:3000'], ) bt_param = Node( package="rbs_bt_executor", executable="bt_param.py", parameters=[{"bt_path": skills_file}] ) return [ RegisterEventHandler( event_handler=OnExecutionComplete( target_action=bt_param, on_completion=[bt_exec], # on_completion=[rbs_bt, bt_exec], ) ), bt_param ] # the order of elements is strictly required def generate_launch_description(): declared_arguments = [] declared_arguments.append( DeclareLaunchArgument( "bt_path", default_value="''", description="path to Behavior tree instance" ) ) return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)])