在Ubuntu下搭建Ros环境

安装与配置

添加ros下载源

$ sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

添加密钥

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

更新

$ sudo apt-get update
$ sudo apt-get update --fix-missing

安装完整桌面版ROS

$ sudo apt-get install ros-melodic-desktop-full

初始化ROS

如果条件允许,请翻墙后执行下面的指令

$ sudo rosdep init

成功会提示

Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

	rosdep update
  • 如果提示以下内容
sudo: rosdep:command not found

需要安装工具

$ sudo apt install rospack-tools
  • 如果提示以下内容
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down

需要添加IP解析

$ sudo gedit /etc/host

增加

151.101.84.133  raw.githubusercontent.com
  • 如果提示以下内容
Traceback (most recent call last):
  File "/usr/bin/rosdep", line 3, in <module>
    from rosdep2.main import rosdep_main
ModuleNotFoundError: No module named 'rosdep2'

需要把python的版本切回2.×

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 200
  • 如果提示以下内容
ERROR: no sources directory exists on the system meaning rosdep has not yet been initialized

很悲剧,只能卸载使用其他的源了

sudo apt-get remove ros-*

更新

$ rosdep update

如果提示以下内容

Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
ERROR: error loading sources list:
	('The read operation timed out',)

设置环境变量

$ echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

安装常用的命令行工具rosinstsll

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

注意:配置完后需要注销用户重新登录,避免有环境变量没有更新

安装测试的工具

$ roscore
$ rosrun turtlesim turtlesim_node
$ rosrun turtlesim turtle_teleop_key

可通过键盘控制乌龟的移动
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值