Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9412678
  • 博文数量: 1748
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 20070
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1748)

文章存档

2024年(24)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: 其他平台

2020-09-02 10:48:57

这里主要使用 cartographer 进行建图.


ros2 launch turtlebot3_bringup robot.launch.py ## 加载 底盘以及lidar 部件.
ros2 run turtlebot3_teleop teleop_keyboard ## 加载手动遥控控制部分.

//默认位置为坐标 0, 0, 0 位置, 所以需要做地图之前进行规划和起始走位.

ros2 launch turtlebot3_cartographer cartographer.launch.py ## 启用 cartographer 的算法处理
根据以往建图经验, 尽量保持机器人平稳走动, 尤其不宜急停/急转. 速度为200mm/s 30度/s 为宜. lidar的视角做好超过180, 位置走一遍为宜. 否则多次扫描有大几率造成重影问题, 毕竟软件算法做到回环矫正还是比较难的.


ros2 run nav2_map_server map_saver -f ~/map  ## 保存地图, 产生 map.pgm/yaml文件.

下一步进行 地图手动修正.
---------------------------------------------------------------------------------------------------
详细步骤

点击(此处)折叠或打开  cartographer.launch.py

  1. import os
  2. from ament_index_python.packages import get_package_share_directory
  3. from launch import LaunchDescription
  4. from launch.actions import DeclareLaunchArgument
  5. from launch_ros.actions import Node
  6. from launch.substitutions import LaunchConfiguration
  7. from launch.actions import IncludeLaunchDescription
  8. from launch.launch_description_sources import PythonLaunchDescriptionSource
  9. from launch.substitutions import ThisLaunchFileDir

  10. def generate_launch_description():
  11.     use_sim_time = LaunchConfiguration('use_sim_time', default='false')
  12.     turtlebot3_cartographer_prefix = get_package_share_directory('turtlebot3_cartographer')
  13.     cartographer_config_dir = LaunchConfiguration('cartographer_config_dir',
  14.                                                     default=os.path.join(turtlebot3_cartographer_prefix, 'config'))
  15.     configuration_basename = LaunchConfiguration('configuration_basename', default='turtlebot3_lds_2d.lua')  //激光雷达的参数以及建图参数

  16.     resolution = LaunchConfiguration('resolution', default='0.05')  ## 地图分辨率
  17.     publish_period_sec = LaunchConfiguration('publish_period_sec', default='1.0') ##地图更新发布频率, 最好不要太快, 会影响CPU计算速度.

  18.     rviz_config_dir = os.path.join(get_package_share_directory('turtlebot3_cartographer'), 'rviz', 'tb3_cartographer.rviz')

  19.     return LaunchDescription([
  20.         DeclareLaunchArgument(
  21.             'cartographer_config_dir',
  22.             default_value=cartographer_config_dir,
  23.             description='Full path to config file to load'),
  24.         DeclareLaunchArgument(
  25.             'configuration_basename',
  26.             default_value=configuration_basename,
  27.             description='Name of lua file for cartographer'),
  28.         DeclareLaunchArgument(
  29.             'use_sim_time',
  30.             default_value='false',
  31.             description='Use simulation (Gazebo) clock if true'),

  32.         Node(
  33.             package='cartographer_ros',
  34.             node_executable='cartographer_node',
  35.             node_name='cartographer_node',
  36.             output='screen',
  37.             parameters=[{'use_sim_time': use_sim_time}],
  38.             arguments=['-configuration_directory', cartographer_config_dir, '-configuration_basename', configuration_basename]),

  39.         DeclareLaunchArgument(
  40.             'resolution',
  41.             default_value=resolution,
  42.             description='Resolution of a grid cell in the published occupancy grid'),

  43.         DeclareLaunchArgument(
  44.             'publish_period_sec',
  45.             default_value=publish_period_sec,
  46.             description='OccupancyGrid publishing period'),

  47.         IncludeLaunchDescription(
  48.             PythonLaunchDescriptionSource([ThisLaunchFileDir(), '/occupancy_grid.launch.py']),
  49.             launch_arguments={'use_sim_time': use_sim_time, 'resolution': resolution, 'publish_period_sec': publish_period_sec}.items(),
  50.         ),

  51.         Node(
  52.             package='rviz2',
  53.             node_executable='rviz2',
  54.             node_name='rviz2',
  55.             arguments=['-d', rviz_config_dir],
  56.             parameters=[{'use_sim_time': use_sim_time}],
  57.             output='screen'),
  58.     ])

点击(此处)折叠或打开

  1. //occupancy_grid.launch.py  地图局部计算,回环等处理部分.

  2. from launch import LaunchDescription
  3. from launch.actions import DeclareLaunchArgument
  4. from launch_ros.actions import Node
  5. from launch.substitutions import LaunchConfiguration

  6. def generate_launch_description():
  7.     use_sim_time = LaunchConfiguration('use_sim_time', default='false')
  8.     resolution = LaunchConfiguration('resolution', default='0.05')
  9.     publish_period_sec = LaunchConfiguration('publish_period_sec', default='1.0')

  10.     return LaunchDescription([
  11.         DeclareLaunchArgument(
  12.             'resolution',
  13.             default_value=resolution,
  14.             description='Resolution of a grid cell in the published occupancy grid'),

  15.         DeclareLaunchArgument(
  16.             'publish_period_sec',
  17.             default_value=publish_period_sec,
  18.             description='OccupancyGrid publishing period'),

  19.         DeclareLaunchArgument(
  20.             'use_sim_time',
  21.             default_value='false',
  22.             description='Use simulation (Gazebo) clock if true'),

  23.         Node(
  24.             package='cartographer_ros',
  25.             node_executable='occupancy_grid_node',
  26.             node_name='occupancy_grid_node',
  27.             output='screen',
  28.             parameters=[{'use_sim_time': use_sim_time}],
  29.             arguments=['-resolution', resolution, '-publish_period_sec', publish_period_sec]),
  30.     ])


阅读(2264) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~