catkin_make super slow in Raspberry Pi 3

asked 2020-01-29 03:48:40 -0500

pfontana96 gravatar image

Hi everyone,

I'm experiencing some really slow builds on the RPI 3B (Ubuntu MATE 18.04 and ROS Melodic) when doing catkin_make or even catkin_make --only-pkg-with-deps <myPkg>. I just wanted to know if this is normal and if there is a way of improving build times. Although it's not reccomended for SDs, I had to add some swap space (1GB) or the builds won't finish at all. I'd already tried with the -j1 or -j2 flags but I couldn't see a great improvement.

I'm new to ROS and CMake but I cannot seem to understand why is taking up to 30-40 min to compile a simple package I made myself (I make use of libraries such as PCL if that changes anything). I leave you here my CMakeList.txt and package.xml (I'm not familiar with CMake so maybe the issue might be there?).

CMakeLists.txt :

cmake_minimum_required(VERSION 2.8.3)


find_package(catkin REQUIRED COMPONENTS

 LIBRARIES sensor_fusion
#  CATKIN_DEPENDS ifm3d pcl_ros roscpp rospy sensor_msgs std_msgs
 DEPENDS system_lib

## Build ##

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories( include


link_directories( ${Boost_LIBRARIES_DIRS} )

link_directories( ${PCL_LIBRARY_DIRS} )


## Declare a C++ library

add_dependencies(sensor_fusion ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

add_executable(camera_handler src/camera_handler.cpp)
target_link_libraries(camera_handler ${catkin_LIBRARIES})
add_dependencies(camera_handler ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

add_executable(camera_parser src/camera_parser_node.cpp)
target_link_libraries(camera_parser ${catkin_LIBRARIES} sensor_fusion ${PCL_LIBRARIES})
add_dependencies(camera_parser ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS} sensor_fusion)

add_executable(radar_parser src/radar_parser_node.cpp)
target_link_libraries(radar_parser ${catkin_LIBRARIES} sensor_fusion ${PCL_LIBRARIES})
add_dependencies(radar_parser ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS} sensor_fusion)

package.xml :

<?xml version="1.0"?>
<package format="2">
  <description>The sensor_fusion_pkg package</description>

  <maintainer email="pedro@todo.todo">pedro</maintainer>


  <!-- The export tag contains other, unspecified, tags -->
    <!-- Other tools can request additional information be placed here -->


Thank you in advance!

edit retag flag offensive close merge delete


I would suggest to clean out your workspace (ie: remove build and devel folders) and then run a verbose build.

That's CMake/make thing, not a Catkin/ROS thing btw, so just set the VERBOSE env var to 1.

This works for me:

VERBOSE=1 catkin_make -j1

Then see what is taking so long.

In a separate terminal, keep an eye on CPU, memory and swap usage. If you have a lot of templated C++, things are going to be slow, no matter what you do on RPis.

gvdhoorn gravatar image gvdhoorn  ( 2020-01-29 05:13:05 -0500 )edit

Hi @gvdhoorn , I've been reading and, indeed, it seems it's the templated C++ that's hard to compile(I did not know that before). Memory and swap space are eaten up entirely (1 GB RAM and 1GB swap). I guess cross-compilation might be an option maybe? I've seen some forums discussing cross-compiling for the RPi (in a ROS workspace). Anyway, thank you a lot for your suggestion!

pfontana96 gravatar image pfontana96  ( 2020-01-30 07:27:34 -0500 )edit

Cross-compilation is certainly an option.

Are you trying to compile your own packages, or base ROS packages?

I'm not entirely sure about all the architecture/instruction width variants with RPis, but you could perhaps install things using apt. According to there is support for Debian Stretch and Ubuntu Bionic with both hard-float (sometimes called arm32) and armv8 (ie: arm64).

gvdhoorn gravatar image gvdhoorn  ( 2020-01-30 10:25:40 -0500 )edit