ros中地图插件的使用

1.这两天看了一些关于move_base的栅格地图相关的一些东西
2.在move_base的costmap中提供了三个话题,其中括号中的是数据类型,通过话题订阅可以获取像素点的代价值及局部地图不断更新的代价值。只能获取并不能更改其代价值。
wiki网页链接:http://wiki.ros.org/costmap_2d

 ~<name>/costmap (nav_msgs/OccupancyGrid)
    The values in the costmap 
~<name>/costmap_updates (map_msgs/OccupancyGridUpdate)
    The value of the updated area of the costmap 
~<name>/voxel_grid (costmap_2d/VoxelGrid)
    Optionally advertised when the underlying occupancy grid uses voxels and the user requests the voxel grid be published. 

3.在costmap上创建一层新的地图层
wiki链接:http://wiki.ros.org/costmap_2d/Tutorials/Creating%20a%20New%20Layer
步骤1:创建一个package

cd ~/catkin_ws/src
catkin_create_pkg simple_layers roscpp costmap_2d dynamic_reconfigure std_msgs rospy

在这里插入图片描述
在这里插入图片描述步骤2:
分别在
1.在simple_layers/include/simple_layers文件夹中建立simple_layer.h文件
2.在simple_layers/isrc/simple_layers文件夹中建立simple_layer.c文件
.h文档与.c文档内容全部复制wiki官网

步骤3:
修改Cmakerlists.txt文件(与src在同一个文件夹的)
add_library(simple_layer src/simple_layer.cpp)
include_directories(include ${catkin_INCLUDE_DIRS})
在这里插入图片描述编译这个package的时候,能够找到之前simple_layers/include/simple_layers这个文件下的头文件
步骤4:创建costmap_plugins.xml
这个文件是插件的描述文件,它的目的是让ROS系统发现这个插件和load这个插件到系统里去
在这里插入图片描述
内容:

<library path="lib/libsimple_layer">
  <class type="simple_layer_namespace::SimpleLayer" base_class_type="costmap_2d::Layer">
    <description>Demo Layer that adds a point 1 meter in front of the robot</description>
  </class>
</library>

步骤5:修改package.xml文件,注册刚刚的插件。
在这里插入图片描述

<costmap_2d plugin="${prefix}/costmap_plugins.xml" />

步骤6:

cd ~/catkin_ws
catkin_make
source devel/setup.bash
rospack plugins --attrib=plugin costmap_2d

获得

zhy@zhy-Inspiron-7460:~/nav_test$ rospack plugins --attrib=plugin costmap_2d
pedestrian_layer-master /home/zhy/nav_test/src/pedestrian_layer-master/costmap_plugins.xml
simple_layers /home/zhy/nav_test/src/simple_layers/costmap_plugins.xml
costmap_2d /opt/ros/kinetic/share/costmap_2d/costmap_plugins.xml
zhy@zhy-Inspiron-7460:~/nav_test$ 

说明插件已经可以使用
参考博客1
看了一个大一的小朋友做的ros,自闭了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值