问题
在编译cartographer的代码包的时候,会被建议使用catkin_make_isolated,为何不使用catkin_make呢?
原因
catkin_make was the first script around to build catkin workspace and is therefore used in many tutorials. It has several down sides (requiring non-standard logic in packages to declared cross-package target dependencies) and limitation (can't process plain CMake packages, requires all targets across all packages in a workspace to be unique). Therefore I wouldn't recommend to use it.
catkin_make_isolated is the script which was developed next which addresses all these shortcomings. It comes at the cost of being slower since it processes all packages sequentially. It is being used on build.ros.org in the devel and PR jobs. I would recommend using this if you want the most reliable solution (exclusively for ROS 1).
catkin_tools (called catkin build above) is similar to catkin_make_isolated but addresses the performance limitation by processing packages in parallel where possible. It also has a lot of usability features which makes it much easier to use and configure. On the downside this tool is not being actively maintained for the past years so I wouldn't recommend it either.
colcon is the new build tool developed for ROS 2 and works similar to catkin_tools with less usability features at the moment but being able to build any kind of packages (catkin, ament, CMake, Python setuptools, gradle, bazel, cargo, ...) on all major platforms (Linux, macOS, Windows). While developed for ROS 2 it in principle also works for ROS 1. If you are willing to use something more bleeding edge (which might come with quirks which haven't been resolved / polished yet) this might be an option. The big advantage is that the tool is very modular and actively developed and extended by multiple parties.
总的来说, catkin_make_isolated比catkin_make更好一点, catkin_make_isolated编译时,会认为每一个功能包都是一个独立的编译空间, 因此不会像catkin_make需要求所有定义的目标变量名必须是唯一值以免冲突, 而colcon工具目前主要在ros2上开发应用,当然也可以适用于ros1的开发。
使用
catkin_make_isolated --use-nija --install --pkg [user's package name]
在ros下,如何添加环境变量呢?因为该命令将每个代码包独立编译以及创建开发目录,需要添加以下命令到.bashrc文件中, 才能保证使用rosrun等ros相关命令的时候, 才能找到相关的launch等文件,
source ~/catkin_ws/install_isolated/setup.bash
或者
source ~/catkin_ws/devel_isolated/pkg_name/setup.bash