如何替换ROS中默认的Planner
官方文档参阅: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的更多相关文章
- ROS中的日志(log)消息
学会使用日志(log)系统,做ROS大型项目的主治医生 通过显示进程的运行状态是好的习惯,但需要确定这样做不会影响到软件的运行效率和输出的清晰度.ROS 日志 (log) 系统的功能就是让进程生成一些 ...
- 设置sublime text2/3中默认预览浏览器快捷键的方法
各位前端大神们,大家在用IDE编辑器的时候喜欢用哪些呢?是Dreamweaver.Zend Studio.editplus又或者是sublime text?今天马浩周给大家就要说说设置sublime ...
- Jenkins进阶系列之——01使用email-ext替换Jenkins的默认邮件通知
1 简述 众所周知,Jenkins默认提供了一个邮件通知,能在构建失败.构建不稳定等状态后发送邮件.但是它本身有很多局限性,比如它的邮件通知无法提供详细的邮件内容.无法定义发送邮件的格式.无法定义灵活 ...
- 将ROS中的/sensor_msgs/NavSatFix数据导入google earth显示轨迹
将ros中的gps_msg数据导入google earth显示轨迹 [TOC] 1. 获取GPS数据 将ros中发布的gps topic输出到文本中 rostopic echo -p /gpsData ...
- ROS中的CMakeLists.txt
在ROS的编程过程中,如果CMakeLists.txt如果写不好,编译就很难成功.如果看不懂CMakeLists.txt那么很多错误你也不知道时什么回事.所以深入了解它是很有必要的.现在我们就来看看它 ...
- ROS中利用V-rep进行地图构建仿真
V-rep中显示激光扫描点 在VREP自带的场景中找到practicalPathPlanningDemo.ttt文件,删除场景中多余的物体只保留静态的地图.然后在Model browser→comp ...
- ROS中发布激光扫描消息
激光雷达工作时会先在当前位置发出激光并接收反射光束,解析得到距离信息,而后激光发射器会转过一个角度分辨率对应的角度再次重复这个过程.限于物理及机械方面的限制,激光雷达通常会有一部分“盲区”.使用激光雷 ...
- ROS中发布IMU传感器消息
下面使用SYD Dynamics的9轴AHRS(Attitude and heading reference system),来发布sensor_msgs/Imu类型的消息. 将传感器用USB转串口接 ...
- 使用itext直接替换PDF中的文本
直接说问题,itext没有直接提供替换PDF中文本的接口(查看资料得到的结论是PDF不支持这种操作),不过存在解决思路:在需要替换的文本上覆盖新的文本.按照这个思路我们需要解决以下几个问题: itex ...
随机推荐
- 模拟器无Back、Menu等键
问题如图所示: 解决方法: 1. 打开Android Virtual Device (AVD) Manager --> 选择模拟器,并点击edit --> 勾选KeyBoard中的选项,并 ...
- 【Java】判断字符串是否含字母
用正则表达式,示例代码如下: String str = "123abc"; Pattern.compile("(?i)[a-z]]").matcher(str) ...
- Ubuntu中修改默认开机项
1首先,按住Ctrl+Alt+t打开终端 2输入cd /etc/default 3输入sudo sudo nano grub 并按照提示输入密码 4在我们开机的时候,可以看到自己想要默认的开机项是多少 ...
- (转)Linux LVM逻辑卷配置过程详解(创建、扩展、缩减、删除、卸载、快照创建)
一.预备知识 LVM全称为Logical Volume Manager 逻辑卷管理器,LVM是Linux环境中对磁盘分区进行管理的一种机制,是建立在硬盘和分区之上.文件系统之下的一个逻辑层,可提高磁盘 ...
- 浅谈 ASCII、Unicode、UTF-8,一目了然
对于ASCII.Unicode.UTF-8这三种编码方式我们经常用到,也经常挂到嘴边,但他们是怎么来的,为什么要存在,具体是怎么个规则,我们并没有做深入了解,下面,就带你看一下他们到底是怎么回事吧…… ...
- Spring Security (CORS)跨域资源访问配置
1.CORS介绍 CORS是一个W3C标准,全称是"跨域资源共享"(Cross-origin resource sharing).它允许浏览器向跨源(协议 + 域名 + 端口)服务 ...
- WebGL简易教程(二):向着色器传输数据
目录 1. 概述 2. 示例:绘制一个点(改进版) 1) attribute变量 2) uniform变量 3) varying变量 3. 结果 4. 参考 1. 概述 在上一篇教程<WebGL ...
- 关于JVM内存溢出的原因分析及解决方案探讨
前言:JVM中除了程序计数器,其他的区域都有可能会发生内存溢出. 0.什么是内存溢出 当程序需要申请内存的时候,由于没有足够的内存,此时就会抛出OutOfMemoryError,这就是内存溢出. 1. ...
- template.demo.js
<!DOCTYPE html><html><head> <title>index</title> <meta charset=&quo ...
- final,权限,引用类型数据
1. final关键字 1.概述 为了避免子类出现随意改写父类的情况,java提供了关键字final,用于修饰不可改变内容 final:不可改变,可以修饰类,方法和变量 类:被修饰的类,不能用于继承 ...