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 
相关推荐
比花花解语7 分钟前
Kafka在Windows系统使用delete命令删除Topic时出现的问题
windows·分布式·kafka
rainmanqqst43 分钟前
耀世16Pro鼠标卡顿
windows
ChinaRainbowSea44 分钟前
1. Linux下 MySQL 的详细安装与使用
linux·数据库·sql·mysql·adb
致奋斗的我们1 小时前
Nginx反向代理及负载均衡
linux·运维·mysql·nginx·负载均衡·shell·openeluer
百锦再1 小时前
在Linux上创建一个Docker容器并在其中执行Python脚本
linux·python·docker
忧虑的乌龟蛋2 小时前
嵌入式 Linux:使用设备树驱动GPIO全流程
linux·服务器·嵌入式·imx6ull·gpio·点灯·pinctrl
朝九晚五ฺ2 小时前
【Linux探索学习】第三十弹——线程互斥与同步(上):深入理解线程保证安全的机制
linux·运维·学习
早起的年轻人2 小时前
Java List 自定义对象排序 Java 8 及以上版本使用 Stream API
java·windows·list
小林熬夜学编程2 小时前
【MySQL】第八弹---全面解析数据库表的增删改查操作:从创建到检索、排序与分页
linux·开发语言·数据库·mysql·算法
m0_748236112 小时前
Spring Boot 实战:轻松实现文件上传与下载功能
linux·spring boot·后端