树莓派4B 4G版(raspbian Buster系统)安装ROS kinetic

0. 前提条件
1)配置国内的apt镜像源
sources.list配置:
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
sources.list.d里的raspi.list配置
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ buster main
2)我是PC上开了SSR(为了ros的国外源能安装),用网线和树莓派连接,通过ssh操作,树莓派使用了proxy代理的是PC上的端
1. 安装ROS的仓库
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-late
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key
C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get upgrade
2. 安装Bootstrap依赖
sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cm
3. 初始化rosdep
sudo rosdep init
rosdep update
1)在rosdep update出现timeout的情况试下改dnns
sudo vim /etc/resolv.conf 添加google的DDNS
nameserver 8.8.8.8
nameserver 8.8.4.4
3. 安装liboost1.58和替换编译器gcc-5 g++-5
wget https://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2
tar –bzip2 -xvf boost_1_58_0.tar.bz2
cd boost_1_58_0/
./bootstrap.sh
./bjam
./bjam install
sudo apt install -y libboost1.58-dev libboost1.58-all-dev
看一下 是否成功
ls /usr/local/lib/ | grep boost
树莓派4B 4G版(raspbian Buster系统)安装ROS kinetic

替换编译器
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++
查看一下是否成功
gcc -v
g++ -v
树莓派4B 4G版(raspbian Buster系统)安装ROS kinetic

4. 创建ros的catkin的工作空间
mkdir -p ~/ros_catkin_ws
cd ~/ros_catkin_ws
ROS-Comm: (recommended) ROS package, build, and communication libraries. No GUI tools. 我是安装精简的
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-generic libraries
$ rosinstall_generator desktop --rosdistro kinetic --deps --wet-only --tar > kinetic-desktop-wet.rosinstall
$ wstool init src kinetic-desktop-wet.rosinstall
如果出现问题中断了,使用下面指令可以继续工作
wstool update -j4 -t src
5. 解决依赖文件
1)Assimp
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
2)使用rosdep安装依赖文件
cd ~/ros_catkin_ws
rosdep install -y --from-paths src --ignore-src --rosdistro kinetic -r --os=debian:buster
这时候可能会安装liboost1.67版本下面需要删除只留1.58的
sudo apt remove libboost1.67-dev
sudo apt autoremove
sudo apt install -y libboost1.58-dev libboost1.58-all-dev
6. 开始编译了ros
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/kinetic

树莓派4B 4G版(raspbian Buster系统)安装ROS kinetic
编译完2个项目才成功。

7. 添加一下环境变量
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
8. 尝试运行一下master
roscore
树莓派4B 4G版(raspbian Buster系统)安装ROS kinetic

成功了。