在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 <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

可通過鍵盤控制烏龜的移動
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章