Nav2極簡筆記01-安裝與試用

      網友投稿 1478 2025-03-31

      安裝


      功能包:

      ros-foxy-navigation2

      ros-foxy-nav2-bringup

      ros-foxy-turtlebot3*

      推薦使用新立得,例如nav2的地圖服務器

      圖形化安裝適合初學者入門!

      選擇需要的包下載安裝即可。

      源碼編譯:

      github中navigation2,按照官網流程說明配置安裝,文檔更新較快,為避免誤導,不再贅述。

      ros@ros:~/RobCode/navigation2$ colcon build

      Starting >>> nav2_common

      Starting >>> nav_2d_msgs

      Starting >>> nav2_gazebo_spawner

      Finished <<< nav2_common [0.68s]

      Starting >>> nav2_msgs

      Starting >>> nav2_voxel_grid

      Finished <<< nav2_gazebo_spawner [0.72s]

      Finished <<< nav_2d_msgs [14.3s]

      Starting >>> dwb_msgs

      Finished <<< nav2_voxel_grid [33.6s]

      Finished <<< dwb_msgs [29.2s]

      Finished <<< nav2_msgs [53.0s]

      Starting >>> nav2_util

      [Processing: nav2_util]

      Finished <<< nav2_util [34.1s]

      Starting >>> nav_2d_utils

      Starting >>> nav2_behavior_tree

      Starting >>> nav2_lifecycle_manager

      Starting >>> nav2_map_server

      Starting >>> nav2_amcl

      Starting >>> nav2_waypoint_follower

      Finished <<< nav_2d_utils [19.4s]

      Finished <<< nav2_waypoint_follower [30.0s]

      Finished <<< nav2_lifecycle_manager [33.4s]

      Starting >>> nav2_rviz_plugins

      Finished <<< nav2_map_server [1min 1s]

      Starting >>> nav2_costmap_2d

      Finished <<< nav2_amcl [1min 7s]

      Finished <<< nav2_rviz_plugins [58.3s]

      [Processing: nav2_behavior_tree, nav2_costmap_2d]

      [Processing: nav2_behavior_tree, nav2_costmap_2d]

      Finished <<< nav2_behavior_tree [2min 58s]

      Starting >>> nav2_bt_navigator

      Finished <<< nav2_costmap_2d [2min 21s]

      Starting >>> nav2_core

      Starting >>> costmap_queue

      Finished <<< nav2_core [4.58s]

      Starting >>> dwb_core

      Starting >>> nav2_controller

      Starting >>> nav2_navfn_planner

      Starting >>> nav2_planner

      Starting >>> nav2_recoveries

      Starting >>> nav2_regulated_pure_pursuit_controller

      Finished <<< nav2_bt_navigator [51.2s]

      Starting >>> smac_planner

      Finished <<< costmap_queue [45.9s]

      Finished <<< nav2_navfn_planner [57.8s]

      Finished <<< dwb_core [57.9s]

      Starting >>> dwb_critics

      Starting >>> dwb_plugins

      Finished <<< nav2_planner [1min 15s]

      Finished <<< nav2_regulated_pure_pursuit_controller [1min 17s]

      [Processing: dwb_critics, dwb_plugins, nav2_controller, nav2_recoveries, smac_planner]

      Finished <<< dwb_plugins [54.7s]

      Finished <<< nav2_controller [2min 4s]

      Finished <<< dwb_critics [1min 8s]

      Starting >>> nav2_dwb_controller

      Finished <<< nav2_dwb_controller [2.32s]

      Finished <<< nav2_recoveries [2min 14s]

      Finished <<< smac_planner [2min 17s]

      Starting >>> navigation2

      Finished <<< navigation2 [1.05s]

      Starting >>> nav2_bringup

      Finished <<< nav2_bringup [1.19s]

      Starting >>> nav2_system_tests

      [Processing: nav2_system_tests]

      [Processing: nav2_system_tests]

      [Processing: nav2_system_tests]

      Finished <<< nav2_system_tests [1min 58s]

      Summary: 31 packages finished [9min 34s]

      ros@ros:~/RobCode/navigation2$

      示例

      測試安裝后,是否能夠正常使用(ros2-foxy為例)。

      功能包

      source /opt/ros/foxy/setup.bash

      export TURTLEBOT3_MODEL=waffle

      export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/foxy/share/turtlebot3_gazebo/models

      路徑依據實際情況,稍有不同。

      源碼編譯

      source /home/ros/RobCode/navigation2/install/setup.bash

      運行

      ros2 launch nav2_bringup tb3_simulation_launch.py

      設置初始位置(2D Pose Estimate):

      在rviz2中加入機器人模型(RobotModel),調整TF大小:

      使用目標(Navigation2 Goal)設置終點,看效果如何?

      定位思考:

      如何提高定位精度呢?

      tb3_simulation_launch.py(Intel)

      # Copyright (c) 2018 Intel Corporation

      #

      # Licensed under the Apache License, Version 2.0 (the "License");

      # you may not use this file except in compliance with the License.

      # You may obtain a copy of the License at

      #

      # http://www.apache.org/licenses/LICENSE-2.0

      #

      # Unless required by applicable law or agreed to in writing, software

      # distributed under the License is distributed on an "AS IS" BASIS,

      # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

      # See the License for the specific language governing permissions and

      # limitations under the License.

      """This is all-in-one launch script intended for use by nav2 developers."""

      import os

      from ament_index_python.packages import get_package_share_directory

      from launch import LaunchDescription

      from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription

      from launch.conditions import IfCondition

      from launch.launch_description_sources import PythonLaunchDescriptionSource

      from launch.substitutions import LaunchConfiguration, PythonExpression

      from launch_ros.actions import Node

      def generate_launch_description():

      # Get the launch directory

      bringup_dir = get_package_share_directory('nav2_bringup')

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

      # Create the launch configuration variables

      slam = LaunchConfiguration('slam')

      namespace = LaunchConfiguration('namespace')

      use_namespace = LaunchConfiguration('use_namespace')

      map_yaml_file = LaunchConfiguration('map')

      use_sim_time = LaunchConfiguration('use_sim_time')

      params_file = LaunchConfiguration('params_file')

      default_bt_xml_filename = LaunchConfiguration('default_bt_xml_filename')

      autostart = LaunchConfiguration('autostart')

      # Launch configuration variables specific to simulation

      rviz_config_file = LaunchConfiguration('rviz_config_file')

      use_simulator = LaunchConfiguration('use_simulator')

      use_robot_state_pub = LaunchConfiguration('use_robot_state_pub')

      use_rviz = LaunchConfiguration('use_rviz')

      headless = LaunchConfiguration('headless')

      world = LaunchConfiguration('world')

      # Map fully qualified names to relative ones so the node's namespace can be prepended.

      # In case of the transforms (tf), currently, there doesn't seem to be a better alternative

      # https://github.com/ros/geometry2/issues/32

      # https://github.com/ros/robot_state_publisher/pull/30

      # TODO(orduno) Substitute with `PushNodeRemapping`

      # https://github.com/ros2/launch_ros/issues/56

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

      ('/tf_static', 'tf_static')]

      # Declare the launch arguments

      declare_namespace_cmd = DeclareLaunchArgument(

      Nav2極簡筆記01-安裝與試用

      'namespace',

      default_value='',

      description='Top-level namespace')

      declare_use_namespace_cmd = DeclareLaunchArgument(

      'use_namespace',

      default_value='false',

      description='Whether to apply a namespace to the navigation stack')

      declare_slam_cmd = DeclareLaunchArgument(

      'slam',

      default_value='False',

      description='Whether run a SLAM')

      declare_map_yaml_cmd = DeclareLaunchArgument(

      'map',

      default_value=os.path.join(bringup_dir, 'maps', 'turtlebot3_world.yaml'),

      description='Full path to map file to load')

      declare_use_sim_time_cmd = DeclareLaunchArgument(

      'use_sim_time',

      default_value='true',

      description='Use simulation (Gazebo) clock if true')

      declare_params_file_cmd = DeclareLaunchArgument(

      'params_file',

      default_value=os.path.join(bringup_dir, 'params', 'nav2_params.yaml'),

      description='Full path to the ROS2 parameters file to use for all launched nodes')

      declare_bt_xml_cmd = DeclareLaunchArgument(

      'default_bt_xml_filename',

      default_value=os.path.join(

      get_package_share_directory('nav2_bt_navigator'),

      'behavior_trees', 'navigate_w_replanning_and_recovery.xml'),

      description='Full path to the behavior tree xml file to use')

      declare_autostart_cmd = DeclareLaunchArgument(

      'autostart', default_value='true',

      description='Automatically startup the nav2 stack')

      declare_rviz_config_file_cmd = DeclareLaunchArgument(

      'rviz_config_file',

      default_value=os.path.join(bringup_dir, 'rviz', 'nav2_default_view.rviz'),

      description='Full path to the RVIZ config file to use')

      declare_use_simulator_cmd = DeclareLaunchArgument(

      'use_simulator',

      default_value='True',

      description='Whether to start the simulator')

      declare_use_robot_state_pub_cmd = DeclareLaunchArgument(

      'use_robot_state_pub',

      default_value='True',

      description='Whether to start the robot state publisher')

      declare_use_rviz_cmd = DeclareLaunchArgument(

      'use_rviz',

      default_value='True',

      description='Whether to start RVIZ')

      declare_simulator_cmd = DeclareLaunchArgument(

      'headless',

      default_value='False',

      description='Whether to execute gzclient)')

      declare_world_cmd = DeclareLaunchArgument(

      'world',

      # TODO(orduno) Switch back once ROS argument passing has been fixed upstream

      # https://github.com/ROBOTIS-GIT/turtlebot3_simulations/issues/91

      # default_value=os.path.join(get_package_share_directory('turtlebot3_gazebo'),

      # 'worlds/turtlebot3_worlds/waffle.model'),

      default_value=os.path.join(bringup_dir, 'worlds', 'waffle.model'),

      description='Full path to world model file to load')

      # Specify the actions

      start_gazebo_server_cmd = ExecuteProcess(

      condition=IfCondition(use_simulator),

      cmd=['gzserver', '-s', 'libgazebo_ros_init.so', world],

      cwd=[launch_dir], output='screen')

      start_gazebo_client_cmd = ExecuteProcess(

      condition=IfCondition(PythonExpression([use_simulator, ' and not ', headless])),

      cmd=['gzclient'],

      cwd=[launch_dir], output='screen')

      urdf = os.path.join(bringup_dir, 'urdf', 'turtlebot3_waffle.urdf')

      start_robot_state_publisher_cmd = Node(

      condition=IfCondition(use_robot_state_pub),

      package='robot_state_publisher',

      executable='robot_state_publisher',

      name='robot_state_publisher',

      namespace=namespace,

      output='screen',

      parameters=[{'use_sim_time': use_sim_time}],

      remappings=remappings,

      arguments=[urdf])

      rviz_cmd = IncludeLaunchDescription(

      PythonLaunchDescriptionSource(os.path.join(launch_dir, 'rviz_launch.py')),

      condition=IfCondition(use_rviz),

      launch_arguments={'namespace': '',

      'use_namespace': 'False',

      'rviz_config': rviz_config_file}.items())

      bringup_cmd = IncludeLaunchDescription(

      PythonLaunchDescriptionSource(os.path.join(launch_dir, 'bringup_launch.py')),

      launch_arguments={'namespace': namespace,

      'use_namespace': use_namespace,

      'slam': slam,

      'map': map_yaml_file,

      'use_sim_time': use_sim_time,

      'params_file': params_file,

      'default_bt_xml_filename': default_bt_xml_filename,

      'autostart': autostart}.items())

      # Create the launch description and populate

      ld = LaunchDescription()

      # Declare the launch options

      ld.add_action(declare_namespace_cmd)

      ld.add_action(declare_use_namespace_cmd)

      ld.add_action(declare_slam_cmd)

      ld.add_action(declare_map_yaml_cmd)

      ld.add_action(declare_use_sim_time_cmd)

      ld.add_action(declare_params_file_cmd)

      ld.add_action(declare_bt_xml_cmd)

      ld.add_action(declare_autostart_cmd)

      ld.add_action(declare_rviz_config_file_cmd)

      ld.add_action(declare_use_simulator_cmd)

      ld.add_action(declare_use_robot_state_pub_cmd)

      ld.add_action(declare_use_rviz_cmd)

      ld.add_action(declare_simulator_cmd)

      ld.add_action(declare_world_cmd)

      # Add any conditioned actions

      ld.add_action(start_gazebo_server_cmd)

      ld.add_action(start_gazebo_client_cmd)

      # Add the actions to launch all of the navigation nodes

      ld.add_action(start_robot_state_publisher_cmd)

      ld.add_action(rviz_cmd)

      ld.add_action(bringup_cmd)

      return ld

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:Excel表格怎么換行?教你簡單實用的方法
      下一篇:是什么原因?怎么破?(打牌天天輸是什么原因怎么破)
      相關文章
      亚洲精品无码av人在线观看| 亚洲精品无码乱码成人| 久久久久久a亚洲欧洲AV| 国产成人高清亚洲| 亚洲成AⅤ人影院在线观看 | 亚洲欧美aⅴ在线资源| 在线观看亚洲AV日韩AV| 日韩亚洲国产高清免费视频| 国产亚洲中文日本不卡二区| 亚洲一级特黄特黄的大片| 亚洲男人天堂2022| 亚洲婷婷在线视频| 亚洲免费在线视频播放| 亚洲av一本岛在线播放| 亚洲一区欧洲一区| 亚洲码欧美码一区二区三区| 亚洲av无码专区青青草原| 337P日本欧洲亚洲大胆精品| 四虎亚洲国产成人久久精品 | 亚洲Av无码精品色午夜| 亚洲AV人无码激艳猛片| 亚洲成人精品久久| 91嫩草私人成人亚洲影院| 亚洲精品成人久久| 国产色在线|亚洲| 亚洲一卡一卡二新区无人区| 亚洲精品无码不卡在线播放| 亚洲爆乳大丰满无码专区| 久久精品亚洲日本波多野结衣| 国产成人 亚洲欧洲| 亚洲国产91精品无码专区| 亚洲色成人网站WWW永久| 国产亚洲精品xxx| 午夜影视日本亚洲欧洲精品一区 | 亚洲国产精品成人午夜在线观看| 久久精品国产亚洲AV天海翼| 亚洲av无码不卡私人影院| 久久国产成人亚洲精品影院| 亚洲VA成无码人在线观看天堂| 日韩亚洲AV无码一区二区不卡| 亚洲人妖女同在线播放|