1、构建地图
- 启动turtlebot底盘
roslaunch turtlebot_bringup minimal.launch
- 启动传感器(激光雷达和惯性导航)
roslaunch lms1xx LMS1xx.launch #启动激光雷达
- 启动hector slam
roslaunch lms1xx hector_mapping_demo.launch
- 启动远程遥控
roslaunch turtlebot_teleop keyboard_teleop.launch
-
启动遥控xbox
roslaunch turtlebot_teleop xbox360_teleop.launch #(1)<remap from="turtlebot_teleop_joystick/cmd_vel" #to="cmd_vel_mux/input/teleop"/> #(2) joy_node节点修改 #<node pkg="joy" type="joy_node" name="joystick"> # <param name="dev" type="string" value="/dev/input/js0" /> # <param name="deadzone" value="0.12" /> # </node>
- 保存地图
rosrun map_server map_saver -f ~/my_map
2、自定义地图amcl导航
- 启动turtlebot底盘
roslaunch turtlebot_bringup minimal.launch
- 启动激光雷达
roslaunch turtlebot_navigation lms1xx.launch
- 启动amcl导航
roslaunch turtlebot_navigation lab_amcl_nomap.launch #不带加载地图,单独加载
- 加载地图
rosrun map_server map_server my_map.yaml
-
rviz查看
roslaunch turtlebot_navigation view_robot.launch
3、问题
-
(1)地图显示不正确
打开yaml文件
image: my_map.png
resolution: 0.050000
origin: [-51.224998, -51.224998, 0.000000]
negate: 0
occupied_thresh: 0.65
free_thresh: 0.196
注意:
图像像素值[0-255].
-
If negate is false, p = (255 - x) / 255.0. This means that black (0) now has the highest value (1.0) and white (255) has the lowest (0.0).
-
If negate is true, p = x / 255.0. This is the non-standard interpretation of images, which is why it is called negate, even though the math indicates that x is not negated. Nomenclature is hard.
一般negate为0。
p = (255 - x) / 255.0
-
If p > occupied_thresh(0.65,换算为灰度值,约为90,也就是说像素小于90为占用(障碍物)), output the value 100 to indicate the cell is occupied.
-
If p < free_thresh(0.196,换算为灰度值,约为205,也就是说像素大于205为空(*空间站)), output the value 0 to indicate the cell is free.
-
Otherwise, output -1 a.k.a. 255 (as an unsigned char), to indicate that the cell is unknown.
我通过hector保存的图像*空间的值为200,显示为障碍物,所以出现上面图像错误。