Click the green button use this template
, this will bring you to project generation page, after filling in all requried information, click "Create repository from template", and that's all! A repository is created in your Github account, just clone that newly created repository then you can start develop awesome ROS package!
This repository contains several ros examples, using publisher/subscriber
, services
, and dynamic_reconfigure
. These examples will need certain files created under certain directory, if you are not going to use, say, dynamic_reconfigure, then in addition to delete the code related to it, you also need to remove the folder cfg
, to do so:
git rm -r <unnecessary_folders> # in the case mentioned above, <unnecessary_folders> will be "cfg"
For example, for non vscode user, you would like to git rm -r .vscode
; for those whose project doesn't publish or advertise any custom services, git rm -r msg
and git rm -r srv
. Also, remember to remove unused ros dependencies in package.xml
.
This part is not about modifying hpp/cpp files, we only focus on CMakeLists.txt
and other non cpp files. Some changes that needs to be done are obvious enough (if you didn't do it, cmake can't even pass configure stage) and are thus omitted here.
-
Continuous Integration
Click to expand
-
Those badges, of course
-
coverage report name
-
github action (
.github/workflows/industrial_ci_action.yml
)(not valid until github action support top-levelPKG_NAME
env
variable substition, current setup assumes that the repository name is the same as project name, if that is not the case, replace all${{ github.event.repository.name }}
with your project name)RT_FLAG
(and possibly files under/tool/sanitizer
(TODO)) in jobrun_sanitizer
, these are used to enable/disable sanitize flags during runtime
-
travis CI (.travis.yml)
-
-
vscode user
Click to expand
-
plugin
vscode-ros
is recommended. If installed, few things are configurabletarget
inlaunch.json
-
catkin_ws.path
, possiblyros.path
in.vscode/c_cpp_properties.json
, andros.distro
insettings.json
ros.path
referencesros.distro
, which is automatically generated byvscode-ros
. If plugin is not installed, you would need to specify it. Remeber to reload window (ctrl + shift + P
, typereload
) for settings to take effect
-
-
ROS related:
Click to expand
-
dynamic_reconfigure
PACKAGE
andRECONFIGURE_NAME
incfg/RosPkgTemplateExample.cfg
(see this for more detail)- if you are not going to use it, remove dependency
dynamic_reconfigure
inpackage.xml
-
msg
/srv
- Remember to add dependent messages/services in
package.xml
, otherwise even the project can compile in local machine, it won't pass CI since the dependencies are installed viarosdep
- Remember to add dependent messages/services in
-
cpp version
CMAKE_CXX_STANDARD
,CMAKE_CXX_STANDARD_REQUIRED
andCMAKE_CXX_EXTENSIONS
in top-levelCMakeLists.txt
(recommend to change onlyCMAKE_CXX_STANDARD
, or usetarget_compile_options
instead of these three CMake variables)
-
-
any versoin of gcc or clang will do since you can change the
CMAKE_CXX_STANDARD
to match the compiler you have-
gcc
sudo apt install build-essential
-
clang
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
-
-
CMake
You probably want (and is recommended) to use latest version of CMake for almost all the time, see here to download and install latest version cmake. Some CMake variables require CMake to be greater than certain version to work, for example:
CMAKE_CXX_CLANG_TIDY
: version greater than 3.6check_ipo_supported
,CMAKE_INTERPROCEDURAL_OPTIMIZATION
: version greater than 3.9CMAKE_CXX_CPPCHECK
: version greater than 3.10.3CMAKE_CXX_COMPILER_LAUNCHER
: version greater than 3.17
All ros dependencies should be able to be installed via rosdep
(not an expert regarding rosdep, need to spend some time on it):
rosdep install <your package name> # e.g. rosdep install ros_pkg_template
I personally prefer to only let rosdep
handle dependencies that are also used by ros library implementation you depend on, for instance, boost, eigen, etc. For other dependencies that are not the case, such as cgal, use package manager e.g. conan, or vcpkg would be better.
Disclaimer: since I am a "you-should-always-use-the-latest-version-of-library" kind of guy, libraries installed from os pacakaging tool are almost always out of date, and therefore I would definitely not recommend it, lol.
-
gcov and gcovr for code coverage report
-
gcov comes with gcc, see previous section regarding installation of gcc
-
gcovr can be installed via pip (see here to check the python version each release supports)
pip install gcovr
-
-
Follow their instruction guide in order to build latest version from source, otherwise
sudo apt install google-perftools
-
ccache or sccache to speed up compilation (these require cmake version greater than 3.17)
-
ccache: see here to build from source, or just do the following
sudo apt-get install ccache
-
sccache: install via cargo (Rust package manager) or snap
sudo snap install sccache --candidate --classic
or (this require Rust to be installed, literally build from source)
cargo install sccache
-
-
This one is a bit tricky, you probably need to follow there installation guide
-
sudo apt-get install cppcheck
-
clang-tidy
should come with llvm nightly packages already, if you do not have a clang compiler installed:sudo apt-get install clang-tools
catkin build --this
Most of the build options are in cmake helper script, but some aren't, e.g. CMAKE_BUILD_TYPE. Unfortunately, catkin doesn't provide any way to view all options in cmake. One of the work around is to use cmake-gui
, and manually specify build directory and source directory.
catkin run_tests --this
Notice you must run catkin build --this
before catkin run_tests --this
, this can be easily forgotten and lead to some stupid mistake.
- refine CI logic
- Add CI test for each cmake helper script functionality?
- documentation on cmake helper script function
- cppcheck flag is not generic enough
- come back to those installation command in cmake
- cpp_starter_project, most of the CMake scripts under
cmake
are from this template repository - Professional CMake_ A Practical Guide (2018) by Craig Scott