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,顯示爲障礙物,所以出現上面圖像錯誤。