1 添加ROS软件源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
为了提高软件的下载、安装速度,也可以使用以下任意一种国内的镜像源:
中国科学技术大学(USTC)镜像源:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
中山大学(Sun Yat-Sen University)镜像源:
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.sysu.edu.cn/ros/ubuntu $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
易科机器人实验室(ExBot Robotics Lab)镜像源:
sudo sh -c '. /etc/lsb-release && echo "deb http://ros.exbot.net/rospackage/ros/ubuntu $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
2 添加密钥
2.1 修改hosts
国内访问raw.githubusercontent.com可能不成功,对此,以下方式可解决GitHub的raw.githubusercontent.com无法连接的问题。
step-1:
在 ip查询 查ip 网站ip查询 同ip网站查询 iP反查域名 iP查域名 同ip域名
输入raw.githubusercontent.com查询IP地址

step-2:
修改hosts,ip用上面查到的(一个不行换另一个)。vim /etc/hosts 加入
185.199.108.133 raw.githubusercontent.com
2.2 添加密钥
sudo apt install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
2.3 更新源
sudo apt update
3 安装ROS
ROS安装可选 ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators和2D/3D perception。这里我们全都要。
sudo apt install ros-melodic-desktop-full
4 配置环境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
5 安装ROS构建包
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
安装rosdep
sudo apt install python-rosdep
6 运行实例检测ROS是否安装成功
6.1 一个窗口终端运行roscore
roscore

6.2 另一个窗口终端启动海龟仿真器
rosrun turtlesim turtlesim_node

6.3 另开一个窗口终端用键盘控制小乌龟移动
rosrun turtlesim turtle_teleop_key

这样,在该终端操作键盘的上下左右方向键,就可以控制乌龟移动。

本文提供了一步一步的指导来帮助读者在Ubuntu系统上安装ROS(机器人操作系统),包括添加软件源、密钥,安装ROS桌面完整版及必要的构建工具,并通过一个简单的实例验证安装的成功。
1862

被折叠的 条评论
为什么被折叠?



