Exemplo n.º 1
0
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())],
        )),
    ])
Exemplo n.º 2
0
def generate_launch_description():
    return launch.LaunchDescription(
        [
            IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    [get_package_share_directory(robot), "/launch/interfaces.py"]
                ),
                launch_arguments={
                    "namespace": robot,
                    "params_file": os.path.join(
                        get_package_share_directory(robot), "param", f"{robot}.yml"
                    ),
                }.items(),
            )
            for robot in robots
        ]
        + [
            IncludeLaunchDescription(
                PythonLaunchDescriptionSource(
                    [
                        get_package_share_directory("assurancetourix"),
                        "/launch/launch.py",
                    ]
                ),
                launch_arguments={
                    "namespace": "assurancetourix",
                    "params_file": os.path.join(
                        get_package_share_directory("assurancetourix"),
                        "param",
                        "assurancetourix.yml",
                    ),
                }.items(),
            )
        ]
        + [
            GroupAction(
                [
                    Node(
                        package="strategix",
                        executable="strategix",
                        output="screen",
                    ),
                    WebotsLauncher(
                        mode="realtime",
                        world="tools/simulation/worlds/cdr2022.wbt",
                    ),
                ]
            )
        ]
        + [
            RegisterEventHandler(
                event_handler=OnProcessExit(
                    on_exit=[
                        EmitEvent(event=Shutdown()),
                    ]
                )
            )
        ]
    )
Exemplo n.º 3
0
def generate_launch_description():
    # Webots
    webots = WebotsLauncher(
        #world=os.path.join(get_package_share_directory('robotis_mini_description'), 'worlds', 'ros_example.wbt')
        world=os.path.join('./worlds', 'empty.wbt'))

    # Controller node
    # synchronization = launch.substitutions.LaunchConfiguration('synchronization', default=False)
    # controller = ControllerLauncher(
    #    package='head_node',
    #    executable='head_publisher',
    #    parameters=[{'synchronization': synchronization}],
    #    output='screen'
    #)

    # urdf for state publisher
    robot_description_filename = 'robotis_mini.urdf.xacro'
    print("robot_description_filename : {}".format(robot_description_filename))
    xacro = os.path.join(
        get_package_share_directory('robotis_mini_description'), 'urdf',
        robot_description_filename)
    print("xacro : {}".format(xacro))
    use_sim_time = LaunchConfiguration('use_sim_time', default='false')
    xacro_path = LaunchConfiguration('xacro_path', default='{}'.format(xacro))
    print("xacro_path : {}".format(xacro_path))

    gui = LaunchConfiguration('gui', default='true')

    return launch.LaunchDescription([
        webots,
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='Use simulation (Gazebo) clock if true'),
        Node(package='robot_state_publisher',
             executable='robot_state_publisher',
             name='robot_state_publisher',
             output='screen',
             parameters=[{
                 'use_sim_time':
                 use_sim_time,
                 'robot_description':
                 Command(['xacro', ' ', xacro_path])
             }]),
        Node(condition=UnlessCondition(gui),
             package='joint_state_publisher',
             executable='joint_state_publisher',
             name='joint_state_publisher',
             output='screen'),
        Node(condition=IfCondition(gui),
             package='joint_state_publisher_gui',
             executable='joint_state_publisher_gui',
             name='joint_state_publisher_gui'),
        launch.actions.
        RegisterEventHandler(event_handler=launch.event_handlers.OnProcessExit(
            target_action=webots,
            on_exit=[launch.actions.EmitEvent(event=launch.events.Shutdown())],
        )),
    ])
Exemplo n.º 4
0
def generate_launch_description():
    package_dir = get_package_share_directory('webots_ros2_turtlebot')
    world = LaunchConfiguration('world')
    robot_description = pathlib.Path(
        os.path.join(package_dir, 'resource',
                     'turtlebot_webots.urdf')).read_text()
    ros2_control_params = os.path.join(package_dir, 'resource',
                                       'ros2control.yml')

    webots = WebotsLauncher(
        world=PathJoinSubstitution([package_dir, 'worlds', world]))

    turtlebot_driver = Node(package='webots_ros2_driver',
                            executable='driver',
                            output='screen',
                            parameters=[{
                                'robot_description': robot_description
                            }, ros2_control_params],
                            remappings=[
                                ('/diffdrive_controller/cmd_vel_unstamped',
                                 '/cmd_vel')
                            ])

    robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[{
            'robot_description':
            '<robot name=""><link name=""/></robot>'
        }],
    )

    footprint_publisher = Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        output='screen',
        arguments=[
            '0', '0', '0', '0', '0', '0', 'base_link', 'base_footprint'
        ],
    )

    return LaunchDescription([
        DeclareLaunchArgument(
            'world',
            default_value='turtlebot3_burger_example.wbt',
            description=
            'Choose one of the world files from `/webots_ros2_turtlebot/world` directory'
        ), webots, robot_state_publisher, turtlebot_driver,
        footprint_publisher,
        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())],
        ))
    ])
Exemplo n.º 6
0
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 = WebotsLauncher(
        world=os.path.join(get_package_share_directory('webots'),
                           'models/worlds', 'sim-robot.wbt'))
    return LaunchDescription([
        webots,
        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_demos'),
                           'worlds', 'armed_robots.wbt'))

    # Controller nodes
    synchronization = launch.substitutions.LaunchConfiguration(
        'synchronization', default=False)
    AbbController = ControllerLauncher(
        package='webots_ros2_core',
        executable='webots_robotic_arm_node',
        # this argument should match the 'name' field
        # of the robot in Webots
        arguments=['--webots-robot-name=abbirb4600'],
        namespace='abb',
        parameters=[{
            'synchronization': synchronization
        }],
        output='screen')
    Ure5controller = ControllerLauncher(
        package='webots_ros2_core',
        executable='webots_robotic_arm_node',
        # this argument should match the 'name' field
        # of the robot in Webots
        arguments=['--webots-robot-name=UR5e'],
        namespace='ur',
        parameters=[{
            'synchronization': synchronization
        }],
        output='screen')
    # Control nodes
    armedRobotsUr = ControllerLauncher(package='webots_ros2_demos',
                                       executable='armed_robots_ur',
                                       output='screen')
    armedRobotsAbb = ControllerLauncher(package='webots_ros2_demos',
                                        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
    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():
    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())],
        ))
    ])