3.1 Hector_mapping初体验
1.初体验
下载依赖
sudo apt install ros-noetic-hector-mapping
构建仿真环境
roslaunch wpr_simulation wpb_stage_slam.launch
运行SLAM
rosrun hector_mapping hector_mapping
再新建终端
rosrun rviz rviz
注意终端管理
新建终端,打开操作杆
osrun rqt_robot_steering rqt_robot_steering
可视化效果
2.launch启动
新建SLAM包
catkin_create_pkg slam_pkg roscpp rospy std_msgs
新建launch'文件,键入以下代码
<launch><includev file="$(find wpr_simulation)/launch/wpb_stage_slam.launch"/>
<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping"/>
<node pkg="rviz" type="rviz" name="rviz"/>
<node pkg="rqt_robot_steering" type="rqt_robot_steering" name="rqt_robot_steering"/></launch>
保存后编译,并运行命令
roslaunch slam_pkg hector.launch
使用配置文件启动rviz
rosrun rviz rviz -d /home/wisdom/catkin_ws/src/slam_pkg/rviz/slam.rviz
或者直接launch文件,增加rviz参数args
<launch><include file="$(find wpr_simulation)/launch/wpb_stage_slam.launch"/>
<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping"/>
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find slam_pkg)/rviz/slam.rviz"/>
<node pkg="rqt_robot_steering" type="rqt_robot_steering" name="rqt_robot_steering"/></launch>
实现一条指令实现所有平台加载对应参数启动
3.参数设置
<launch><include file="$(find wpr_simulation)/launch/wpb_stage_slam.launch"/>
<node pkg="hector_mapping" type="hector_mapping" name="hector_mapping" output="screen"><param name="map_update_distance_thresh" value="0.1"/><param name="map_update_angle_thresh" value="0.1"/><param name="map_pub_period" value="0.1"/>
</node><node pkg="rviz" type="rviz" name="rviz" args="-d $(find slam_pkg)/rviz/slam.rviz"/>
<node pkg="rqt_robot_steering" type="rqt_robot_steering" name="rqt_robot_steering"/></launch>
文件结构