Raspbian Buster ROS RealSense
This page documents problems encountered while trying to install ROS and Intel RealSense onto Raspbian Buster.
I am doing this just a few months after the release of the Raspberry Pi 4. The Raspbian release is Buster. The ROS version I am installing is Kinetic Kame Desktop.
Before You Start
I am using a 64GB microSD card, UHS-I U3. Raspbian Buster Desktop image was flashed to it. SSH was enabled before first boot. I went through the steps to expand the filesystem to fill the whole card, and the other "usual" rasp-config stuff.
I added 1GB of swap space, this is required to build OpenCV and some other packages, otherwise there's a really mysterious crash that happens when compiling those source files.
This will take HOURS, make sure your power supply and SSH connection will not be interrupted. Read a book or watch a movie, or in my case, remotely access your home network so you can work while you do this installation.
Installing ROS
I followed instructions from http://wiki.ros.org/ROSberryPi/Installing%20ROS%20Kinetic%20on%20the%20Raspberry%20Pi
Different people will encounter different problems, most likely due to the rapid pace of version changes. I did not encounter some of the problems mentioned on that page, and I did encounter some ones that were not mentioned on that page.
Problem: "CMake may have trouble finding FindEigen3.cmake"
I did not encounter this problem
Problem: error: invalid conversion from 'const char*' to 'char*'
Full error text is
/home/pi/ros_catkin_ws/src/opencv3/modules/python/src2/cv2.cpp: In function ‘bool pyopencv_to(PyObject*, T&, const char*) [with T = cv::String; PyObject = _object]’: /home/pi/ros_catkin_ws/src/opencv3/modules/python/src2/cv2.cpp:885:34: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] char* str = PyString_AsString(obj);
Apparently this is due to some changes in Python 3.7, and the fix is to find the file cv2.cpp and edit the offending line from
char* str = PyString_AsString(obj);
to
const char* str = PyString_AsString(obj);
Citation: https://github.com/opencv/opencv/issues/14856#issuecomment-504416696
Problem: fatal error: boost/tr1/unordered_set.hpp: No such file or directory
Full error text is
In file included from /home/pi/ros_catkin_ws/src/rospack/src/rospack.cpp:28: /home/pi/ros_catkin_ws/src/rospack/include/rospack/rospack.h:108:10: fatal error: boost/tr1/unordered_set.hpp: No such file or directory #include <boost/tr1/unordered_set.hpp> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/rospack.dir/build.make:63: CMakeFiles/rospack.dir/src/rospack.cpp.o] Error 1 make[2]: *** Waiting for unfinished jobs.... In file included from /home/pi/ros_catkin_ws/src/rospack/src/rospack_backcompat.cpp:29: /home/pi/ros_catkin_ws/src/rospack/include/rospack/rospack.h:108:10: fatal error: boost/tr1/unordered_set.hpp: No such file or directory #include <boost/tr1/unordered_set.hpp> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/rospack.dir/build.make:76: CMakeFiles/rospack.dir/src/rospack_backcompat.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:371: CMakeFiles/rospack.dir/all] Error 2 make: *** [Makefile:141: all] Error 2
This was mentioned on the install instruction page. "On Raspbian Buster the compilation may fail with "'boost/tr1/unordered_set.hpp' file not found". This is because rospack version used in Kinetic is dependent on boost 1.58. To fix this error try installing boost 1.58 manually."
I followed these instructions to install boost 1.58: http://osdevlab.blogspot.com/2016/02/how-to-install-latest-boost-library-on.html , but note: the page here says 1.60, but I changed that to 1.58
Problem: /usr/bin/ld: cannot find -l-lpthread
Full error text:
[ 94%] Compiling generated code for qt_gui_cpp_sip Python bindings... make[3]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. /usr/bin/ld: cannot find -l-lpthread collect2: error: ld returned 1 exit status make[3]: *** [Makefile:38: "/home/pi/ros_catkin_ws/devel_isolated/qt_gui_cpp/lib/python2.7/dist-packages/qt_gui_cpp/libqt_gui_cpp_sip".so] Error 1 make[2]: *** [src/qt_gui_cpp_sip/CMakeFiles/libqt_gui_cpp_sip.dir/build.make:61: /home/pi/ros_catkin_ws/devel_isolated/qt_gui_cpp/lib/python2.7/dist-packages/qt_gui_cpp/libqt_gui_cpp_sip.so] Error 2 make[1]: *** [CMakeFiles/Makefile2:380: src/qt_gui_cpp_sip/CMakeFiles/libqt_gui_cpp_sip.dir/all] Error 2 make: *** [Makefile:141: all] Error 2
This one was nasty... I can't actually explain it, but I found a working fix
Citation: https://aur.archlinux.org/packages/ros-melodic-qt-gui-cpp/ , user hansbonini commented on 2019-05-31 02:34 "Run the package install for the first time, restart the compilation, add this line before cmake"
sed -i -e 's/\-l\-lpthread//g' sip/qt_gui_cpp_sip/Makefile
Note: depending on what directory you are in, you may need to change the path to the correct Makefile in the command above
Note: I did not put that line before cmake, instead I simply ran that command from the terminal
Problem: logWarn or logError not declared in scope
Full error text, is very similar to:
/home/pi/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp: In member function ‘bool tf2::BufferCore::setTransform(const TransformStamped&, const string&, bool)’: /home/pi/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:221:5: error: ‘logError’ was not declared in this scope logError("TF_SELF_TRANSFORM: Ignoring transform from authority \"%s\" with frame_id and child_frame_id \"%s\" because they are the same", authority.c_str(), stripped.child_frame_id.c_str()); ^~~~~~~~ /home/pi/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:221:5: note: suggested alternative: ‘strerror’ logError("TF_SELF_TRANSFORM: Ignoring transform from authority \"%s\" with frame_id and child_frame_id \"%s\" because they are the same", authority.c_str(), stripped.child_frame_id.c_str()); ^~~~~~~~ strerror
or
/home/pi/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp: In member function ‘bool tf2::BufferCore::warnFrameId(const char*, const string&) const’: /home/pi/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:126:5: error: ‘logWarn’ was not declared in this scope logWarn("%s",ss.str().c_str()); ^~~~~~~ /home/pi/ros_catkin_ws/src/geometry2/tf2/src/buffer_core.cpp:134:5: error: ‘logWarn’ was not declared in this scope logWarn("%s",ss.str().c_str()); ^~~~~~~
This is another code revision incompatibility, the internet says that logError became CONSOLE_BRIDGE_logError. The fix is going into the source file buffer_core.cpp and add in a macro to redefine logWarn and logError:
#include "tf2/buffer_core.h" #include "tf2/time_cache.h" #include "tf2/exceptions.h" #include "tf2_msgs/TF2Error.h" #include <assert.h> #include <console_bridge/console.h> #include "tf2/LinearMath/Transform.h" #include <boost/foreach.hpp> #ifndef logError // added by frank26080115 #define logError CONSOLE_BRIDGE_logError #endif #ifndef logWarn // added by frank26080115 #define logWarn CONSOLE_BRIDGE_logWarn #endif namespace tf2 { ... rest of the code
Citation: https://github.com/ros/console_bridge/issues/56 and https://github.com/ros/ros-overlay/issues/509
I am unsure if my method is the best but it worked.
Installing librealsense
Problem: undefined reference to __atomic_store_8
Full error text is
/usr/bin/ld: ../../librealsense2.so.2.25.0: undefined reference to '__atomic_load_8' /usr/bin/ld: ../../librealsense2.so.2.25.0: undefined reference to '__atomic_store_8' /usr/bin/ld: ../../librealsense2.so.2.25.0: undefined reference to '__atomic_fetch_add_8' collect2: error: ld returned 1 exit status make[2]: *** [examples/hello-realsense/CMakeFiles/rs-hello-realsense.dir/build.make:91: examples/hello-realsense/rs-hello-realsense] Error 1 make[1]: *** [CMakeFiles/Makefile2:455: examples/hello-realsense/CMakeFiles/rs-hello-realsense.dir/all] Error 2 /usr/bin/ld: ../../librealsense2.so.2.25.0: undefined reference to '__atomic_load_8' /usr/bin/ld: ../../librealsense2.so.2.25.0: undefined reference to '__atomic_store_8' /usr/bin/ld: ../../librealsense2.so.2.25.0: undefined reference to '__atomic_fetch_add_8' collect2: error: ld returned 1 exit status make[2]: *** [examples/software-device/CMakeFiles/rs-software-device.dir/build.make:91: examples/software-device/rs-software-device] Error 1 make[1]: *** [CMakeFiles/Makefile2:511: examples/software-device/CMakeFiles/rs-software-device.dir/all] Error 2 make: *** [Makefile:130: all] Error 2
I don't fully understand the problem, but the internet offers a solution
Citation: https://github.com/IntelRealSense/librealsense/issues/4565#issuecomment-518359584
Find the file librealsense/CMakeList.txt and put this line near the top
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -latomic")