在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

安装完整桌面版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
  • 如果提示以下内容
Traceback (most recent call last):
  File "/usr/bin/rosdep", line 3, in 
    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

可通过键盘控制乌龟的移动
在Ubuntu下搭建Ros环境_第1张图片

你可能感兴趣的:(ros)