$ 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 keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
$ sudo apt-get update
$ sudo apt-get install ros-melodic-desktop-full
如果条件允许,请后执行下面的指令
$ sudo rosdep init
成功会提示
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
Traceback (most recent call last):
File "/usr/bin/rosdep", line 3, in
from rosdep2.main import rosdep_main
ModuleNotFoundError: No module named 'rosdep2'
需要把python的版本切回2.×
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 200
ERROR: no sources directory exists on the system meaning rosdep has not yet been initialized
很悲剧,只能卸载使用其他的源了
sudo apt-get remove ros-*
$ rosdep update
如果提示以下内容
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
ERROR: error loading sources list:
('The read operation timed out',)
$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
注意:配置完后需要注销用户重新登录,避免有环境变量没有更新
$ roscore
$ rosrun turtlesim turtlesim_node
$ rosrun turtlesim turtle_teleop_key