配置ubuntu的软件和更新
确保勾选了"restricted", "universe," 和 "multiverse."
设置安装源
默认安装源:
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'
注意密码是不显示的,我用了中科大的源
设置key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
安装
apt 是用于从互联网仓库搜索、安装、升级、卸载软件或操作系统的工具。
sudo apt update
无法下载 http://mirrors.ustc.edu.cn/ros/ubuntu/dists/focal/main/binary-i386/Packages.gz 文件尺寸不符(59457 != 59487)。您使用的镜像正在同步中? [IP: 218.104.71.170 80]
更换清华的源解决
安装ROS
sudo apt install ros-noetic-desktop-full
再次确认
sudo apt install ros-noetic-desktop-full
按装pip
sudo apt-get install python3-pip
按装rosdepc C指中国
sudo pip install rosdepc
初始化 rosdepc 国内必须带C
sudo rosdepc init
///
找不到命令
按装 rosdep2
sudo apt install python3-rosdep2
ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list Please delete if you wish to re-initialize
执行删除
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
更新 rosdepc 使用国内必须带C
rosdepc update
设置环境变量
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
让环境变量生效
source ~/.bashrc
如果没有正确安装 卸载ros 重装
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sudo apt remove ros-noetic-*
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||安装构建依赖
noetic 最初发布时,没有安装构建依赖这一步骤。随着 noetic 不断完善,官方补齐了这一操作
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
验证 ROS 是否安装成功
roscore
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
报错解决
Command ‘roscore’ not found, but can be installed with:sudo apt install python3-roslaunch
sudo apt install python3-roslaunch
Resource not found: roslaunch
ROS path [0]=/opt/ros/noetic/share/ros
ROS path [1]=/opt/ros/noetic/share
The traceback for the exception was written to the log file
解决办法
$ sudo apt-get install ros-noetic-roslaunch
或ros没有正确按装,再次按装
sudo apt install ros-noetic-desktop-full
ubuntu内存不足1G 记得按y
$ rosclean check
$ rosclean purge
Resource not found: rosbash
$ sudo apt install ros-noetic-rosbash
not found: rosrun
$ sudo apt install ros-noetic-rosrun
Could not find the required component 'rospy'
如不能解决则 需要按装rosservice或ros-noetic-rospy
$ sudo apt-get install python3-rospy
$ sudo apt-get install ros-noetic-rospy
rosservice not found
$ sudo apt install python3-rosservice
ERROR: default sources list file already exists: /etc/ros/rosdep/sources.list.d/20-default.list Please delete if you wish to re-initialize
$ sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
ROS中使用许多工具前,要求需要初始化rosdep(可以安装系统依赖) rosdep不带C是国外的
sudo apt install python3-rosdep
或者
sudo apt install python-rosdep2
或者
sudo apt install python3-rosdep2
建议使用国内 按装rosdep
初始化rosdep 不带C国外的
最好使用国内的rosdep
sudo rosdep init
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
更新
rosdep update
使用国内rosdep不用替换
ERROR: error loading sources list:
<urlopen error <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
资源被屏蔽了
使用以下资源替换即可
https://gitee.com/zhao-xuzuo/rosdistro
主要使用
gitee.com/zhao-xuzuo/rosdistro/raw/master
替换
raw.githubusercontent.com
进入
"/usr/lib/python3/dist-packages/"
cd /usr/lib/python3/dist-packages/
查找rosdep中和raw.githubusercontent.com相关的内容
find . -type f | xargs grep "raw.githubusercontent"
文件中涉及的 URL 内容,
raw.githubusercontent.com/ros/rosdistro/master
都替换
gitee.com/zhao-xuzuo/rosdistro/raw/master
chuanmei@ubuntu:~/Desktop$ cd /usr/lib/python3/dist-packages/
chuanmei@ubuntu:/usr/lib/python3/dist-packages$ find . -type f | xargs grep "raw.githubusercontent"
匹配到二进制文件 ./rosdistro/__pycache__/__init__.cpython-38.pyc
sudo gedit ./rosdistro/__pycache__/__init__.cpython-38.pyc
./rosdistro/__init__.py:DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
匹配到二进制文件 ./rosdistro/manifest_provider/__pycache__/github.cpython-38.pyc
sudo gedit ./rosdistro/manifest_provider/__pycache__/github.cpython-38.pyc
./rosdistro/manifest_provider/github.py: url = 'https://raw.githubusercontent.com/%s/%s/package.xml' % (path, release_tag)
./rosdistro/manifest_provider/github.py: url = 'https://raw.githubusercontent.com/%s/%s/%s' % \
./requests-2.22.0.egg-info/PKG-INFO: [![image](https://raw.githubusercontent.com/requests/requests/master/docs/_static/requests-logo-small.png)](http://docs.python-requests.org/)
匹配到二进制文件 ./rosdep2/__pycache__/rep3.cpython-38.pyc
sudo gedit ./rosdep2/__pycache__/rep3.cpython-38.pyc
匹配到二进制文件 ./rosdep2/__pycache__/sources_list.cpython-38.pyc
sudo gedit ./rosdep2/__pycache__/sources_list.cpython-38.pyc
匹配到二进制文件 ./rosdep2/__pycache__/gbpdistro_support.cpython-38.pyc
sudo gedit ./rosdep2/__pycache__/gbpdistro_support.cpython-38.pyc
./rosdep2/gbpdistro_support.py:FUERTE_GBPDISTRO_URL = 'https://raw.githubusercontent.com/ros/rosdistro/' \
./rosdep2/sources_list.py:DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
./rosdep2/rep3.py:REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
grep: ./setuptools/script: 没有那个文件或目录
grep: (dev).tmpl: 没有那个文件或目录
grep: ./setuptools/command/launcher: 没有那个文件或目录
grep: manifest.xml: 没有那个文件或目录
注国外的都要替换,要不就使用国内的 按装rosdepc C指中国
国内按装
sudo pip install rosdepc
国内初使化
sudo rosdepc init
更新
rosdepc update
测试
1. 首先启动三个命令行(ctrl + alt + T)
2. 命令行1键入:roscore
roscore
3. 命令行2键入:rosrun turtlesim turtlesim_node(此时会弹出图形化界面)
rosrun turtlesim turtlesim_node
4. 命令行3键入:
rosrun turtlesim turtle_teleop_key
(在3中可以通过上下左右控制2中乌龟的运动)
rosdep 也可以这样按装
sudo apt install python3-rosdep
sudo rosdep ini
RROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
ERROR: error loading sources list:
<urlopen error <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
sudo gedit /etc/hosts
199.232.28.133 raw.githubusercontent.com
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
rosdep update
测试两个终端
# 终端1:激活ROS核心
roscore
# 终端2:打开Rviz
rosrun rviz rviz