一、换国内源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak
sudo nano /etc/apt/sources.list
中科大源地址:
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
清华源地址:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main contrib non-free rpi
sudo nano /etc/apt/sources.list.d/raspi.list
中科大:
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ buster main ui
清华:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo rpi-update
二、安装ROS
官网安装教程:http://wiki.ros.org/melodic/Installation/Source
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://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake
sudo rosdep init(无法执行可尝试重新安装python-rosdep)
rosdep update(执行出现timeout,换网络再执行一次)
mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws
rosinstall_generator ros_comm --rosdistro melodic --deps --tar > melodic-ros_comm.rosinstall(网络问题出现错误,换网络重试)
wstool init -j8 src melodic-ros_comm.rosinstall(发生错误查看ros_catkin_ws内是否存在src文件夹,若存在将其删除)
wstool update -j 4 -t src
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
cd ~/ros_catkin_ws
rosdep install --from-paths src --ignore-src --rosdistro melodic -y
sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/melodic -j2
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
roscore
参考文献:
https://blog.csdn.net/weixin_38951967/article/details/100364177
https://blog.csdn.net/NaiveWizard/article/details/102458217
https://www.seeedstudio.com/blog/2019/08/01/installing-ros-melodic-on-raspberry-pi-4-and-rplidar-a1m8/