Ubuntu18.04安装Ros本人已试过多次,安装过程基本没出现问题,而且该方法也可用在Jetson nano/NX 上。
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.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 apt-get install ros-melodic-rqt*
sudo rosdep init
rosdep update
在运行sudo rosdep init后出现下所示错误:
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
1.新建文件夹,并进入文件夹
sudo mkdir -p /home/one/git/
cd /home/one/git/
下载项目:
sudo git clone https://gitee.com/one_DS/rosdistro.git
2.另打开一个终端,备份原文件
sudo cp /usr/lib/python2.7/dist-packages/rosdep2/main.py /usr/lib/python2.7/dist-packages/rosdep2/main.py.bak
sudo cp /usr/lib/python2.7/dist-packages/rosdep2/rep3.py /usr/lib/python2.7/dist-packages/rosdep2/rep3.py.bak
sudo cp /usr/lib/python2.7/dist-packages/rosdistro/__init__.py /usr/lib/python2.7/dist-packages/rosdistro/__init__.py.bak
sudo cp /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py.bak
3.替换原文件网址到本地下载
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/main.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
并全部做替换,将 https://raw.githubusercontent.com/ros/rosdistro/master 全部替换为 file:///home/one/git/rosdistro
4.运行
sudo rosdep init
终端显示 rosdep update 即可进入下一步。
5.备份并运行
sudo cp /etc/ros/rosdep/sources.list.d/20-default.list /etc/ros/rosdep/sources.list.d/20-default.list.bak
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
并做替换https://raw.githubusercontent.com/ros/rosdistro/master 全部替换为 file:///home/one/git/rosdistro
6.运行
rosdep update
sudo apt-get install python-rosinstall
sudo apt-get install ros-melodic-catkin python-catkin-tools
gedit ./.bashrc
在末尾添加如下:
#Ros-melodic
source /opt/ros/melodic/setup.bash
打开三个终端分别输入以下:
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key