在很多的时候,我们需要将编译好的ROS软件给第三方集成打包发布。当然我们可以使用.deb
的形式释放。但是多方联合开发的项目就不是很方便。于是我们可以使用ROS catkin_make
来集成发布。
步骤如下:
- 在源代码工程中使用
catkin_make install
进行编译,完成后会将所要释放的程序和配置文件拷贝到 install文件夹下。
$ ls install/
env.sh lib local_setup.bash local_setup.sh local_setup.zsh setup.bash setup.sh _setup_util.py setup.zsh share
- 将
install
下的lib
,share
拷贝到需要发布到的工程中src
下
/src$ tree -L 2
.
├── CMakeLists.txt -> /opt/ros/melodic/share/catkin/cmake/toplevel.cmake
├── core
│ ├── CMakeLists.txt
│ ├── lib
│ ├── package.xml
│ └── share
如上所述core文件夹
下的 lib
和 share
就是发布的内容。
- 再次通过
catkin_make
来集成发布就需要在core文件夹下
新建CMakeLists.txt
与package.xml
。
CMakeLists.txt
内容如下:
cmake_minimum_required(VERSION 2.8.3)
project(core)
find_package(catkin REQUIRED)
catkin_package(
# INCLUDE_DIRS include
# CATKIN_DEPENDS other_catkin_pkg
# DEPENDS system_lib
)
###########
## Build ##
###########
include_directories(
# include
# ${catkin_INCLUDE_DIRS}
)
#############
## Install ##
#############
## Mark other files for installation (e.g. launch and bag files, etc.)
install(DIRECTORY lib/
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} USE_SOURCE_PERMISSIONS
FILES_MATCHING PATTERN "*"
)
install(DIRECTORY share/
DESTINATION ${CATKIN_GLOBAL_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS
)
package.xml
内容如下:
<?xml version="1.0"?>
<package format="2">
<name>core</name>
<version>1.0.0</version>
<description>The core package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<maintainer email="core@todo.todo">core</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
- 使用
catkin_make install
就可以进行程序的发布。