这是一个管理ros代码的工程管理工具,基于cmake,但是比cmake多更多功能,是cmake上层的代码管理规则
ros之前采用的是ros_build,现在用catkin;catkin是cmake宏和用于构建ROS某些部分的相关python代码的集合;
不安装ros的情况下,也可以使用catkin进行项目工程管理。
但需要安装catkin或将catkin package包含在项目工程文件中,这样就可以使用catkin最外层CMakeLists.txt 方便的进行项目构建与管理。
也可以像ros工程文件那样,在catkin_ws中直接使用catkin_make进行项目构建。
1. 如果没有安装catkin,或catkin未包含在工程文件中,cmake .. 时无法识别catkin相关指令;
2. 使用catkin进行项目管理时,每个功能包必须有package.xml文件,否则cmake .. 时会报错; package.xml中,对于未安装的self-developed package,需要配置
3. CMake 及 CMakeLists.txt 使用小结 https://blog.csdn.net/reasonyuanrobot/article/details/106723888
Catkin具有以下依赖性
——CMake 一个跨平台的开源构建系统。
——Python 一种通用的解释性高级编程语言,版本2.7。
————catkin_pkg 一个用于catkin的Python运行库。
————empy 一个Python模板库。
————nose 一个Python测试框架。
——GTest 一种Google的c++单元测试框架。
——GNU C++编译器(g++)- GNU C++编译
安装以上依赖项
~$ sudo apt-get install cmake
~$ sudo apt-get install python-catkin-pkg
~$ sudo apt-get install python-empy
~$ sudo apt-get install python-nose
~$ sudo apt-get install python-setuptools
~$ sudo apt-get install libgtest-dev
~$ sudo apt-get install build-essential
下载:
~$ sudo apt-get install git
~$ git clone https://github.com/ros/catkin
1. 将catkin package包含在项目工程文件中
只能在该项目中使用,其它项目找不到catkin package
文件结构类似下图:
2.构建并安装
其它项目都可使用
~$ cd catkin/
~$ cd build
~$ cmake -DCMAKE_BUILD_TYPE=Release ../
~$ make
~$ sudo make install
安装完之后,需参照 https://blog.csdn.net/reasonyuanrobot/article/details/117335278 ,解决find_package(catkin)失败的问题。
将 .catkin 的路径添加到CMAKE_PREFIX_PATH中。
【1】http://wiki.ros.org/catkin#Installing_catkin
【2】http://docs.ros.org/jade/api/catkin/html/user_guide/installation.html
http://wiki.ros.org/catkin
https://docs.ros.org/en/api/catkin/html/
源码:https://github.com/ros/catkin
Ubuntu 16.04下源码安装Catkin https://blog.csdn.net/willwinston/article/details/80714334
catkin_make的时候发生了什么 https://blog.csdn.net/bluewhalerobot/article/details/73658162
catkin的原理和流程和CMake很类似,与rosbuild相比,它的可移植性,以及对交叉编译的支持更好。
catkin基于CMake实现,CMakeList的语句与基本CMake一致,常用的包括:
add_subdirectory():一般情况下,我们的项目各个子项目都在一个总的项目根目录下,但有的时候,我们需要使用外部的文件夹,怎么办呢?add_subdirectory
命令,可以将指定的文件夹加到build任务列表中。
固定,无需更改
# toplevel CMakeLists.txt for a catkin workspace
# catkin/cmake/toplevel.cmake
cmake_minimum_required(VERSION 2.8.3)
set(CATKIN_TOPLEVEL TRUE)
# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
RESULT_VARIABLE _res
OUTPUT_VARIABLE _out
ERROR_VARIABLE _err
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
if(NOT _res EQUAL 0 AND NOT _res EQUAL 2)
# searching fot catkin resulted in an error
string(REPLACE ";" " " _cmd_str "${_cmd}")
message(FATAL_ERROR "Search for 'catkin' in workspace failed (${_cmd_str}): ${_err}")
endif()
# include catkin from workspace or via find_package()
if(_res EQUAL 0)
set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake")
# include all.cmake without add_subdirectory to let it operate in same scope
include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_SCOPE)
add_subdirectory("${_out}")
else()
# use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
# or CMAKE_PREFIX_PATH from the environment
if(NOT DEFINED CMAKE_PREFIX_PATH)
if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
endif()
endif()
# list of catkin workspaces
set(catkin_search_path "")
foreach(path ${CMAKE_PREFIX_PATH})
if(EXISTS "${path}/.catkin")
list(FIND catkin_search_path ${path} _index)
if(_index EQUAL -1)
list(APPEND catkin_search_path ${path})
endif()
endif()
endforeach()
# search for catkin in all workspaces
set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
find_package(catkin QUIET
NO_POLICY_SCOPE
PATHS ${catkin_search_path}
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
unset(CATKIN_TOPLEVEL_FIND_PACKAGE)
if(NOT catkin_FOUND)
message(FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before.")
endif()
endif()
catkin_workspace()
robot_mission_planner_pick
1.0.0
URDF Description package for robot_model
This package contains configuration data, 3D models and launch files
for robot_model robot
me
BSD
catkin
utils
apriltags
utils
apriltags