本文章记录了作者在使用nano过程中ROS环境的安装过程
sodo swapon --show
free -h
sudo fallocate -l 2G /swapfile
sudo chmod 666 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo gedit /etc/fstab
粘贴
/swapfile swap swap defaults 0 0
sudo swapon --show
sudo free -h
sudo apt-get purge libreoffice*
sudo apt-get clean
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit /etc/apt/sources.list
将以下内容替换原内容
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
保存并退出
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y python3-dev python3-testresources python3-setuptools
wget https://bootstrap.pypa.io/pip/3.6/get-pip.py
sudo python3 get-pip.py
rm get-pip.py
持久的更换默认源
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
sudo sh -c 'echo "deb http://mirrors.ustc.edu.cn/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 update
完整桌面版安装
sudo apt install ros-melodic-desktop-full
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update
1.sudo rodeo init报错
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.
解决方案:
sudo gedit /etc/hosts
添加
199.232.28.133 raw.githubusercontent.com
151.101.228.133 raw.github.com
如果还不行,便手动完成初始化
sudo passwd //接着提示输入UNIX密码,输入你的用户密码即可
sudo su //或者su root 然后输入密码切换至root用户
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
将以下内容复制进20-default.list文件中
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
执行下面的命令
exit //退出root用户
rosdep update
2.rosdep update报错
解决方案如下:
git clone https://github.com/ros/rosdistro.git
将下载下来的文件提取至主目录下的git文件夹;
将下列文件备份
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
sudo cp /etc/ros/rosdep/sources.list.d/20-default.list /etc/ros/rosdep/sources.list.d/20-default.list.bak
对下面的文件进行操作,全部将 https://raw.githubusercontent.com/ros/rosdistro/master 替换为file:///home/xxx/git/rosdistro
注:xxx为用户名
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
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
再执行:
rosdep update
显示成功执行!
对ROS文件夹进行提权:
sudo chmod 777 -R ~/.ros/
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
分别用3个终端打开上述命令,当可以正常显示小乌龟,并可以用按键控制时,ROS环境即安装成功。
https://blog.csdn.net/maijiayong/article/details/109910366
https://blog.csdn.net/Hacker_MAI/article/details/105827254