官方文档参阅:http://wiki.ros.org/pluginlib

有时候,可能会需要将替换ROS默认的planner替换成别的planner或我们自己的planner。这就涉及到了新planner包的建立和配置。

建立一个新的planner,大致分为以下几个步骤:

1. 实现nav_core包中的base_global_planner或base_local_planner接口,来建立一个新的planner包。

2. 在planner源码中添加:PLUGINLIB_EXPORT_CLASS宏,用于注册planner,否则ROS会不知道你的这个类是一个planner。

3. 在你的项目中添加your_planner_plugin.xml,用于声明你的planner。

4. 在package.xml中添加export。这里特别需要注意一点,如果你的export看起来像下面这样:

    <export>
<nav_core plugin="${prefix}/planner_plugin.xml" />
</export>

那么,一定要记得在package.xml中添加:

  <build_depend>nav_core</build_depend>
<exec_depend>nav_core</exec_depend>

否则,你会发现编译全对,但启动move_base就是找不到你的planner。会出来类似下面的错误:

Failed to create the your_planner/YourPlannerROS planner, are you sure it is properly registered and that the containing library is built?
Exception: According to the loaded plugin descriptions the class your_planner/YourPlannerROS with base class type nav_core::BaseGlobalPlanner does not exist.
Declared types are carrot_planner/CarrotPlanner global_planner/GlobalPlanner navfn/NavfnROS.

无论你怎么调试,系统就是找不到你的planner。

5. 最后一步是编写CMakefileLists.txt。一定要注意install你的lib文件和plugin.xml文件。不install的话有时会因找不到这些文件而失败:

install(TARGETS your_planner
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
) install(FILES your_planner_plugin.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

使用自己的planner进行测试时,推荐使用catkin_make_isolated --install进行编译,然后source install_isolated/setup.bash。使用devel_isolated/setup.bash有时会找不到planner。

PS:如果调试的时候发现还是出错,想查具体错误原因,可以修改move_base中下面这段:

    //initialize the global planner
try {
planner_ = bgp_loader_.createInstance(global_planner);
planner_->initialize(bgp_loader_.getName(global_planner), planner_costmap_ros_);
} catch (const pluginlib::PluginlibException& ex) {
ROS_FATAL("Failed to create the %s planner, are you sure it is properly registered and that the containing library is built? Exception: %s", global_planner.c_str(), ex.what());
exit();
}

将它修改为:

    //initialize the global planner
try {
planner_ = bgp_loader_.createInstance(global_planner);
planner_->initialize(bgp_loader_.getName(global_planner), planner_costmap_ros_);
}
catch (const pluginlib::LibraryLoadException& ex) {
ROS_FATAL("pluginlib::LibraryLoadException");
exit();
}
catch (const pluginlib::ClassLoaderException& ex) {
ROS_FATAL("pluginlib::ClassLoaderException");
exit();
}
catch (const pluginlib::LibraryUnloadException& ex) {
ROS_FATAL("pluginlib::LibraryUnloadException");
exit();
}
catch (const pluginlib::CreateClassException& ex) {
ROS_FATAL("pluginlib::CreateClassException");
exit();
}
catch (const pluginlib::PluginlibException& ex) {
ROS_FATAL("Failed to create the %s planner, are you sure it is properly registered and that the containing library is built? Exception: %s", global_planner.c_str(), ex.what());
exit();
}

就可以看到具体的错误原因了,local planner和global planner方法相似。

如何替换ROS中默认的Planner的更多相关文章

  1. ROS中的日志(log)消息

    学会使用日志(log)系统,做ROS大型项目的主治医生 通过显示进程的运行状态是好的习惯,但需要确定这样做不会影响到软件的运行效率和输出的清晰度.ROS 日志 (log) 系统的功能就是让进程生成一些 ...

  2. 设置sublime text2/3中默认预览浏览器快捷键的方法

    各位前端大神们,大家在用IDE编辑器的时候喜欢用哪些呢?是Dreamweaver.Zend Studio.editplus又或者是sublime text?今天马浩周给大家就要说说设置sublime ...

  3. Jenkins进阶系列之——01使用email-ext替换Jenkins的默认邮件通知

    1 简述 众所周知,Jenkins默认提供了一个邮件通知,能在构建失败.构建不稳定等状态后发送邮件.但是它本身有很多局限性,比如它的邮件通知无法提供详细的邮件内容.无法定义发送邮件的格式.无法定义灵活 ...

  4. 将ROS中的/sensor_msgs/NavSatFix数据导入google earth显示轨迹

    将ros中的gps_msg数据导入google earth显示轨迹 [TOC] 1. 获取GPS数据 将ros中发布的gps topic输出到文本中 rostopic echo -p /gpsData ...

  5. ROS中的CMakeLists.txt

    在ROS的编程过程中,如果CMakeLists.txt如果写不好,编译就很难成功.如果看不懂CMakeLists.txt那么很多错误你也不知道时什么回事.所以深入了解它是很有必要的.现在我们就来看看它 ...

  6. ROS中利用V-rep进行地图构建仿真

    V-rep中显示激光扫描点  在VREP自带的场景中找到practicalPathPlanningDemo.ttt文件,删除场景中多余的物体只保留静态的地图.然后在Model browser→comp ...

  7. ROS中发布激光扫描消息

    激光雷达工作时会先在当前位置发出激光并接收反射光束,解析得到距离信息,而后激光发射器会转过一个角度分辨率对应的角度再次重复这个过程.限于物理及机械方面的限制,激光雷达通常会有一部分“盲区”.使用激光雷 ...

  8. ROS中发布IMU传感器消息

    下面使用SYD Dynamics的9轴AHRS(Attitude and heading reference system),来发布sensor_msgs/Imu类型的消息. 将传感器用USB转串口接 ...

  9. 使用itext直接替换PDF中的文本

    直接说问题,itext没有直接提供替换PDF中文本的接口(查看资料得到的结论是PDF不支持这种操作),不过存在解决思路:在需要替换的文本上覆盖新的文本.按照这个思路我们需要解决以下几个问题: itex ...

随机推荐

  1. django第一次(转自刘江大佬)

    下面的模型定义了一个“人”,它具有first_name和last_name字段: from django.db import models class Person(models.Model): fi ...

  2. Servlet的介绍

    Servlet由来 做过BS项目的人都知道,浏览器能够根据HTML静态标记语言来显示各式各样的网页.但是如果我们需要在网页上完成一些业务逻辑:比如登陆验证.或者说网页显示的内容在服务器的数据库中.如果 ...

  3. Android的简述

    程序截图 先来简单了解下程序运行的效果 程序入口点  类似于win32程序里的WinMain函数,Android自然也有它的程序入口点.它通过在AndroidManifest.xml文件中配置来指明, ...

  4. Lexical or preprocessor 'XXX/XXX.h' issue file not found

    最近做第三方登录,引入了第三库,结果就出来个这个问题.如下图所示: 刚开始编译运行都没问题,可下次再打开时就报这个错误…… 一个比较弱智的解决办法: 1. 删除第三方库文件(删除到垃圾箱,而且还要在文 ...

  5. 【python-Django开发】Django 配置MySQL数据库讲解!!!

    官方文档请阅读:https://docs.djangoproject.com/en/1.11/ref/databases/#mysql-db-api-drivers 配置MySQL数据库 1. 新建M ...

  6. 全开源C++ DirectUI 界面库SOUI 3.0更新

    从2019.5.22开始,SOUI版本号更新到2.9.0.2,后面开始准备3.0的开发,历时近3个月,现在3.0的主要工作基本完成. 为了便于大家区别2.x,3.0启用了新的代码仓库:https:// ...

  7. Maven从入门到放弃

    1.maven是什么? maven是Apache下的一个纯java开发的一个开源项目,它是一款能够抽象构建过程,并且提供依赖管理,中央仓库,自动下载构建等功能的项目构建工具. 2.为什么要使用mave ...

  8. java常见面试题目(二)

    部分没有答案可以自行百度. 1.myeclipse与eclipse的区别. 2.说说对maven或者SVN的理解. 3.类的加载过程 (创建对象的过程)  1)子父类里静态属性 赋上默认初始值 如果有 ...

  9. WebGL简易教程(二):向着色器传输数据

    目录 1. 概述 2. 示例:绘制一个点(改进版) 1) attribute变量 2) uniform变量 3) varying变量 3. 结果 4. 参考 1. 概述 在上一篇教程<WebGL ...

  10. java并发编程(十三)----(JUC原子类)引用类型介绍(CAS和ABA的介绍)

    这一节我们将探讨引用类型原子类:AtomicReference, AtomicStampedRerence, AtomicMarkableReference.AtomicReference的使用非常简 ...