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 
相关推荐
stormsha4 分钟前
Linux中su与sudo命令的区别:权限管理的关键差异解析
linux·运维·服务器·鸿蒙系统·ux·batch命令
筏.k1 小时前
grep、wc 与管道符快速上手指南
linux
Johny_Zhao1 小时前
华为MAAS、阿里云PAI、亚马逊AWS SageMaker、微软Azure ML各大模型深度分析对比
linux·人工智能·ai·信息安全·云计算·系统运维
CodeOfCC1 小时前
c语言 封装跨平台线程头文件
linux·c语言·windows
科文小白狼1 小时前
Linux下VSCode开发环境配置(LSP)
linux·vscode·里氏替换原则·lsp
momo卡2 小时前
MinGW-w64的安装详细步骤(c_c++的编译器gcc、g++的windows版,win10、win11真实可用)
c语言·c++·windows
jugt3 小时前
CentOS 7.9安装Nginx1.24.0时报 checking for LuaJIT 2.x ... not found
linux·运维·centos
多多*4 小时前
LUA+Reids实现库存秒杀预扣减 记录流水 以及自己的思考
linux·开发语言·redis·python·bootstrap·lua
何双新5 小时前
第21讲、Odoo 18 配置机制详解
linux·python·开源
21号 15 小时前
9.进程间通信
linux·运维·服务器