def generate_launch_description(): synchronization = launch.substitutions.LaunchConfiguration('synchronization', default=False) red_1 = ControllerLauncher(package='controller', executable='controller', parameters=[{'synchronization': synchronization}], arguments=['red_1'], output='screen') red_2 = ControllerLauncher(package='controller', executable='controller', parameters=[{'synchronization': synchronization}], arguments=['red_2'], output='screen') blue_1 = ControllerLauncher(package='controller', executable='controller', parameters=[{'synchronization': synchronization}], arguments=['blue_1'], output='screen') blue_2 = ControllerLauncher(package='controller', executable='controller', parameters=[{'synchronization': synchronization}], arguments=['blue_2'], output='screen') supervisor = ControllerLauncher(package='controller', executable='supervisor', parameters=[{'synchronization': synchronization}], output='screen') return LaunchDescription([ red_1, red_2, blue_1, blue_2, supervisor ])
def generate_launch_description(): # Webots arguments = [ '--mode=realtime', '--world=' + os.path.join(get_package_share_directory('webots_ros2_demos'), 'worlds', 'armed_robots.wbt') ] webots = launch_ros.actions.Node(package='webots_ros2_core', node_executable='webots_launcher', arguments=arguments, output='screen') # Controller nodes synchronization = launch.substitutions.LaunchConfiguration( 'synchronization', default=False) AbbController = ControllerLauncher( package='webots_ros2_abb', node_executable='abb_driver', # this argument should match the 'name' field # of the robot in Webots arguments=['--webots-robot-name=abbirb4600'], node_namespace='abb', parameters=[{ 'synchronization': synchronization }], output='screen') Ure5controller = ControllerLauncher( package='webots_ros2_universal_robot', node_executable='universal_robot', # this argument should match the 'name' field # of the robot in Webots arguments=['--webots-robot-name=UR5e'], node_namespace='ur', parameters=[{ 'synchronization': synchronization }], output='screen') # Control nodes armedRobotsUr = ControllerLauncher(package='webots_ros2_demos', node_executable='armed_robots_ur', output='screen') armedRobotsAbb = ControllerLauncher(package='webots_ros2_demos', node_executable='armed_robots_abb', output='screen') return launch.LaunchDescription([ webots, AbbController, Ure5controller, armedRobotsUr, armedRobotsAbb, # Shutdown launch when Webots exits. launch.actions. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())], )), ])
def generate_launch_description(): webots = WebotsLauncher( world=os.path.join(get_package_share_directory('webots'), 'models/worlds', 'sim-robot.wbt')) synchronization = launch.substitutions.LaunchConfiguration( 'synchronization', default=False) red_1 = ControllerLauncher(package='controller', executable='controller', parameters=[{ 'synchronization': synchronization }], arguments=['red_1'], output='screen') red_2 = ControllerLauncher(package='controller', executable='controller', parameters=[{ 'synchronization': synchronization }], arguments=['red_2'], output='screen') blue_1 = ControllerLauncher(package='controller', executable='controller', parameters=[{ 'synchronization': synchronization }], arguments=['blue_1'], output='screen') blue_2 = ControllerLauncher(package='controller', executable='controller', parameters=[{ 'synchronization': synchronization }], arguments=['blue_2'], output='screen') supervisor = ControllerLauncher(package='controller', executable='supervisor', parameters=[{ 'synchronization': synchronization }], output='screen') return LaunchDescription([ webots, red_1, red_2, blue_1, blue_2, supervisor, Node(package='params', executable='params'), Node(package='motion', executable='motion', arguments=['red_1']), Node(package='motion', executable='motion', arguments=['red_2']), Node(package='motion', executable='motion', arguments=['blue_1']), Node(package='motion', executable='motion', arguments=['blue_2']), launch.actions. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())], )) ])
def generate_launch_description(): # Webots webots = WebotsLauncher( world=os.path.join(get_package_share_directory('webots_ros2_examples'), 'worlds', 'ros_example.wbt')) # Controller node synchronization = launch.substitutions.LaunchConfiguration( 'synchronization', default=False) controller = ControllerLauncher(package='webots_ros2_examples', node_executable='example_controller', parameters=[{ 'synchronization': synchronization }], output='screen') return launch.LaunchDescription([ webots, controller, # Shutdown launch when Webots exits. launch.actions. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())], )), ])
def generate_launch_description(): # Webots arguments = [ '--mode=realtime', '--world=' + os.path.join( get_package_share_directory('webots_ros2_universal_robot'), 'worlds', 'universal_robot.wbt') ] webots = launch_ros.actions.Node(package='webots_ros2_core', node_executable='webots_launcher', arguments=arguments, output='screen') # Controller node synchronization = launch.substitutions.LaunchConfiguration( 'synchronization', default=False) controller = ControllerLauncher(package='webots_ros2_universal_robot', node_executable='universal_robot', parameters=[{ 'synchronization': synchronization }], output='screen') return launch.LaunchDescription([ webots, controller, # Shutdown launch when Webots exits. launch.actions. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())], )), ])
def generate_launch_description(): synchronization = LaunchConfiguration('synchronization') package = LaunchConfiguration('package') executable = LaunchConfiguration('executable') world = LaunchConfiguration('world') gui = LaunchConfiguration('gui') mode = LaunchConfiguration('mode') publish_tf = LaunchConfiguration('publish_tf') node_parameters = LaunchConfiguration('node_parameters') robot_name = LaunchConfiguration('robot_name') node_name = LaunchConfiguration('node_name') use_sim_time = LaunchConfiguration('use_sim_time') # Webots webots = WebotsLauncher(world=world, mode=mode, gui=gui) # Driver node controller = ControllerLauncher( package=package, executable=executable, parameters=[ node_parameters, { 'synchronization': synchronization, 'use_joint_state_publisher': publish_tf } ], output='screen', arguments=[ '--webots-robot-name', robot_name, '--webots-node-name', node_name ], ) # Robot state publisher robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[{ 'robot_description': '<robot name=""><link name=""/></robot>', 'use_sim_time': use_sim_time }], condition=launch.conditions.IfCondition(publish_tf)) return LaunchDescription(ARGUMENTS + [ robot_state_publisher, webots, controller, # Shutdown launch when Webots exits. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[EmitEvent(event=launch.events.Shutdown())], )) ])
def generate_launch_description(): # Webots webots = WebotsLauncher(world=os.path.join( get_package_share_directory('webots_ros2_universal_robot'), 'worlds', 'universal_robot_multiple.wbt')) # Controller nodes synchronization = launch.substitutions.LaunchConfiguration( 'synchronization', default=False) ure3_controller = ControllerLauncher( package='webots_ros2_core', executable='webots_robotic_arm_node', arguments=['--webots-robot-name=UR3e'], namespace='UR3e', parameters=[{ 'synchronization': synchronization }], output='screen') ure5_controller = ControllerLauncher( package='webots_ros2_core', executable='webots_robotic_arm_node', arguments=['--webots-robot-name=UR5e'], namespace='UR5e', parameters=[{ 'synchronization': synchronization }], output='screen') return launch.LaunchDescription([ webots, ure3_controller, ure5_controller, # Shutdown launch when Webots exits. launch.actions. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())], )), ])
def generate_launch_description(): # Webots arguments = [ '--mode=realtime', '--world=' + os.path.join(get_package_share_directory('webots_ros2_epuck'), 'worlds', 'epuck_world.wbt') ] webots = Node(package='webots_ros2_core', node_executable='webots_launcher', arguments=arguments, output='screen') # Controller node synchronization = LaunchConfiguration('synchronization', default=False) controller = ControllerLauncher(package='webots_ros2_epuck', node_executable='driver', parameters=[{ 'synchronization': synchronization }], output='screen') # Rviz node use_rviz = LaunchConfiguration('rviz', default=False) rviz_config = os.path.join( get_package_share_directory('webots_ros2_epuck'), 'resource', 'all.rviz') rviz = Node(package='rviz2', node_executable='rviz2', output='screen', arguments=['--display-config=' + rviz_config], condition=launch.conditions.IfCondition(use_rviz)) # Launch descriptor launch_entities = [ webots, controller, rviz, # Shutdown launch when Webots exits. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[EmitEvent(event=launch.events.Shutdown())], )) ] return LaunchDescription(launch_entities)
def generate_launch_description(): package_dir = get_package_share_directory('webots_ros2_universal_robot') # Webots webots = WebotsLauncher( world=os.path.join(package_dir, 'worlds', 'universal_robot.wbt')) # Driver node controller = ControllerLauncher(package='webots_ros2_core', executable='webots_robotic_arm_node', parameters=[{ 'controller_name': 'webots_controller', 'use_joint_state_publisher': True }], output='screen') # Robot state publisher robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[{ 'robot_description': '<robot name=""><link name=""/></robot>', 'use_sim_time': True }], ) # MoveIt config robot_description_config = None with open('/tmp/webots_robot_UR5e.urdf', 'r') as file: robot_description_config = file.read() robot_description = {'robot_description': robot_description_config} robot_description_semantic = { 'robot_description_semantic': load_file('webots_ros2_universal_robot', 'config/ur5e.srdf') } robot_description_kinematics = { 'robot_description_kinematics': load_yaml('webots_ros2_universal_robot', 'config/kinematics.yaml') } moveit_controllers = { 'moveit_controller_manager': 'moveit_simple_controller_manager/MoveItSimpleControllerManager', 'moveit_simple_controller_manager': load_yaml('webots_ros2_universal_robot', 'config/controllers.yaml') } run_move_group_node = Node(package='moveit_ros_move_group', executable='move_group', output='screen', parameters=[ robot_description_semantic, robot_description, moveit_controllers, robot_description_kinematics, { 'use_sim_time': True } ]) # RViz rviz_config_file = os.path.join(package_dir, 'launch', 'universal_robot_moveit2.rviz') rviz_node = Node(package='rviz2', executable='rviz2', name='rviz2', arguments=['-d', rviz_config_file], parameters=[ robot_description_kinematics, robot_description, robot_description_semantic, { 'use_sim_time': True } ]) return LaunchDescription([ webots, controller, robot_state_publisher, rviz_node, run_move_group_node, RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[EmitEvent(event=launch.events.Shutdown())], )) ])
def generate_launch_description(): # Webots arguments = [ '--mode=realtime', '--world=' + os.path.join( get_package_share_directory('webots_ros2_universal_robot'), 'worlds', 'universal_robot_rviz.wbt') ] webots = launch_ros.actions.Node(package='webots_ros2_core', node_executable='webots_launcher', arguments=arguments, output='screen') # Controller nodes synchronization = launch.substitutions.LaunchConfiguration( 'synchronization', default=False) URe5Controller = ControllerLauncher( package='webots_ros2_universal_robot', node_executable='universal_robot', # this argument should match the 'name' field # of the robot in Webots arguments=['--webots-robot-name=UR5e'], parameters=[{ 'synchronization': synchronization }], output='screen') tfController = ControllerLauncher( package='webots_ros2_core', node_executable='tf_publisher', # this argument should match the 'name' field # of the robot in Webots arguments=['--webots-robot-name=tf_supervisor'], parameters=[{ 'synchronization': synchronization }], output='screen') # Copy .rviz config file and update path ro URDF file. templateRvizFile = os.path.join( get_package_share_directory('webots_ros2_ur_e_description'), 'rviz', 'view_robot') + '.rviz' home = Path.home() customRvizFile = os.path.join(home, 'webots_ros2_ur_e_description.rviz') if not os.path.exists( os.path.join(home, 'webots_ros2_ur_e_description.rviz')): with open(templateRvizFile, 'r') as f: content = f.read() content = content.replace( 'package://webots_ros2_ur_e_description', get_package_share_directory('webots_ros2_ur_e_description')) with open(customRvizFile, 'w') as f2: f2.write(content) # Rviz node rviz = launch_ros.actions.Node(package='rviz2', node_executable='rviz2', arguments=['-d', customRvizFile], output='screen') return launch.LaunchDescription([ rviz, webots, URe5Controller, tfController, # Shutdown launch when Webots exits. launch.actions. RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit( target_action=webots, on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())], )) ])