ubuntu不同系统版本支持的Ros版本有所差异,需要选择对应的版本。我的系统是ubuntu18.04故使用Melodic版本。
ubuntu18.04 --> Melodic
软件和更新--> 所有选项都勾上--> 软件源下拉框选择阿里源
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'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
本人安装的是桌面完整版,如下高亮显示了。
sudo apt install ros-melodic-desktop-full
sudo apt install ros-melodic-desktop
sudo apt install ros-melodic-ros-base
sudo apt install ros-melodic-PACKAGE
使用ROS之前需要执行rosdep init的初始化操作,这样在进行编译时,会帮助我们轻松的安装好系统依赖项和在ROS中运行所需要的核心组件。
sudo rosdep init # 有墙,无法访问。这里我们下载目标程序包手动本地安装
rosdep update # 手动安装完成后直接执行此命令
查阅了很多博客,发现我发通过修改/etc/hosts文件来绕过墙,实际上对我来说没有任何效果。因此需要采用手动rosdep init需要的程序包,解压后手动修改ros相关的python文件进行安装,具体安装步骤如下节问题处理。
不支持python3导致,因此需要将系统的python设置成python2,执行以下命令后选择相应的版本
sudo update-alternatives --config python
https://github.com/ros/rosdistro #直接下载压缩包就行,解压后使用
以下个点的修改文件路径以rosdeb-master解压路径为准
FUERTE_GBPDISTRO_URL = 'file:///home/huangli/rosdistro-master/releases/fuerte.yaml'
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///home/huangli/rosdistro-master/index-v4.yaml'
# rosdep
#DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
DEFAULT_SOURCES_LIST_URL = 'file:///home/huangli/rosdistro-master/rosdep/sources.list.d/20-default.list'
# location of targets file for processing gbpdistro files huagnli change for ros in 2022/5/13
#REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'file:///home/huangli/rosdistro-master/releases/targets.yaml'
# 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
yaml file:///home/huangli/rosdistro-master/rosdep/base.yaml
yaml file:///home/huangli/rosdistro-master/rosdep/python.yaml
yaml file:///home/huangli/rosdistro-master/rosdep/ruby.yaml
yaml file:///home/huangli/rosdistro-master/rosdep/osx-homebrew.yaml osx
gbpdistro file:///home/huangli/rosdistro-master/releases/fuerte.yaml fuerte
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
roscore
打开一个新终端,执行下面命令,会出现小海龟的图形界面
rosrun turtlesim turtlesim_node
再打开一个新终端,用于控制小海龟运动,操作过程按方向键让小海龟运动,不能离开当前终端
rosrun turtlesim turtle_teleop_key
roscore # 独立终端运行
rosrun rviz rviz # 起新终端执行
[参考博客](Ubuntu18.04安装ROS出现的一些问题 - 灰信网(软件开发博客聚合) (freesion.com))
[安装全程参考博库]((5条消息) Ubuntu18.04安装Ros(最新最详细亲测)_向日葵骑士Faraday的博客-CSDN博客_ubuntu18.04安装ros)
[手动安装rosdeb-master库更新内容参考博客]((5条消息) sudo rosdep init 出现 ERROR: cannot download default sources list from:_iridescence184的博客-CSDN博客)