catkin_make super slow in Raspberry Pi 3

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

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)
project(sensor_fusion_pkg)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  ifm3d
  pcl_ros
  roscpp
  rospy
  sensor_msgs
  std_msgs
)

catkin_package(
 INCLUDE_DIRS include
 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
  ${catkin_INCLUDE_DIRS}
  ${PCL_INCLUDE_DIRS}
  ${sensor_fusion_INCLUDE_DIRS}

)

link_directories( ${Boost_LIBRARIES_DIRS} )

link_directories( ${PCL_LIBRARY_DIRS} )

add_definitions(${PCL_DEFINITIONS})

## Declare a C++ library
add_library(sensor_fusion
  src/RadarParser.cpp
  src/CameraParser.cpp
)

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

set (CMAKE_CXX_STANDARD 11)
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">
  <name>sensor_fusion_pkg</name>
  <version>0.0.0</version>
  <description>The sensor_fusion_pkg package</description>

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

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>ifm3d</build_depend>
  <build_depend>pcl_ros</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_export_depend>ifm3d</build_export_depend>
  <build_export_depend>pcl_ros</build_export_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>sensor_msgs</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <exec_depend>ifm3d</exec_depend>
  <exec_depend>pcl_ros</exec_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>sensor_msgs</exec_depend>
  <exec_depend>std_msgs</exec_depend>


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

  </export>
</package>

Thank you in advance!

edit retag flag offensive close merge delete

Comments

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 -0600 )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 -0600 )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 repositories.ros.org/status_page 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 -0600 )edit