前言
本文章记录了作者在使用nano过程中ROS环境的安装过程
一、Nano环境配置
1、检查当前系统的交换空间和内存
sodo swapon --show
free -h
2、增加2G的使用空间
sudo fallocate -l 2G /swapfile
sudo chmod 666 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
3、为使激活永远有效
sudo gedit /etc/fstab
粘贴
/swapfile swap swap defaults 0 0
4、验证是否有效
sudo swapon --show
sudo free -h
二、更新系统并移除无用软件
1、移除LibreOffice
sudo apt-get purge libreoffice*
sudo apt-get clean
2、更新系统并还原
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit /etc/apt/sources.list
将以下内容替换原内容
deb http:
deb http:
deb http:
deb http:
deb-src http:
deb-src http:
deb-src http:
deb-src http:
保存并退出
3、更新软件列表并进行软件更新
sudo apt-get update
sudo apt-get upgrade
三、pip安装
1、安装pip
sudo apt-get install -y python3-dev python3-testresources python3-setuptools
wget https:
sudo python3 get-pip.py
rm get-pip.py
2、pip换源
持久的更换默认源
pip install pip -U
pip config set global.index-url https:
四、ROS安装
1、 添加ROS国内源
sudo sh -c 'echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list
2、添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3、安装
更新包列表
sudo apt update
完整桌面版安装
sudo apt install ros-melodic-desktop-full
4、环境设置
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
5、依赖包安装
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
6、初始化rosdep
sudo rosdep init
rosdep update
1.sudo rodeo init报错
sudo rosdep init
ERROR: cannot download default sources list from:
https:
Website may be down.
解决方案:
sudo gedit /etc/hosts
添加
199.232.28.133 raw.githubusercontent.com
151.101.228.133 raw.github.com
如果还不行,便手动完成初始化
sudo passwd
sudo su
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:
# generic
yaml https:
yaml https:
yaml https:
gbpdistro https:
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
执行下面的命令
exit
rosdep update
2.rosdep update报错 解决方案如下:
git clone https:
将下载下来的文件提取至主目录下的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/
7、运行测试
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
|