ROS2自动驾驶
yolo5自动驾驶
1、重要!更换U盘的操作指引
2、关闭开机自启动大程序
3、Linux基础
4、YoloV5训练集
5、自动驾驶基础调试(代码解析)
6、自动驾驶特调
7、自动驾驶原理
8、PID算法理论
9、阿克曼运动学分析理论
10、建立运动学模型
常用命令
!重要!首次使用
一、原理分析
麦克纳姆轮运动学分析
二、AI大模型
3、AI大模型类型和原理
4、RAG检索增强和模型训练样本
5、具身智能机器人系统架构
6、具身智能玩法核心源码解读
7、配置AI大模型
8、配置API-KEY
三、深度相机
2、颜色标定
10、深度相机的基础使用
11、深度相机伪彩色图像
12、深度相机测距
13、深度相机色块体积测算
14、深度相机颜色跟随
15、深度相机人脸跟随
16、深度相机KCF物体跟随
17、深度相机Mediapipe手势跟随
18、深度相机视觉循迹自动驾驶
19、深度相机边缘检测
四、多模态视觉理解
20、多模态语义理解、指令遵循
21、多模态视觉理解
22、多模态视觉理解+自动追踪
23、多模态视觉理解+视觉跟随
24、多模态视觉理解+视觉巡线
25、多模态视觉理解+深度相机距离问答
26、多模态视觉理解+SLAM导航
27、多模态视觉理解+SLAM导航+视觉巡线
28、意图揣测+多模态视觉理解+SLAM导航+视觉功能
五、雷达
8、雷达基础使用
思岚系列雷达
六、建立地图
9、Gmapping建图
cartographer快速重定位导航
RTAB-Map导航
RTAB-Map建图
slam-toolbox建图
cartographer建图
Navigation2多点导航避障
Navigation2单点导航避障
手机APP建图与导航
七、新机器人自动驾驶与调整
多模态视觉理解+SLAM导航
新机器人自动驾驶
场地摆放及注意事项
启动测试
识别调试
无人驾驶的车道保持
无人驾驶路标检测
无人驾驶红绿灯识别
无人驾驶之定点停车
无人驾驶转向决策
无人驾驶之喇叭鸣笛
无人驾驶减速慢行
无人驾驶限速行驶
无人驾驶自主泊车
无人驾驶综合应用
无人驾驶融合AI大模型应用
八、路网规划
路网规划导航简介
构建位姿地图
路网标注
路网规划结合沙盘地图案例
路径重规划
九、模型训练
1、数据采集
2、数据集标注
3、YOLOv11模型训练
4、模型格式转换
十、YOLOV11开发
多机通讯配置
汝城县职业中等专业学校知识库-信息中心朱老师编辑
-
+
首页
六、建立地图
cartographer快速重定位导航
cartographer快速重定位导航
## 快速重定位导航 ### 1、课程内容 1. 学习机器人快速重定位导航功能 2. 运行程序,rviz中会加载实时地图和机器人模型,机器人可以快速定位出在地图中的位置,能进行实时slam建图和导航功能 ### 2、原理简介 #### 2.1简介 * Navigation 2(Nav 2)是ROS 2中自带的导航框架,其目的是能够通过一种安全的方式使移动机器人从A点移动到B点。 * 其中Navigation 2默认的定位算法是AMCL(自适应蒙特卡洛定位) ,将默认的AMCL的定位方式更换为cartographer的定位方式,其他导航功能保持不变 #### 2.2 两种定位方式区别 * **AMCL**:适用于已知地图的场景,如在已构建好地图的室内环境中,机器人进行重复任务或导航时,可使用 AMCL 来确定自身位置。 * **Cartographer**:更适合在未知环境中,机器人需要同时建图和定位的场景,如机器人首次进入一个新的区域,需要快速构建地图并确定自身位置时,Cartographer 能发挥更好的作用。 ### 3、准备工作 #### 3.1 内容说明 我们的主板直接打开终端,输入本节课程提及的指令即可。 #### 3.2 地图准备 * 本节课程的快速重定位导航需要先按照教程【激光雷达课程】-【cartographer建图】保存一张pbstream格式地图,和yaml文件,pbstream,yaml文件会保存在 `~/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/yahboomcar.pbstream ~/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/yahboomcar.yaml` 目录下  #### 3.3 导航功能 **注意:** **我们的主板直接打开终端**,输入本节课程提及的指令即可。 机器人车机终端启动底层传感器命令: ``` ros2 launch yahboomcar_nav laser_bringup_launch.py ```  输入指令启动rviz可视化建图 。再启动cartographer节点,用于定位,【use_rviz:=true】改成true表示开启rviz可视化 ```#ORIN主控 ros2 launch yahboomcar_nav localization_imu_odom.launch.py use_rviz:=true load_state_filename:=/home/jetson/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/yahboomcar.pbstream ``` 参数说明 ``` #选择是否打开rviz,true为打开,false为不打开 use_rviz:=true #可替换目标地图文件 #.pbstream地图文件参考cartograph建图算法保存地图 load_state_filename:=/root/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/yahboomcar.pbstream ```  此时可以看到地图加载进去了,但是小车定位并不准确,然后我们点击【2D Pose Estimate】,给小车设置初始位姿,根据小车在实际环境中的大概位置,在rviz中用鼠标点击拖动,小车能快速的定位到地图上。如下图所示,雷达扫描的区域与实际障碍物大致重合。 **注:如果仍然无法定位,可能是小车处于障碍物区域,请放置在四周近距离无障碍物的地方再次启动。也可以终端保持开启,直接重启小车,等待自动恢复数据后重新定位。也可能是建图的时候地图特征点过少,建图一定需要细致一点的建图。**  最后启动Navigation 2导航, ``` #ORIN主控 ros2 launch yahboomcar_nav navigation_cartodwb_launch.py maps:=/home/jetson/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/yahboomcar.yaml ``` 参数说明 ``` #加载地图参数:(可替换目标地图) maps:=/root/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/maps/yahboomcar.yaml #.pgm文件也必须和.yaml在同路径下 ``` **注:此处yahboomcar.yaml必须和yahboomcar.pbstream是同时完成建图的,即是同一个地图,参考cartograph建图算法保存地图**  出现膨胀区域即可进行导航。 单点导航,点击【2D Goal Pose】工具,然后在rviz中选择一个目标点,小车结合周围的情况,规划出一条路径并且沿着路径移动到目标点。  多点导航,需要把nav2的插件添加进来,  添加后,rviz显示如下,  然后点击【Waypoint/Nav Through Poses Mode】,使用rivz工具栏中的【Nav2 Goal】给定任意的目标点,  然后点击【Start Waypoint Following】开始规划路径导航。小车会根据选的点的先后顺序,到了目标点后会自动前往下一个点,无需进行操作。达到最后一个点后,小车停车等待下一个指令。  ### 4、查看节点通讯图 终端输入,` ros2 run rqt_graph rqt_graph ` 如果一开始没有显示,选择【Nodes/Topics(all)】,然后点击左上角的刷新按钮。  ### 5、查看TF树 终端输入,` ros2 run rqt_tf_tree rqt_tf_tree `  ### 6、原理讲解 快速的重定位导航关键点在于使用cartographer的定位方式替换原本navigation2默认的amcl定位方式,其他内容保持不变,以下是对替换定位方式的内容进行讲解。 源码位置:`~/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/launch/` launch目录下找到`cartographer_localization.launch.py`文件,内容如下: * 本文件是启动cartographer节点,用于替换navigation2中默认的定位方式。对navigation2默认启动文件进行了修改,去除了原本启动amcl定位方式的节点,导航栈的其他内容保持不变。 ``` # 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. 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, ParameterFile from nav2_common.launch import RewrittenYaml def generate_launch_description(): # Get the launch directory bringup_dir = get_package_share_directory('nav2_bringup') namespace = LaunchConfiguration('namespace') map_yaml_file = LaunchConfiguration('map') use_sim_time = LaunchConfiguration('use_sim_time') autostart = LaunchConfiguration('autostart') params_file = LaunchConfiguration('params_file') use_composition = LaunchConfiguration('use_composition') container_name = LaunchConfiguration('container_name') container_name_full = (namespace, '/', container_name) use_respawn = LaunchConfiguration('use_respawn') log_level = LaunchConfiguration('log_level') # Remove 'amcl' from lifecycle_nodes lifecycle_nodes = ['map_server'] # 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')] # Create our own temporary YAML files that include substitutions param_substitutions = { 'use_sim_time': use_sim_time, 'yaml_filename': map_yaml_file} configured_params = ParameterFile( RewrittenYaml( source_file=params_file, root_key=namespace, param_rewrites=param_substitutions, convert_types=True), allow_substs=True) stdout_linebuf_envvar = SetEnvironmentVariable( 'RCUTILS_LOGGING_BUFFERED_STREAM', '1') declare_namespace_cmd = DeclareLaunchArgument( 'namespace', default_value='', description='Top-level namespace') declare_map_yaml_cmd = DeclareLaunchArgument( 'map', description='Full path to map yaml file to load') declare_use_sim_time_cmd = DeclareLaunchArgument( 'use_sim_time', default_value='false', 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_autostart_cmd = DeclareLaunchArgument( 'autostart', default_value='true', description='Automatically startup the nav2 stack') declare_use_composition_cmd = DeclareLaunchArgument( 'use_composition', default_value='False', description='Use composed bringup if True') declare_container_name_cmd = DeclareLaunchArgument( 'container_name', default_value='nav2_container', description='the name of conatiner that nodes will load in if use composition') declare_use_respawn_cmd = DeclareLaunchArgument( 'use_respawn', default_value='False', description='Whether to respawn if a node crashes. Applied when composition is disabled.') declare_log_level_cmd = DeclareLaunchArgument( 'log_level', default_value='info', description='log level') load_nodes = GroupAction( condition=IfCondition(PythonExpression(['not ', use_composition])), actions=[ Node( package='nav2_map_server', executable='map_server', name='map_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_lifecycle_manager', executable='lifecycle_manager', name='lifecycle_manager_localization', output='screen', arguments=['--ros-args', '--log-level', log_level], parameters=[{'use_sim_time': use_sim_time}, {'autostart': autostart}, {'node_names': lifecycle_nodes}]) ] ) load_composable_nodes = LoadComposableNodes( condition=IfCondition(use_composition), target_container=container_name_full, composable_node_descriptions=[ ComposableNode( package='nav2_map_server', plugin='nav2_map_server::MapServer', name='map_server', parameters=[configured_params], remappings=remappings), ComposableNode( package='nav2_lifecycle_manager', plugin='nav2_lifecycle_manager::LifecycleManager', name='lifecycle_manager_localization', parameters=[{'use_sim_time': use_sim_time, 'autostart': autostart, 'node_names': lifecycle_nodes}]), ], ) # Create the launch description and populate ld = LaunchDescription() # Set environment variables ld.add_action(stdout_linebuf_envvar) # Declare the launch options ld.add_action(declare_namespace_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_autostart_cmd) ld.add_action(declare_use_composition_cmd) ld.add_action(declare_container_name_cmd) ld.add_action(declare_use_respawn_cmd) ld.add_action(declare_log_level_cmd) # Add the actions to launch all of the localiztion nodes ld.add_action(load_nodes) ld.add_action(load_composable_nodes) return ld ``` launch目录下找到`navigation_cartodwb_launch.py`文件,内容如下: 这里启动了以下几个节点: * base_link_to_laser_tf:发布静态的TF变换; * map_yaml_path:加载地图文件,默认值 为/root/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_navmaps/yahboom_map.yaml,用于指定要加载的地图文件路径; cartographer_bringup_launch.py:启动cartographer纯定位的launch文件,文件位于,/root/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav/launch/cartographer_bringup_launch.py ORIN主控,路径在/home/yahboom/下 RDKX5主控,路径在/home/sunrise/下 另外还加载了一个导航参数配置文件cartoteb_nav_params.yaml。 ``` import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node def generate_launch_description(): package_path = get_package_share_directory('yahboomcar_nav') use_sim_time = LaunchConfiguration('use_sim_time', default='false') namespece = LaunchConfiguration('namespece', default='') map_yaml_path = LaunchConfiguration( 'maps', default=os.path.join('/root/yahboomcar_ros2_ws/yahboomcar_ws/src/yahboomcar_nav', 'maps', 'yahboomcar.yaml')) nav2_param_path = LaunchConfiguration('params_file', default=os.path.join( package_path, 'params', 'cartoteb_nav_params.yaml')) return LaunchDescription([ DeclareLaunchArgument('use_sim_time', default_value=use_sim_time, description='Use simulation (Gazebo) clock if true'), DeclareLaunchArgument('namespece', default_value=namespece, description='Use simulation (Gazebo) clock if true'), DeclareLaunchArgument('maps', default_value=map_yaml_path, description='Full path to map file to load'), DeclareLaunchArgument('params_file', default_value=nav2_param_path, description='Full path to param file to load'), IncludeLaunchDescription( PythonLaunchDescriptionSource( [package_path, '/launch', '/cartographer_bringup_launch.py']), launch_arguments={ 'map': map_yaml_path, 'use_sim_time': use_sim_time, 'namespece': namespece, 'params_file': nav2_param_path}.items(), ), ]) ```
admin
2025年12月4日 14:41
49
转发
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
Word文件
PDF文档
PDF文档(打印)
分享
链接
类型
密码
更新密码
有效期
AI