ROS 自定义地图加载和导航(turtlebot测试)

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,显示为障碍物,所以出现上面图像错误。

  • 4
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值