書接上文,上文提到了在樹莓派自帶系統Raspbian中安裝ros kinetic的教學安裝教學,但在安裝過程中遇到了一些問題,在這裡記錄一下。
如何使用一根USB線便在電腦上控制樹莓派在我的另一篇部落格有寫,可以前去檢視。
在上面連結中,執行到1.2安裝引導依賴項指令時,會報錯,我的錯誤如下:
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python-rosdep-modules : Depends: python-rospkg-modules (>= 1.1.10) but it is not going to be installed
Depends: python-catkin-pkg-modules (>= 0.4.0) but it is not going to be installed
Depends: python-rosdistro-modules (>= 0.7.5) but it is not going to be installed
python-rosdistro : Depends: python-rosdistro-modules (>= 0.8.3) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
根據提示,輸入以下指令:
$ sudo apt --fix-broken install
後,又出現了以下錯誤:
dpkg: error processing archive /var/cache/apt/archives/python-catkin-pkg-modules_0.4.23-1_all.deb (--unpack):
trying to overwrite '/usr/lib/python2.7/dist-packages/catkin_pkg/__init__.py', which is also in package python-catkin-pkg 0.4.10-1
Preparing to unpack .../python-rospkg-modules_1.2.8-1_all.deb ...
Unpacking python-rospkg-modules (1.2.8-1) ...
dpkg: error processing archive /var/cache/apt/archives/python-rospkg-modules_1.2.8-1_all.deb (--unpack):
trying to overwrite '/usr/lib/python2.7/dist-packages/rospkg/__init__.py', which is also in package python-rospkg 1.1.7-1
Errors were encountered while processing:
/var/cache/apt/archives/python-catkin-pkg-modules_0.4.23-1_all.deb
/var/cache/apt/archives/python-rospkg-modules_1.2.8-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
能夠看出是兩個問題,分別執行下面的指令即可:
$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/python-catkin-pkg-modules_0.4.23-1_all.deb
$ sudo apt-get -f install
$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/python-rospkg-modules_1.2.8-1_all.deb
$ sudo apt-get -f install
PS:可能module的號不同,比如我缺的是catkin的0.4.23-1和rospkg的1.2.8-1,大家根據錯誤提示自己修改一下即可。
然後輸入以下指令便不再報錯:
$ sudo apt --fix-broken install
再用下面的指令更新一下rosdep:
$ sudo rosdep update
然後再執行教學中的1.2安裝引導依賴項指令即可:
$ sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake
若網路不好,就多試幾遍。
在執行教學中步驟1.3中指令:
$ sudo rosdep init
出現如下錯誤:
DistributionNotFound: The 'rospkg>=1.1.10' distribution was not found and is required by rosdep
重新安裝 Python版本的 rosdep的即可
sudo apt install python3-rosdep
安裝完之後繼續執行init指令,但是有報錯:
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.
此時需要在/etc/hosts檔案末尾新增上一個網址:
151.101.84.133 raw.githubusercontent.com
用什麼方式新增都可以,包括用gedit、vim,或者直接在圖形化介面開啟這個檔案進行更改,這裡列出用gedit和vim新增的方法,任選其一即可:
gedit新增網址:
sudo gedit /etc/hosts
然後在末尾新增網址。
vim新增網址:
sudo vi /etc/hosts
然後按i進入vim的insert模式,然後把遊標挪到末尾,複製一下上面的網址,按shift+ins鍵(在小鍵盤旁邊),然後按Ctrl+C,然後輸入:wq即可。
然後再進行1.3初始化中的兩條指令即可:
$ sudo rosdep init
$ rosdep update
此時如果報如下錯誤:
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
則使用如下指令將其刪掉即可:
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
然後再執行如下指令便沒有問題了
$ sudo rosdep init
$ rosdep update