acml可用订阅到起始位姿

感到热泪盈眶了家人们 这个局部路径规划终于可以离线了
就是用这个启动文件就可以 了

/home/acan/ros2_ws/install/nav2_pure_pursuit_controller/share/nav2_pure_pursuit_controller/nav2_pure_pursuit_controller.xml

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, GroupAction, SetEnvironmentVariable
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import LoadComposableNodes
from launch_ros.actions import Node
from launch_ros.descriptions import ComposableNode
from nav2_common.launch import RewrittenYaml


def generate_launch_description():

    bringup_dir = get_package_share_directory('yhs_nav2')
    launch_dir = os.path.join(bringup_dir, 'launch')

    workspace_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
    map_file_dir = os.path.join(workspace_dir, 'yhs_nav2', 'map')

    use_respawn = LaunchConfiguration('use_respawn')
    declare_use_respawn_cmd = DeclareLaunchArgument(
    'use_respawn', default_value='False',
    description='Whether to respawn if a node crashes. Applied when composition is disabled.')


    namespace = LaunchConfiguration('namespace')
    declare_namespace_cmd = DeclareLaunchArgument(
        'namespace',
        default_value='',
        description='Top-level namespace')


    use_sim_time = LaunchConfiguration('use_sim_time')
    declare_use_sim_time_cmd = DeclareLaunchArgument(
        'use_sim_time',
        default_value='false',
        description='Use simulation (Gazebo) clock if true')
    

    params_file = LaunchConfiguration('params_file')

    autostart = LaunchConfiguration('autostart')
    declare_autostart_cmd = DeclareLaunchArgument(
        'autostart', default_value='true',
        description='Automatically startup the nav2 stack')

    log_level = LaunchConfiguration('log_level')
    declare_log_level_cmd = DeclareLaunchArgument(
    'log_level', default_value='info',
    description='log level')

    map_yaml_file = LaunchConfiguration('map')

    declare_map_yaml_cmd = DeclareLaunchArgument(
    'map',
    default_value=os.path.join(map_file_dir, '416.yaml'),
    description='地图名称')

    lifecycle_nodes = ['behavior_server','controller_server','map_server','planner_server','bt_navigator','waypoint_follower','amcl']

    remappings = [('/tf', 'tf'),
                ('/tf_static', 'tf_static')]

    declare_params_file_cmd = DeclareLaunchArgument(
        'params_file',
        default_value=os.path.join(bringup_dir, 'param', 'yhs_nav2.yaml'),
        description='Full path to the ROS2 parameters file to use for all launched nodes')
    
    param_substitutions = {
        'use_sim_time': use_sim_time,
        'yaml_filename': map_yaml_file}
    
    configured_params = RewrittenYaml(
        source_file=params_file,
        root_key=namespace,
        param_rewrites=param_substitutions,
        convert_types=True)

    bringup_cmd_group = GroupAction([
        Node(
                package='nav2_behaviors',
                executable='behavior_server',
                name='behavior_server',
                output='screen',
                respawn=use_respawn,
                respawn_delay=2.0,
                parameters=[configured_params],
                arguments=['--ros-args', '--log-level', log_level],
                remappings=remappings),

        Node(
                package='nav2_controller',
                executable='controller_server',
                output='screen',
                respawn=use_respawn,
                respawn_delay=2.0,
                parameters=[configured_params],
                arguments=['--ros-args', '--log-level', log_level],
                remappings=remappings + [('cmd_vel', 'cmd_vel_nav')]),

        Node(
        name='nav2_container',
        package='rclcpp_components',
        executable='component_container_isolated',
        parameters=[configured_params, {'autostart': autostart}],
        arguments=['--ros-args', '--log-level', log_level],
        remappings=remappings,
        output='screen'),
        Node(
        package='nav2_bt_navigator',
        executable='bt_navigator',
        name='bt_navigator',
        output='screen',
        parameters=[configured_params],
        arguments=['--ros-args', '--log-level', log_level],
        remappings=remappings),

        Node(
        package='nav2_map_server',
        executable='map_server',
        name='map_server',
        parameters=[{'yaml_filename': os.path.join(map_file_dir, '416.yaml')}]
        ),
        Node(
        package='nav2_amcl',
        executable='amcl',
        name='amcl',
        output='screen',
        respawn=use_respawn,
        respawn_delay=2.0,
        parameters=[configured_params],
        arguments=['--ros-args', '--log-level', log_level],
        remappings=remappings),

        Node(
                package='nav2_waypoint_follower',
                executable='waypoint_follower',
                name='waypoint_follower',
                output='screen',
                respawn=use_respawn,
                respawn_delay=2.0,
                parameters=[configured_params],
                arguments=['--ros-args', '--log-level', log_level],
                remappings=remappings),

        Node(
        package='nav2_planner',
        executable='planner_server',
        name='planner_server',
        parameters=[{
            'expected_planner_frequency': 2.0,
            'use_sim_time': False,
            'planner_plugins': ['GridBased'],
            'GridBased': {
                'plugin': 'nav2_navfn_planner/NavfnPlanner',
                'tolerance': 0.5,
                'use_astar': True,
                'allow_unknown': False,
                'smooth_path': True,
                'angle': 0.05
            }
        }]),
   

        Node(
        package='nav2_lifecycle_manager',
        executable='lifecycle_manager',
        name='lifecycle_manager',
        output='screen',
        parameters=[{'autostart': True},
                    {'node_names': lifecycle_nodes}]),

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

    ld = LaunchDescription()

    ld.add_action(declare_namespace_cmd)
    ld.add_action(declare_params_file_cmd)

    ld.add_action(declare_use_sim_time_cmd)  
    ld.add_action(declare_autostart_cmd)
    ld.add_action(declare_log_level_cmd)
    ld.add_action(declare_map_yaml_cmd)
    ld.add_action(declare_use_respawn_cmd)

    ld.add_action(bringup_cmd_group)

   

    return ld

相关推荐

  1. acml可用订阅起始姿

    2024-07-21 21:58:01       29 阅读
  2. 对相机姿 导出 Tum 格式的姿

    2024-07-21 21:58:01       61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-21 21:58:01       142 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-21 21:58:01       156 阅读
  3. 在Django里面运行非项目文件

    2024-07-21 21:58:01       131 阅读
  4. Python语言-面向对象

    2024-07-21 21:58:01       141 阅读

热门阅读

  1. Windows 12 网页版

    2024-07-21 21:58:01       26 阅读
  2. 网络融合的艺术:Xcode中应用Web服务集成全指南

    2024-07-21 21:58:01       35 阅读
  3. 提示工程的技术与策略分类

    2024-07-21 21:58:01       31 阅读
  4. css font 优化

    2024-07-21 21:58:01       31 阅读
  5. 基于深度学习的金融交易

    2024-07-21 21:58:01       35 阅读
  6. MATLAB中balance函数用法

    2024-07-21 21:58:01       33 阅读
  7. 栈和队列之间有哪些区别

    2024-07-21 21:58:01       30 阅读
  8. python 爬虫技术 第04节 函数和模块

    2024-07-21 21:58:01       30 阅读
  9. 打造安全堡垒:Xcode应用权限管理全解析

    2024-07-21 21:58:01       29 阅读
  10. MSPM0G3507——K210和M0通信(K210给M0发数据)

    2024-07-21 21:58:01       29 阅读
  11. Vue3替代vue2就好比自动驾驶代替出租网约车

    2024-07-21 21:58:01       34 阅读