安装
1.设置安装源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
2.设置key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3.安装
sudo apt update
sudo apt install ros-melodic-desktop-full
//tips:ubuntu18安装melodic;ubuntu20是noetic
//卸载命令:sudo apt remove ros-noetic-*
//解决
sudo mv /var/lib/dpkg/info /var/lib/dpkg/info.bk
sudo mkdir /var/lib/dpkg/info
sudo apt-get update
sudo apt-get install -f
sudo apt-get install ros-melodic-desktop-full
4.配置环境变量
//ubuntu20版本
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
//ubuntu18版本
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
5.安装构建依赖
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo apt install python3-rosdep
6.初始化
sudo rosdep init
rosdep update
rosdep异常解决:
1.进入"/usr/lib/python3/dist-packages/" 查找rosdep中和raw.githubusercontent.com
相关的内容,调用命令:
find . -type f | xargs grep "raw.githubusercontent"
2. 修改四个文件的内容
sudo gedit /rosdistro/__init__.py
sudo gedit ./rosdep2/gbpdistro_support.py
sudo gedit ./rosdep2/sources_list.py
sudo gedit ./rosdep2/rep3.py文件中涉及的 URL 内容,如果是:raw.githubusercontent.com/ros/rosdistro/master都替换成步骤1中准备的gitee.com/zhao-xuzuo/rosdistro/raw/master即可。
3.重新sudo rosdep init+rosdep update
遇到这个,说明修改成功。
小乌龟Turtle测试
ROS 内置了一些小程序,可以通过运行这些小程序以检测 ROS 环境是否可以正常运行
-
首先启动三个命令行(ctrl + alt + T)
-
命令行1键入:roscore
-
命令行2键入:rosrun turtlesim turtlesim_node(此时会弹出图形化界面)
-
命令行3键入:rosrun turtlesim turtle_teleop_key(在3中可以通过上下左右控制2中乌龟的运动)