The ROS system is the most friendly to the Ubuntu system. It seems that it can be installed directly, but I couldn't find it available, so I had to install and use the ROS system on Raspbian, the native system of the Raspberry Pi. The Raspberry Pi I tested is 3B, 1G RAM, I'm going to buy a 4B 8G one.
ready
Of course, the first step is to install the Pie system in accordance with the requirements of raspberry PI and run it normally. If not, go to https://www.raspberrypi.org/software/ .
There was a Chinese tutorial that emphasized that opencv must be installed, and I did so. Install python's opencv (non-compiled method) on the Raspberry Pi . The official tutorial did not see this requirement.
Check the version of os: cat /etc/os-release # OS version information
Set up the ROS library
The setting is somewhat related to the version.
Raspbian Stretch::
Except that dirmngr needs to be installed, everything else is the same as : Raspbian Jessie:.
$ sudo apt-get install dirmngr
Raspbian Buster: Same as Raspbian Jessie.
Raspbian Jessie:
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Update:
$ sudo apt-get update
$ sudo apt-get upgrade
Install Bootstrap dependencies
Install as follows:
$ sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake
Initialize Rosdep
$ sudo rosdep init
$ rosdep update
installation
Create catkin workspace
$ mkdir -p ~/ros_catkin_ws
$ cd ~/ros_catkin_ws
Next, you will get the core software package. Use wstool for this. According to the specific requirements of the installation, select the wstool command, here is just one of two options to install one:
ROS-Comm: (Officially recommended) ROS package, build, and communication library. No GUI tool.
$ rosinstall_generator ros_comm --rosdistro kinetic --deps --wet-only --tar > kinetic-ros_comm-wet.rosinstall
$ wstool init src kinetic-ros_comm-wet.rosinstall
Desktop: ROS, rqt , rviz , and robot libraries:
$ rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-wet.rosinstall
$ wstool init src kinetic-desktop-wet.rosinstall
This will add all catkin or wet packages in the given requirements, and then extract the source into the ~/ros_catkin_ws/src directory. This command will take a few minutes to download all core ROS packages to the src folder. The -j8 option downloads 8 software packages in parallel. As the original text says, I didn't see this command here.
The following is optional, just as an example, you can download more:
$ rosinstall_generator robot --rosdistro kinetic --deps --wet-only --tar > kinetic-robot-wet.rosinstall
$ wstool init src kinetic-robot-wet.rosinstall
If there is an error in the middle, you can continue. It should be said that the source to be compiled is complete.
wstool update -j4 -t src
Resolve dependent libraries
Before building the Catkin workspace, you need to make sure that you have all the necessary dependencies. We use the rosdep tool for this, however, there are several dependencies in the repository. They must be built manually first.
Manually constructed:
If the compilation of collada_urdf fails, you can replace it as follows:
mkdir -p ~/ros_catkin_ws/external_src
cd ~/ros_catkin_ws/external_src
wget http://sourceforge.net/projects/assimp/files/assimp-3.1/assimp-3.1.1_no_test_models.zip/download -O assimp-3.1.1_no_test_models.zip
unzip assimp-3.1.1_no_test_models.zip
cd assimp-3.1.1
cmake .
make
sudo make install
Use the following method to set the replacement:
$ rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --exclude collada_parser collada_urdf --tar > kinetic-desktop-wet.rosinstall
Use rosdep to solve the dependent library, which is different according to the version, and the command is different:
Raspbian Stretch:
$ cd ~/ros_catkin_ws
$ rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:stretch
Raspbian Jessie:
$ cd ~/ros_catkin_ws
$ rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:jessie
Raspbian Buster:
$ cd ~/ros_catkin_ws
$ rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:buster
Compile catkin space
Once you have finished downloading the package and resolved the dependent libraries, you can compile the catkin package.
Invoke catkin_make_isolated:
Note: On Raspbian Buster, compilation may fail with "'boost/tr1/unordered_set.hpp' file not found". This is because the rospack version used in Kinetic depends on boost 1.58. To resolve this error, try to install boost 1.58 manually.
(Note: When using GCC 8, the libboost 1.58 obtained through apt-get is not compatible with librosconsole. The solution is to use GCC 8 to build boost 1.58 from source code, or use an earlier version of ROS for the entire ROS version. Similarly, almost All Kinetic ROS packages use libboost 1.58, and cannot be built with newer versions of libboost, continue to use 1.58 on anything built in the catkin workspace)
(Please note: if you install libpcl later via apt-get (used with rtabmap or other point cloud packages), it will install the latest libboost 1.67 as a dependency. In /usr/local/lib and in /usr/lib The automatic installation of libboost 1.67 in Rtabmap will cause a runtime error in CloudViewer.cpp. Therefore, it is recommended not to actually install the manually built libboost 1.58. Instead, it should be pointed to by BOOST_INCLUDEDIR and BOOST_LIBRARYDIR of boost cmake. The build output of boost is actually directed to you. Shows how to do it.)
Raspbian Buster: This version needs to use the gcc -5 version, and the following operations are required. Is it necessary for others to do the same? I didn't say, but mine is this version.
$ sudo apt remove libboost1.67-dev
$ sudo apt autoremove
$ sudo apt install -y libboost1.58-dev libboost1.58-all-dev
$ sudo apt install -y g++-5 gcc-5
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
$ sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
$ sudo update-alternatives --set cc /usr/bin/gcc
$ sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
$ sudo update-alternatives --set c++ /usr/bin/g++
$ sudo apt install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake
Generally use the following command to compile:
$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic
Swap settings and other solutions to "internal compiler error"
For the 1G Raspberry Pi, the memory is definitely not enough, so you need to set the swap memory to 1G to solve it. See: https://nebl.io/neblio-university/enabling-increasing-raspberry-pi-swap/
In fact, it is very simple, the description is as follows:
1: temporarily close swap:
sudo dphys-swapfile swapoff
2: Edit the /etc/dphys-swapfile file:
sudo nano /etc/dphys-swapfile
Find CONF_SWAPSIZE and modify it to 1024 (1G), then save and exit.
CONF_SWAPSIZE=1024
3: Initialize swap
sudo dphys-swapfile setup
4: Restart swap
sudo dphys-swapfile swapon
There is also the following command to replace the above compilation command:
$ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic -j2
Here, -j2 is used and the default is -j4, which means 4 cores.
Remember source
After all is compiled, it should be installed, and then source:
$ source /opt/ros/kinetic/setup.bash
Or join to start automatic execution:
$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
verification
Run roscore
Reference: Test whether the ROS installation is successful
See the installation process above:
Raspbian install ROS system Kinectic|Raspberry Pi 4B install ros using OpenCV (full process)
Installing ROS Kinetic on the Raspberry Pi