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 
相关推荐
Madison-No72 小时前
【Linux】gcc/g++编辑器 && 初识动静态库 && 程序翻译过程
linux·服务器
字节逆旅3 小时前
一个从从容容,一个连滚带爬:scp 与 rsync 的不同人生
linux
洛克大航海3 小时前
Linux 中新建用户
linux·运维·服务器
位步4 小时前
在linux系统中使用通用包安装 Mysql
android·linux·mysql
fly五行4 小时前
Windows 系统下使用 Docker 安装 Milvus 向量数据库
windows·docker·milvus
hello kitty w5 小时前
Python学习(11) ----- Python的泛型
windows·python·学习
蜜蜜不吃糖5 小时前
解决Vcenter告警datastore存储容量不足问题
linux·运维·服务器
zzz.105 小时前
top命令的详解
linux·服务器·网络
东城绝神5 小时前
《Linux运维总结:基于ARM64+X86_64架构CPU使用docker-compose一键离线部署redis 7.4.5容器版分片集群》
linux·运维·redis·架构·分片集群
馨谙5 小时前
网络故障排查三板斧:路由追踪、端口检查,快速定位网络问题
linux·网络