ubuntu安装ros1

以Ubuntu 18.04为例:

1.如果源没有切换到国内的建议切换

cpp 复制代码
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vi /etc/sources.list

删除原来的源切换到清华大学源

cpp 复制代码
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

不同系统源获取方式参照:(注意一下源地址和密钥可能是变的,要根据清华大学网站复制)跳转到清华大学源

2.更新一下

cpp 复制代码
sudo apt update
sudo apt upgrade

3.配置ros源仓库,还是以清华ros源为例 跳转到清华大学ros仓库地址

新建 /etc/apt/sources.list.d/ros-latest.list,内容为:(注意一下源地址和密钥可能是变的,要根据清华大学网站复制)

cpp 复制代码
deb https://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ focal main

然后再输入如下命令,信任 ROS 的 GPG Key,并更新索引:

cpp 复制代码
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

apt update

4.安装ros相关组件 此处安装desktop-full版本,其包含Gazebo、Rviz等常用组件

cpp 复制代码
sudo apt install ros-melodic-desktop-full

5.再安装相关依赖

cpp 复制代码
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

6.安装rosdep

这里借助国内鱼香ros

cpp 复制代码
sudo apt install python3-pip
sudo pip3 install 6-rosdep
sudo 6-rosdep

7.更新一下

cpp 复制代码
sudo rosdep init
rosdep update

8.环境变量配置

cpp 复制代码
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

9.测试

使用的经典的ros小乌龟测试

重新打开第一个终端,运行roscore

cpp 复制代码
roscore

第二个终端,运行小乌龟ui节点

cpp 复制代码
rosrun turtlesim turtlesim_node

第三个终端,通过键盘上下左右控制小乌龟运动

cpp 复制代码
rosrun turtlesim turtle_teleop_key 
相关推荐
PanZonghui5 分钟前
Centos项目部署之安装数据库MySQL8
linux·后端·mysql
PanZonghui6 分钟前
Centos项目部署之运行SpringBoot打包后的jar文件
linux·spring boot
PanZonghui7 分钟前
Centos项目部署之Java安装与配置
java·linux
程序员弘羽18 分钟前
Linux进程管理:从基础到实战
linux·运维·服务器
PanZonghui26 分钟前
Centos项目部署之常用操作命令
linux
JeffersonZU29 分钟前
Linux/Unix进程概念及基本操作(PID、内存布局、虚拟内存、环境变量、fork、exit、wait、exec、system)
linux·c语言·unix·gnu
大熊程序猿43 分钟前
netcore PowerShell 安装-linux
linux·运维
Johny_Zhao1 小时前
Docker 一键安装部署 JumpServer 堡垒机
linux·网络安全·信息安全·云计算·shell·jumpserver·ldap·yum源·系统运维
网安小白的进阶之路1 小时前
A模块 系统与网络安全 第三门课 网络通信原理-3
网络·windows·安全·web安全·系统安全
芳草萋萋鹦鹉洲哦8 小时前
【vue3+tauri+rust】如何实现下载文件mac+windows
windows·macos·rust