Coder Social home page Coder Social logo

mrt_cmake_modules's Introduction

MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))

Maintainer status: maintained

Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package for your dependencies, etc.

Well, this is exactly what mrt_cmake_modules do for you! The only thing you have to do is:

  • Keep your files in a fixed structure,
  • keep library and executable code in separate packages and
  • make sure the package.xml actually contains all the packages you depend on.

If you don't want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.

On the other hand, you get a lot of things for free:

  • Resolution of your dependencies in CMake
  • Automatic generation of Nodes/Nodelets
  • Supports C++ and Python(2/3)
  • Python bindings for pybind11/boost-python
  • Automated unittest detection and execution (including ROS tests)
  • Automated code coverage generation
  • Support for sanitizers
  • Support for running clang-tidy
  • Automated install of your scripts/launchfiles/executables/libraries... to the correct location
  • experimental support for ROS2 and Conan builds

*) Actually MRT stands for Institut für Mess- und Regelungstechnik, the institute that develops this package.

Building

mrt_cmake_modules is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin and lcov (for code coverage).

Getting started

Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]. This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros and --exe flags):

  • Library package: They have no dependency to ros (except catkin). Their goal is to either build a lib<package>.so, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course.
  • Ros library package (--ros): Similar to the above, but can also contain message, action or configuration files
  • Executable package (--exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
  • Node/Nodelet package (--ros --exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.

Package structure

The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.

Libraries

Here is the structure of a package called example_package. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros:

.
├── CMakeLists.txt                    # The generated CMakeLists
├── include                           # The headers of this package. Available in the whole package
│   └── example_package               # It is a ROS convention to keep them within include/<package_name>
│       ├── a_header.hpp
│       └── internal                  # Headers here are only to be used within cpp files of this package
│           └── internal_header.hpp
├── msg
│   └── a_message.msg                 # Messages files that will be automatically generated (only available for --ros)
├── package.xml                       # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api                        # Folder for python bindings. Every file here becoms a module
│   ├── python_bindings.cpp           # Will be available as "import example_package.python_bindings"
│   └── more_python_bindings.cpp      # Refer to the pybind11 doc for the content of this file
├── README.md                         # The readme
├── src                               # Every cpp file in this filder will become part of libexample_package.so
│   ├── examplefile.cpp
│   ├── onemorefile.cpp
│   └── example_package               # Python modules have to go to src/<package_name>
│       ├── pythonmodule.py           # Will be available as "import example_package.pythonmodule"
│       └── __init__.py
└── test                              # Contains the unittests. Will be executed when running the test or run_tests target
    ├── test_example_package.cpp      # Every file here will be a separate unittest executable
    └── test_pyapi.py                 # Every py file that matches the testMatch regular expression will be executed
                                      # using nosetest. Executables are ignored. See https://nose.readthedocs.io/

Note that everything in this structure is optional and can be left away if you don't need it (except for the CMakeLists.txt of course).

Executables, Nodes and Nodelets

Here is the structure of a package called example_package_ros_tool. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros:

.
├── CMakeLists.txt
├── cfg
│   └── ConfigFile.cfg                    # Files to be passed to dynamic_reconfigure
├── launch                                # Contains launch files provided by this package
│   ├── some_node.launch
│   ├── some_nodelet.launch
│   ├── some_python_node.launch
│   └── params                            # Contains parameter files that will be installed
│       ├── some_parameters.yaml
│       └── some_python_parameters.yaml
├── nodelet_plugins.xml                   # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml                           # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts                               # Executable scripts that will be installed. These can be python nodes as well
│   ├── bias_python_node.py
│   └── bias_script.sh
├── src                                   # Every folder in here will be a node/nodelet or both
│   ├── nodename                          # nodename is the name of the node/nodelet
│   │   ├── somefile.cpp                  # Files compiled into the node and the nodelet
│   │   ├── somefile.hpp
│   │   ├── some_node.cpp                 # files ending with _node will end up being compiled into the node executable
│   │   └── a_nodelet.cpp                 # files ending whth _nodelet will end up as part of the nodelet library
│   └── example_package_ros_tool          # python modules have to go to src/<package_name>.
│       ├── node_module_python.py         # These files can provide the node implementation for the scripts
│       └── __init__.py
└── test                                  # The unittests
    ├── test_node.cpp                     # Every pair of .cpp and .test files represents one rostest
    ├── test_node.test
    ├── test.cpp                          # A cpp file without a matching .test a normal unittest and launched without ROS
    ├── node_python_test.py               # Same for .py and .test files with the same name. The .py file must be executable!
    └── node_python_test.test

For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.

Generating code coverage

By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE (e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true). Setting this requires a recompilation of the project. If this is set, running the run_tests target will run the unittests and afterwards automatically generate an html coverage report. The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2, it will also be opened in firefox afterwards.

Sanitizing your code

The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime. Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan. You can enable them similarly to the code coverage by setting the MRT_SANITIZER cmake variable. It has two possible values:

  • checks (enables Asan and UBsan)
  • check_race (enables tsan)

If one of the sanitzers discovers an error at runtime, it will be printed to cerr.

Using clang-tidy

Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed. You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details. You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY.

If you set it to "check", clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to "fix" the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the "fix" mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.

How dependency resolution works in detail

The mrt_cmake_modules parse your manifest file (i.e. package.xml) in order to figure out your dependencies. The following lines in the CMakeLists.txt are responsible for this:

find_package(mrt_cmake_modules REQUIRED)                          # finds this module
include(UseMrtStdCompilerFlags)                                   # sets some generally useful compiler/warning flags
include(GatherDeps)                                               # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES})  # resolves your dependencies by calling find_package appropriately.

AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package. The result is written into MRT_INCLUDE_DIRS, MRT_LIBRARIES and MRT_LIBRARY_DIRS. These variables should be passed to the cmake targets.

The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables it will set by the script if successful. These will then be appended to the MRT_* variables.

CMake API

This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install(), mrt_add_node_and_nodelet(), mrt_add_library(), etc. The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists. See here for a full documentation.

Findscripts

This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.

Going further

After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template. All you have to do is write a .rosif file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!

mrt_cmake_modules's People

Contributors

autonomobil avatar christiankinzig avatar christophburger89 avatar filiperinaldi avatar florianwirth avatar janstrohbeck avatar johannesbeck avatar jquehl avatar keroe avatar koenigshof avatar kroeper avatar m-naumann avatar olesalscheider avatar omersahintas avatar poggenhans avatar shenyinzhe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mrt_cmake_modules's Issues

Link a library from other package

I am trying to link a library from other ros package to a ros package. I understand that the mrt_cmake_modules should make these entire dependency linkage process smooth and easy, but I am having some trouble linking a library to my package.

I am working on the LIMO SLAM package (link) which rely on the mrt_cmake_modules to generate the dependencies.

In the LIMO SLAM project, different ros packages from other git repos are used and linked.
With the dependencies auto-generated, the launch file can instantiate other package's module. However, what I need is more than this.

I need my main program (also auto-generated through mrt_cmake_modules) to include the headers from other packages. The main program is demo_keyframe_bundle_adjustment_meta/apps/main_program.cpp in my repo. I want it to be able to include the header from an external package called image_preprocessing_tool.

I organized the package structure of the image_preprocessing_tool to be compatible with mrt_cmake_modules guide. I was expecting the mrt_cmake_modules to auto-generate the linkage by putting this package name to my main package, but sadly it does not seem working.

I noticed that the cmake macro MRT_INCLUDE_DIR and the MRT_LIBRARIES seem to be empty which I suppose should contain the paths for the dependent packages. When I added hard coded paths into the cmakelist file, the code worked.

I don't know if I conveyed my problem clearly.

I wasn't sure how to use the mrt_cmake_modules properly for this task.

I would appreciate any help.
Thank you for your help in advance.

CMAKE_NO_SYSTEM_FROM_IMPORTED

The following line is creating problems in my project: https://github.com/KIT-MRT/mrt_cmake_modules/blob/master/cmake/mrt_cmake_modules-macros.cmake#L26

This tells CMake that all imported targets should have their INTERFACE_INCLUDE_DIRECTORIES not treated as SYSTEM-includes. This generates large amounts of warnings for me with other third-party software, e.g. Eigen or libtorch, when using stricter global compiler warning settings. I don't think a package like mrt_cmake_modules should set/override such global CMake settings. Maybe there is a better solution for this? My current workaround is to restore the default using set(CMAKE_NO_SYSTEM_FROM_IMPORTED NO) after importing mrt_cmake_modules (which is an implicit dependency of lanelet2 in my case).

FindAutoDeps doesn't work with boost 1.71

Hello, I caught an error when using mrt_cmake_modules and lanelet2.

I could build lanelet2_core if I manually remove boost from ${DEPENDEND_PACKAGES}, but when other packages (e.g. lanelet2_io) call AutoDeps with lanelet2_core, it causes the error again.

I'd appreciate it if you give me any information to solve this problem.

Environment

  • Ubuntu 20.04
  • ROS Noetic
  • Python 3.8.2
  • CMake 3.16.3

Problem

FindAutoDeps causes an error because of boost_signals which was deleted and replaced by boost_signals2 at v1.69.

https://www.boost.org/users/history/version_1_69_0.html

$ colcon build 
Starting >>> mrt_cmake_modules
Finished <<< mrt_cmake_modules [0.21s]                                
Starting >>> lanelet2_core
--- stderr: lanelet2_core                          
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package):
  Could not find a package configuration file provided by "boost_signals"
  (requested version 1.71.0) with any of the following names:

    boost_signalsConfig.cmake
    boost_signals-config.cmake

  Add the installation prefix of "boost_signals" to CMAKE_PREFIX_PATH or set
  "boost_signals_DIR" to a directory containing one of the above files.  If
  "boost_signals" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:443 (find_package)
  /home/kenji/lanelet2_ws/install/mrt_cmake_modules/share/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:196 (find_package)
  /home/kenji/lanelet2_ws/install/mrt_cmake_modules/share/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:253 (_find_dep)
  CMakeLists.txt:21 (find_package)


make: *** [Makefile:1328: cmake_check_build_system] Error 1
---
Failed   <<< lanelet2_core	[ Exited with code 2 ]

Summary: 1 package finished [0.89s]
  1 package failed: lanelet2_core
  1 package had stderr output: lanelet2_core
  9 packages not processed

How to reproduce the problem

mkdir ~/lanelet2_ws/src
cd ~/lanelet2_ws/src
git clone [email protected]:odel4y/mrt_cmake_modules.git # https://github.com/KIT-MRT/mrt_cmake_modules/pull/13
git clone [email protected]:fzi-forschungszentrum-informatik/Lanelet2.git

cd ~/lanelet2_ws
colcon build --packages-up-to lanelet2_core
# Fail

cd src/lanelet2
patch -p1 < lanelet2_patch.txt # See attached

cd ~/lanelet2_ws
colcon build --packages-up-to lanelet2_core
# Success

colcon build --packages-up-to lanelet2_io
# Fail

lanelet2_patch.txt

python script not installed in ROS1

I have been using the lanelet2_interface_ros (available here) package which is using mrt_cmake_modules for building. I noticed that the python scripts are no longer being installed with the recent changes to this package. Specifically, the latest commit that worked for me is 604ef7a.

There has been no significant change in lanelet2_interface_ros to warrant this behaviour, so I think the source of the issue would be here. It would be great if you would let me know if there has now been a change to the behaviour of mrt_install(PROGRAMS scripts) such that I would need to do something else to install the python scripts or perhaps this is a bug.

I apologise if I have misunderstood something. Do let me know if you need further clarification of this issue. Thanks for the great package!

OpenMP dependency

cmake/Modules/UseMrtStdCompilerFlags.cmake seems to require OpenMP:

#add OpenMP
find_package(OpenMP REQUIRED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")

If mrt_cmake_modules needs this package, then I assume this dependency should be expressed in its package.xml.

Can any one please clarify it?

UseMrtStdCompilerFlags.cmake defaults the target to sandybridge (x86)

Arguably not an bug report, but a feature request...

UseMrtStdCompilerFlags.cmake restricts the use of these modules to amd64 machines by defaulting to "sandybridge":

# Select arch flag
if(MRT_ARCH)
  if(NOT MRT_ARCH STREQUAL "None" AND NOT MRT_ARCH STREQUAL "none")
    set(_arch "-march=${MRT_ARCH}")
  endif()
else()
  # sandybridge is the lowest common cpu arch for us
  set(_arch "-march=sandybridge")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_arch}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_arch}")

Trying to build a project using mrt_cmake_modules in an AArch64 (Arm) machine fails. The failure can be obvious (you will see compilation errors and with the mach=sandybridge flag being used, or some find_package() may fail with no reason (this is due the fact they use the CMake's try/run mechanism to build small C apps).

Note that this was the real problem why find_package(OpenMP) was failing for me on this issue: #6

Is there a good reason why sandybridge is being forced as the defaul mach? The compiler will already have default to a sane value for the target it is running from. If the "application" using mrt_cmake_modules has a minimum arch target requirement, then I suppose this is what MRT_ARCH is there for.

GLOG_INCLUDE_DIRS in FindGlog.cmake

Cmake fails to bind glog with:
mrt_cmake_modules/cmake/Modules/FindGlog.cmake:366 (list): list sub-command REMOVE_ITEM requires list to be present.

If lines
list(REMOVE_ITEM GLOG_INCLUDE_DIRS "/usr/include")
list(REMOVE_ITEM GLOG_INCLUDE_DIRS "/usr/local/include")
are deleted, it builds without any problem.

The list() commands are not present in other find scripts such as Ceres-solver. What is the reason behind to add these lines?

ROS Build Farm Release

I've asked this about lanelet2 (see fzi-forschungszentrum-informatik/Lanelet2#53) but this package is a prerequisite. I would be happy to help release this package. lanelet2 is a requirement for the Autoware.ai (and will likely be for Autoware.Auto as well) and is taking a huge portion of our CI build time to build. Having binary packages distributed from the build farm would be a major boon.

AutoDeps would not work with ninja.

Hi,

I am trying to build lanelet2-traffic-rules in the yocto project and found AutoDeps could not find lanelet2_core even recipe declare already its dependency to the recipe. yocto use ninja for generating Makefile and use ament_cmake.

error message is

| CMake Error at /home/bchoi/nvidia-yocto-bsp/official_ros_humble_build/bchoi-build/tmp/work/armv8a-poky-linux/lanelet2-traffic-rules/1.2.1-1-r0/recipe-sysroot-native/usr/share/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:176 (message):
|   Package lanelet2_core was not found.  If it is a catkin package: Make sure
|   it is present.  If it is an external package: Make sure it is listed in
|   mrt_cmake_modules/yaml/cmake.yaml!
| Call Stack (most recent call first):
|   /home/bchoi/nvidia-yocto-bsp/official_ros_humble_build/bchoi-build/tmp/work/armv8a-poky-linux/lanelet2-traffic-rules/1.2.1-1-r0/recipe-sysroot-native/usr/share/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:253 (_find_dep)
|   CMakeLists.txt:22 (find_package)

I'd appreciate you if you give me information to resolve it.

BR,
Mark

Is python-argparse dependency still necessary?

According to https://github.com/ros/rosdistro/blob/master/rosdep/python.yaml#L471-L498, it seems it's only for older distributions.

I think in most of the distributions that are currently supported, we can use argparse without installing any packages.

$ docker run --rm -it ubuntu:18.04 /bin/bash # or 16.04
# apt update && apt install -y python
# python
Python 2.7.17 (default, Apr 15 2020, 17:20:14) 
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
>>> 

I'm asking this because it causes an error when using colcon-ros-bundle to mrt_cmake_modules.
When dependency.name is python-argparse, rule and package_name_list will be [], so an error happens.
https://github.com/colcon/colcon-ros-bundle/blob/master/colcon_ros_bundle/task/ros_bundle.py#L62-L66

Of course, I'll send an issue/PR to colcon-ros-bundle, but it would be helpful if you could remove this old dependency.

Finding libboost-python-dev in Ubuntu 20.04 (focal, Boost1.71)

Hello,
Judging from your FindBoostPython.cmake file, I can see that you are aware that it is quite troublesome to find the correct libboost-python-dev version depending on the Ubuntu/Python/Boost version combination. However, the current implementation is failing for default Ubuntu 20.04 systems (which are shipped with Boost 1.71). You can recreate the failure by running the mrt_cmake _modules generate_cmakelists.py script for a package.xml containing the following line:

  <depend>libboost-python-dev</depend>

Alternatively, directly invoking the following stripped CMake file:

cmake_minimum_required(VERSION 3.5.1)
project(testpackage)

find_package(mrt_cmake_modules REQUIRED)
include(UseMrtStdCompilerFlags)
include(GatherDeps)

find_package(AutoDeps REQUIRED COMPONENTS mrt_cmake_modules libboost-python-dev)

will cause the following CMake error:

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package):
  Could not find a package configuration file provided by "boost_python3"
  (requested version 1.71.0) with any of the following names:

    boost_python3Config.cmake
    boost_python3-config.cmake

  Add the installation prefix of "boost_python3" to CMAKE_PREFIX_PATH or set
  "boost_python3_DIR" to a directory containing one of the above files.  If
  "boost_python3" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
  /usr/local/share/cmake-3.12/Modules/FindBoost.cmake:261 (find_package)
  /home/patrick/mrt_cmake_modules/cmake/Modules/FindBoostPython.cmake:39 (find_package)
  /home/patrick/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:198 (find_package)
  /home/patrick/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:253 (_find_dep)
  CMakeLists.txt:8 (find_package)

Interestingly, I can help locate the package by adding

find_package(Boost COMPONENTS python)

right before the AutoDeps call. However, I'm trying to build the lanelet2_interface_ros package; therefore I don't want to touch its CMakeLists.txt and neither the mrt_cmake subrepo.

The following Boost Issue should explain the issue - the FindBoostPython.cmake script searches for the python3 component in line 39, which is not supported in Boost version 1.71 (and should be supported again in 1.73 according to this issue). Instead, a search for python without the suffix is preferable.

I understand that the problem should therefore be fixed by upgrading Boost to 1.73; however, Ubuntu focal ships with 1.71 and the fix has apparently not been backported for over a year now. So I would like to ask if you could address this on your side? This would help a lot by avoiding to upgrade Boost or patch either the lanelet2_interface_ros or this subrepo.

Best regards,

Patrick

Package qtbase5-dev was not found, when installing lanelet_rviz_plugin_ros

Installed mrt_cmake_modules as a dependency from ros-melodic-lanelet2. When installing lanelet_rviz_plugin_ros the following error occurs (after installing lanelet2_interface_ros and util_rviz):

Errors     << lanelet_rviz_plugin_ros:cmake /home/mo/catkin_ws/logs/lanelet_rviz_plugin_ros/build.cmake.003.log                                                                                                                                                                   
CMake Error at /opt/ros/melodic/share/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:176 (message):
  Package qtbase5-dev was not found.  If it is a catkin package: Make sure it
  is present.  If it is an external package: Make sure it is listed in
  mrt_cmake_modules/yaml/cmake.yaml!
Call Stack (most recent call first):
  /opt/ros/melodic/share/mrt_cmake_modules/cmake/Modules/FindAutoDeps.cmake:253 (_find_dep)
  CMakeLists.txt:23 (find_package)

cd /home/mo/catkin_ws/build/lanelet_rviz_plugin_ros; catkin build --get-env lanelet_rviz_plugin_ros | catkin env -si  /usr/bin/cmake /home/mo/catkin_ws/src/lanelet_rviz_plugin_ros --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/mo/catkin_ws/devel/.private/lanelet_rviz_plugin_ros -DCMAKE_INSTALL_PREFIX=/home/mo/catkin_ws/install; cd -
..................................................................................................................................................................................................................................................................................
Failed     << lanelet_rviz_plugin_ros:cmake          [ Exited with code 1 ]                                                                                                                                                                                                       
Failed    <<< lanelet_rviz_plugin_ros                [ 0.6 seconds ]    

I had to add

qtbase5-dev:
  components: [Core Gui Network]
  include_dirs: [QT_INCLUDES]
  libraries: [QT_LIBRARIES]
  name: MrtQt5

to /opt/ros/melodic/share/mrt_cmake_modules/yaml/cmake.yaml to make it work.

Error: "add_action_files() directory not found", but msg and srv building fine

The ros package has the following structure:

custom_msg_pkg
├── CMakeLists.txt  
├── package.xml                               
├── action
│   └── some_action.action                 # Action files
├── srv
│   └── some_service.srv                 # Service files
├── msg
│   └── some_message.msg                 # Messages files 

When building (catkin build custom_msg_pkg) I'm getting the following error:

Errors     << custom_msg_pkg:check /home/user/catkin_ws/logs/custom_msg_pkg/build.check.003.log                                                                                                                                                                   
CMake Error at /opt/ros/melodic/share/actionlib_msgs/cmake/actionlib_msgs-extras.cmake:20 (message):
  add_action_files() directory not found:
  /home/user/catkin_ws/src/project/custom_msg_pkg//home/user/catkin_ws/src/project/custom_msg_pkg/action
Call Stack (most recent call first):
  /opt/ros/melodic/share/mrt_cmake_modules/cmake/mrt_cmake_modules-macros.cmake:429 (add_action_files)
  CMakeLists.txt:46 (mrt_add_action_files)


make: *** [cmake_check_build_system] Error 1
cd /home/user/catkin_ws/build/custom_msg_pkg; catkin build --get-env custom_msg_pkg | catkin env -si  /usr/bin/make cmake_check_build_system; cd -
.......................................................................................................................................................................................................................................................
Failed     << custom_msg_pkg:check          [ Exited with code 2 ]                                                                                                                                                                                           
Failed    <<< custom_msg_pkg                [ 0.6 seconds ]                                                                                                                                                                                                  
[build] Summary: 0 of 1 packages succeeded.                                                                                                                                                                                                            
[build]   Ignored:   22 packages were skipped or are blacklisted.                                                                                                                                                                                      
[build]   Warnings:  None.                                                                                                                                                                                                                             
[build]   Abandoned: None.                                                                                                                                                                                                                             
[build]   Failed:    1 packages failed.                                                                                                                                                                                                                
[build] Runtime: 0.7 seconds total.  

If I comment out mrt_add_action_files(action) in CMakeLists.txt everything builds fine.

Does it have to do something with this difference:

if(_ROS_SERVICE_FILES)
add_service_files(FILES ${_ROS_SERVICE_FILES} DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/${folder_name}")

vs.

if(_ROS_ACTION_FILES)
add_action_files(FILES ${_ROS_ACTION_FILES} DIRECTORY "${folder_name}")

Open3d

Hello
I would like to use open3D in one of my robotics projects under ROS.
Unfortunately, then i add to yaml/cmake.yaml:

open3d:
  components: []
  name: Open3D
  include_dirs: [Open3D_INCLUDE_DIRS]
  libraries: [Open3D_LIBRARIES]
  library_dirs: [Open3D_LIBRARY_DIRS]

and generate cmake by mrt.

it is possible to build simple code:

#include "open3d/Open3D.h"

int main(int argc, char** argv)
{
    using namespace open3d;

    auto sphere = geometry::TriangleMesh::CreateSphere(1.0);
    sphere->ComputeVertexNormals();
    sphere->PaintUniformColor({ 0.0, 1.0, 0.0 });
    visualization::DrawGeometries({ sphere });

    return 0;
}

but then i try to add ROS:

#include <ros/ros.h>
#include "open3d/Open3D.h"

int main(int argc, char** argv)
{
    using namespace open3d;

    ros::init(argc, argv, "map_loader");

    auto sphere = geometry::TriangleMesh::CreateSphere(1.0);
    sphere->ComputeVertexNormals();
    sphere->PaintUniformColor({ 0.0, 1.0, 0.0 });
    visualization::DrawGeometries({ sphere });

    return 0;
}

i have:

undefined reference to ros::init(int&, char**, std::string const&, unsigned int)

is it possible to help me with such an issue?

Rosdep Error

When I have this package under catkin_ws and run rosdep install, I get following error.

mrt_cmake_modules: Cannot locate rosdep definition for [coverage]

Is this key for installing lcov and gcovr as defined in base.yaml file?

If that's the case, then wouldn't it be better to use lconv and gcovr as a key for dependency?

Many libraries in one package

Hi,

Do I understand correctly that with default mrt CmakeList in one package there can be only either one library or a lot of nodes/nodeletes? And to create more than one library in the package, I need to modify Cmake? In general, I already did this, I just want to understand if I'm correct.

Nodelet library name

Hi,
I think that nodelet library name in README and documentation is wrong.

It says that the nodelet library name will be: “libexample_package_nodelet”.

But depending on the folder structure I only get such names:
“libexample_package-example_name-nodelet”
“libexample_package-example_package-nodelet”

I created a simple example to show this problem: https://github.com/BaltashovIlia/example_package

This project can not be installed by `colcon build`

Windows 11 and Visual Studio.

steps:

  1. create an empty workspace: d:\ws
  2. put this project to d:\ws\src\mrt_cmake_modules
  3. in d:\ws, run colcon build

error:

Traceback (most recent call last):
File "C:\Program Files\Python310\lib\site-packages\colcon_core\executor_init_.py", line 91, in call
rc = await self.task(*args, **kwargs)
File "C:\Program Files\Python310\lib\site-packages\colcon_core\task_init_.py", line 93, in call
return await task_method(*args, **kwargs)
File "C:\Program Files\Python310\lib\site-packages\colcon_ros\task\catkin\build.py", line 75, in build
rc = await extension.build(
File "C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake\build.py", line 103, in build
rc = await self._build(
File "C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake\build.py", line 236, in build
if not await has_target(args.build_base, target):
File "C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake_init
.py", line 62, in has_target
assert target == 'install'
AssertionError

for C:\Program Files\Python310\lib\site-packages\colcon_cmake\task\cmake\__init__.py

async def has_target(path, target):
    """
    Check if the CMake generated build system has a specific target.

    :param str path: The path of the directory contain the generated build
      system
    :param str target: The name of the target
    :rtype: bool
    """
    generator = get_generator(path)
    if 'Unix Makefiles' in generator:
        return target in await get_makefile_targets(path)
    if 'Ninja' in generator:
        return target in get_ninja_targets(path)
    if 'Visual Studio' in generator:
        print(target)
        assert target == 'install'                                             <-- error
        install_project_file = get_project_file(path, 'INSTALL')
        return install_project_file is not None
    assert False, \
        "'has_target' not implemented for CMake generator '{generator}'" \
        .format_map(locals())

print(target) is for debug and its output is

tests

so assert target == 'install' failed

ps:
if I do a normal cmake --build (not colcon), it compiles ok.

Python3 Compatibility

Is there any plan to support Python3 with this package? Python2.7 updates end in January of 2020 and Autoware currently uses Python3 by default so building this package fails.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.