Rosanswers logo

I have created a fresh raspbian system on as Pi3b. I have created a new user with sudo privileges, rebooted to new user and installed latest updates follow by a reboot. I am now trying to install ros2 following these instructions https://docs.ros.org/en/foxy/Installation/Linux-Install-Binary.html and using this image ros2-foxy-20201211-linux-focal-arm64.tar.bz2. When trying to install the dependencies I get :

robot@robot:~/ros2_foxy $ rosdep install --from-paths ros2-linux/share --ignore-src --rosdistro foxy -y --skip-keys "console_bridge fastcdr fastrtps osrf_testing_tools_cpp poco_vendor rmw_connext_cpp rosidl_typesupport_connext_c rosidl_typesupport_connext_cpp rti-connext-dds-5.3.1 tinyxml_vendor tinyxml2_vendor urdfdom urdfdom_headers"
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
rmw_cyclonedds_cpp: No definition of [cyclonedds] for OS [debian]

Following a previous question I then proceed with the -r option and all seems to go OK until I try to run the demos when I get the following errors: talker

robot@robot:~ $ ros2 run demo_nodes_cpp talker
Traceback (most recent call last):
  File "/home/robot/ros2_foxy/ros2-linux/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli==0.9.8', 'console_scripts', 'ros2')())
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/ros2run/command/run.py", line 70, in main
    return run_executable(path=path, argv=args.argv, prefix=prefix)
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/ros2run/api/__init__.py", line 61, in run_executable
    process = subprocess.Popen(cmd)
  File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/robot/ros2_foxy/ros2-linux/lib/demo_nodes_cpp/talker'


robot@robot:~/ros2_foxy $ ros2 run demo_nodes_py listener
Traceback (most recent call last):
  File "/home/robot/ros2_foxy/ros2-linux/lib/demo_nodes_py/listener", line 33, in <module>
    sys.exit(load_entry_point('demo-nodes-py==0.9.3', 'console_scripts', 'listener')())
  File "/home/robot/ros2_foxy/ros2-linux/lib/demo_nodes_py/listener", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/home/robot/.local/lib/python3.7/site-packages/importlib_metadata/__init__.py", line 100, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/demo_nodes_py/topics/listener.py", line 16, in <module>
    from rclpy.node import Node
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/node.py", line 41, in <module>
    from rclpy.client import Client
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/client.py", line 22, in <module>
    from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/impl/implementation_singleton.py", line 31, in <module>
    rclpy_implementation = _import('._rclpy')
  File "/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/impl/__init__.py", line 28, in _import
    return importlib.import_module(name, package='rclpy')
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'rclpy._rclpy'
The C extension '/home/robot/ros2_foxy/ros2-linux/lib/python3.8/site-packages/rclpy/_rclpy.cpython-37m-arm-linux-gnueabihf.so' isn't present on the system. Please refer to 'https://index.ros.org/doc/ros2/Troubleshooting/Installation-Troubleshooting/#import-failing-without-library-present-on-the-system' for possible solutions

Following the trouble shooting guide the ros run receive / send work as expected. using mlocate on "rclpy._rclpy" I find nothing, searching for rclpy finds a lot in the home/robot/ros2_foxy/ros2-linux subdirectories but nothing in /usr/bin or anywhere else I might expect executables. Is there another specific file I should be looking for or any more information I could provide to assist.

Further info : I now understand why locate can't find the _rclpy private subroutine within rclpy. just to confirm I have sourced setup.bash before runningg the demos. I have also installed Python3.8.0 from source as that showed as missing in the error messages. I have ordered another microSD card so I can try installing ROS2 under Ubunut 20.04. I have used ubuntu since Dapper Drake and so will be more au fait with trouble shooting. The disadvantage is the lack of raspi-config in the ubunut install and I could not detect my camera even with the start_x=1 hack.

Originally posted by bassline on ROS Answers with karma: 28 on 2021-03-04

Post score: 0

Original comments

Comment by TheLegendaryJedi on 2021-03-19:
Hi @bassline. I'm having the same problem. Any updates on this?

Comment by bassline on 2021-03-20:
I tried everything again and using "top" to monitor CPU and memory usage I could see it was swapping out memory all the time in the final build. I bought a new Pi4B and installed under ubuntu with no problems. I suggest you try and close everything that is not essential, reduce memory swapping (sorry can't remember where I found that hack) and then try again. PS If you decide to upgrade to a 4B be aware that the mains supply has a different connector so you will need a new power supply as well.

Comment by bassline on 2021-04-07:
I have tried again pulling the most recent code but still get problems compiling (e.g. /usr/bin/ld: ../../lib/libOgreMain.so.1.12.1: undefined reference to `__atomic_fetch_add_8') my command line input (after working around several problems) is: MAKEFLAGS="-j1 -l1" colcon build --symlink-install --cmake-args -DCMAKE_EXTRA_LINKER_FLAGS='-latomic' -DBUILD_TESTING=OFF --cmake-force-configure --packages-skip-build-finished --continue-on-error

Has anyone actually succeeded in compiling ROS2 on a Pi3B or do I just transfer my efforts to mi Pi4b?


1 Answer 1


Rosanswers logo

Success!! I eventually managed to get ROS2 to build on a Pi3B. It took me 8 hours of trial and error yesterday and may not be the most efficient way but it worked for me. I based it on the approach here https://medium.com/swlh/raspberry-pi-ros-2-camera-eef8f8b94304 up to the camera install. The previous link depends heavily on https://docs.ros.org/en/foxy/Installation/Linux-Development-Setup.html The main issue is kswapd0 keeps kicking in to manage the swap. Following are the extra steps / changes I made.

  1. Edit /etc/sysctl.conf as root to add " vm.swappiness = 0". This stops swapping except when completely out of memory. Reboot to activate the changes
  2. I got a warning about missing paths when installing the build pre-requisites so I added these to my PATH. In my case this was achieved by "export PATH=$PATH:/home/brian/.local/bin"
  3. I amended ~/.colcon/defaults.yaml to remove the last line selecting the compiler and added " - -DBUILD_TESTING=OFF" to reduce the load.
  4. I still had kswapd0 cutting in regularly so I limited the C compiler to one instance per thread and only used 2 threads. This made my command line :-

MAKEFLAGS="-j1 -l1" colcon build --symlink-install --packages-skip-build-finished --continue-on-error --parallel-workers 2

This had the additional benefit that I could run "top -i" in another terminal to see what was going on.

5 Even so I still got kswapd0 grabbing a large chunk of processor every so often so I would abort the build (using Ctrl C or in extremis Ctrl Z), reboot the pi and set the build to continue. Eventually I got it all compiled with only one error - concerning ROS1 bridge which I don't need.

Query : I am not sure if I am allowed to close this or whether I need a moderator to do that. I will take action if this is still open at the end of the month.

Comment : I am now moving on the the camera where Raspbian seems to set up /dev/video10 onwards but ROS2 wants to use /dev/video0 - Issue now fixed, just needed the camera activating and the cable connecting the right way round (doh!)

UPDATE - added missing PATH information.

INFO UPDATE: I had not come across the alternative mentioned below

Originally posted by bassline with karma: 28 on 2021-04-08

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by sgvandijk on 2021-04-09:
Hi, I'm very happy to see my article has helped you! I will amend it with some comments about the MAKEFLAGS and --parallel-workers, others have commented about running out of resources during build as well. The -DBUILD_TESTING=OFF option is a good one to add, too! It would be interesting to know which missing paths you saw.

Regarding the camera: /dev/video10 and up are devices for the onboard hardware decoder, encoder and GPU image signal processor. If you have a camera module connected but you don't see a /dev/video0, maybe you have to enable it first: https://projects.raspberrypi.org/en/projects/getting-started-with-picamera/2

Comment by gvdhoorn on 2021-04-09:
I'm ignorant here, but can you not use ros-tooling/cross_compile? Or is building on-device faster?

Comment by sgvandijk on 2021-04-10:
ros_cross_compile indeed is horribly slow, because it uses emulation rather than a real cross-compilation toolchain. I haven't done proper timing vs on-device, but the latter was fast enough for me and doesn't require any additional setup on a separate machine and any copying over of build artifacts. However it'll be very different if this issue gets resolved.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.