ROS 是套機器人開發框架,因為相關的套件齊全,最近常常聽到人家討論。沒事想說來玩玩看,了解有哪些特色。
Step 1: Check version
參照官網說明,ROS 可以讓你方便整合自己與他人的機器人軟體。ROS 常見的 OS 是 Ubuntu
The Robot Operating System (ROS) is a flexible framework for writing robot software.
開始安裝前,要注意 ROS 對應的 Ubuntu 版本,目前兩個主要的 ROS 發行版是 ROS Kinetic Kame 跟 ROS Melodic Morenia,分別對應到 Ubuntu 16.04 跟 18.04
KineticThese instructions will install the ROS Kinetic Kame distribution, which is available for Ubuntu Wily (15.10) and Ubuntu Xenial (16.04 LTS), among other platform options.MelodicROS Melodic Morenia is primarily targeted at the Ubuntu 18.04 (Bionic) release, though other Linux systems as well as Mac OS X, Android, and Windows are supported to varying degrees.
如果選錯版本,在安裝時會出現找不到套件的情形
Step 2: Install ROS via apt
在 Ubuntu 下,通常會使用 apt 來管理套件,在這邊將 ROS 加入 apt 的來源中,以便用 apt 直接安裝
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
接著設定套件金鑰
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
更新套件列表
sudo apt-get update
安裝套件,安裝時要注意選擇對應的版本,18.04 選擇 melodic
sudo apt-get install ros-melodic-desktop-full
原則上到這邊已經完成,但我們最好再安裝一些常用的相依套件,以免到時使用有問題
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
Step 3: Initialize
安裝完後需要初始化,這個動作只需要執行一次即可
sudo rosdep init
將 setup.bash 加入 .bashrc 中,使得 terminal 開啟後有 ROS 的環境變數,同時重新載入 terminal
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
如果有遇到權限問題,記得將 ROS 的資料夾權限改為自己
sudo chown ken:ken -R .ros/
Step 4: Test
全部設定完後進行測試,先將 ROS 的 core 跑起來,看看是否正常。先不用在意 core 的用途,我們的目的只是要確認是否可執行
roscore
如果正常,應該會看到如下訊息
...
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.started roslaunch ... version 1.14.3SUMMARY
========PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.3NODESauto-starting new master
process[master]: started with pid [24242]
ROS_MASTER_URI=http://ken-Lenovo-ideapad-330-15ICH:11311/setting /run_id to 53147388-bc27-11e9-a69d-302432574842
process[rosout-1]: started with pid [24253]
started core service [/rosout]
Conclusion:
透過簡單的步驟,我們可以在 Ubuntu 上安裝 ROS,由於 ROS 需要 OS,如果是嵌入式應用,最好要確認 CPU 夠力。不用在意 x86 或 ARM,只要能跑得動就行,據說 Raspberry Pi 3 會有點悲劇?
Reference:
Official Site http://wiki.ros.org/