ubuntu18.04运行turtlebot2与Hokuyo(URG-04LX-UG01)激光雷达建图步骤(配置好后)
1.打开第一个终端
配置ros环境变量
$ source ~/catkin_ws/devel/setup.bash
修改串口权限
$ sudo chmod a+rw /dev/ttyACM0
运行roscore
$ roscore
2.打开另一个终端
启动turtlebot2
$ roslaunch turtlebot_bringup minimal.launch
3.打开一个新终端
启动gmmaping建图
$ source ~/catkin_ws/devel/setup.bash
$ roslaunch turtlebot_navigation hokuyo_gmapping_demo.launch
此时可能报错如下
[FATAL] [1611126610.532934830]: Failed to create the dwa_local_planner/DWAPlannerROS planner, are you sure it is properly registered and that the containing library is built? Exception: According to the loaded plugin descriptions the class dwa_local_planner/DWAPlannerROS with base class type nav_core::BaseLocalPlanner does not exist. Declared types are base_local_planner/TrajectoryPlannerROS
[move_base-6] process has died [pid 9487, exit code 1, cmd /opt/ros/melodic/lib/move_base/move_base cmd_vel:=navigation_velocity_smoother/raw_cmd_vel odom:=odom scan:=scan __name:=move_base __log:=/home/qmw/.ros/log/6a5f6734-5aee-11eb-aaf0-b88198b64892/move_base-6.log].
log file: /home/qmw/.ros/log/6a5f6734-5aee-11eb-aaf0-b88198b64892/move_base-6*.log
运行以下命令即可解决:
$ sudo apt-get install ros-melodic-dwa-local-planner
4.打开一个新终端
使用键盘操作turtlebot2
$ roslaunch turtlebot_teleop keyboard_teleop.launch
5.再打开一个终端
启动rivz,可看建图情况
$ source catkin_ws/devel/setup.bash
$ roslaunch turtlebot_rviz_launchers view_navigation.launch
6.建图结束以后再打开一个新终端存储地图文件
$ mkdir -p ~/map
$ rosrun map_server map_saver -f ~/map/hokuyo_gmapping
参考:https://blog.csdn.net/aicynthiachan/article/details/104902650