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 
相关推荐
努力学习的小廉13 分钟前
深入了解linux网络—— 守护进程
linux·运维·网络
wheeldown30 分钟前
【Linux】从内存布局到信号屏蔽:Linux 内核态与用户态交互核心知识点汇总
linux·运维·服务器
落羽的落羽32 分钟前
【Linux系统】C/C++的调试器gdb/cgdb,从入门到精通
linux·服务器·c语言·c++·人工智能·学习·机器学习
张彦峰ZYF36 分钟前
高频面试题(含笔试高频算法整理)基本总结回顾5
linux·运维·服务器
liuccn1 小时前
Ubuntu 22.04 离线升级 OpenSSH 到 9.8p1
linux·ubuntu·github
徐子元竟然被占了!!1 小时前
Linux的df和du
linux·运维·服务器
集大周杰伦1 小时前
Linux网络编程核心实践:TCP/UDP socket与epoll高并发服务器构建
linux·tcp/ip·网络编程·socket·字节序·套接字·i/o多路复用
Mr. Cao code1 小时前
实战:Docker构建Haproxy负载均衡镜像
linux·运维·ubuntu·docker·容器·负载均衡
大聪明-PLUS1 小时前
3 个诊断 Linux 服务器的脚本
linux·嵌入式·arm·smarc
@木辛梓1 小时前
Linux 线程
linux·开发语言·c++