写在前面
我在CSDN上写了一套关于ros基础的图文教程,欢迎关注!!!
移植自己的node到nodelet的流程:
add the necessary #includes: 添加必要头文件
get rid of int main(): 删除main函数
subclass nodelet::Nodelet: 继承Nodelet class
move code from constructor to onInit(): 把原来的node类中的构造函数移植到nodelet的初始化函数中,因为nodelet的构造函数无参
add the PLUGINLIB_EXPORT_CLASS macro: 使用pluginlib的宏来注册插件
add <build_depend> and <run_depend> dependencies on nodelet in the package manifest.:添加build_depend 和 run_depend到package.xml文件中
create the .xml file to define the nodelet as a plugin: 创建对应插件的.xml描述文件
add the <nodelet> item in the <export> part of the package manifest:将7中写好的xml放在package.xml文件的export部分
make the necessary changes to CMakeLists.txt (comment out a rosbuild_add_executable, add a rosbuild_add_library) : 在cmakelist中做对应修改