配置ubuntu软件库
避免无法定位软件包的错误,提供国内的安装源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
设置密钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
更新ubuntu18.04
sudo apt update
如果出现问题
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
开始安装ROS melodic
sudo apt-get install ros-melodic-desktop-full
出现安装错误,再执行这条命令
查看进程占用,解除进程占用
ls /var/lib/dpkg/lock-frontend
sudo rm -r -f /var/lib/dpkg/lock-frontend
sudo rm -r -f /var/lib/dpkg/lock
避免sudo rosdep找不到命令提示
sudo apt install python-rosdep
初始化rosdep
sudo rosdep init
安装pip3
sudo apt-get install python3-pip
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update
添加ros环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
为了构建和管理开发者自己的ROS工作空间,还需要安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential