码迷,mamicode.com
首页 > 其他好文 > 详细

ros之调用其他rospackage

时间:2018-11-13 02:55:53      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:nat   href   run   lag   under   pre   port   export   require   

ros之调用其他rospackage

Every package should only implement just one funtion, add the exported interfaces to libraries for exported usages.
It is worth doing so, it can make software flexiable, maintainable.

How to use the packages with exported libraries

Here is an example:
pointmatch-ros is the package to be called.

  • lidar_location is the package to implement the localization using the pointmatch-ros pacakge.

Add exported libraries and other information(like include_dirs) in catkin_package

According to the
(catkin/CMakeLists.txt)[http://wiki.ros.org/catkin/CMakeLists.txt]

  1. catkin_pacakge():
- INCLUDE_DIRS - The exported include paths (i.e. cflags) for the package
- *LIBRARIES* - The *exported libraries* from the project
- CATKIN_DEPENDS - Other catkin projects that this project depends on
- DEPENDS - Non-catkin CMake projects that this project depends on. For a better understanding, see this explanation.
- CFG_EXTRAS - Additional configuration options

Add the exported libraries and other information to the catkin_package like this (here the exported libraries is pointmatcher_ros):

#+BEGIN_SRC cmake
catkin_package(
INCLUDE_DIRS include
LIBRARIES pointmatcher_ros
CATKIN_DEPENDS
roscpp
sensor_msgs
nav_msgs
tf
tf_conversions
eigen_conversions
libpointmatcher
)
#+END_SRC

catkin_package is added for what you want to exported for other packages, like the exported libraries and exported header files.

Add libpointmatch_ros package to the depend of lidar_location in the package.xml

#+BEGIN_SRC xml
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>message_filters</build_depend>
<build_depend>tf</build_depend>
<build_depend>tf_conversions</build_depend>
<build_depend>libpointmatcher_ros</build_depend>
<build_depend>message_generation</build_depend>

<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>message_filters</run_depend>
<run_depend>tf</run_depend>
<run_depend>tf_conversions</run_depend>
<run_depend>libpointmatcher_ros</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>message_generation</run_depend>
#+END_SRC

Add libpointmatcher_ros package to find_package() in CMakeLists.txt

#+BEGIN_SRC cmake
find_package(catkin REQUIRED COMPONENTS 
             roscpp std_msgs sensor_msgs geometry_msgs 
             message_filters tf tf_conversions 
             libpointmatcher_ros message_generation)
    #+END_SRC

Now the pointmatcher_ros library is now in the ${catkin_LIBRARIES}.
Use the library by target_link_libraries.

ros之调用其他rospackage

标签:nat   href   run   lag   under   pre   port   export   require   

原文地址:https://www.cnblogs.com/ChrisCoder/p/9949630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!