1. 程式人生 > >在樹莓派2B上搭建indigo ros 開發環境

在樹莓派2B上搭建indigo ros 開發環境

第一次接觸ros,感覺無從下手,在學了了官網wiki20篇教程後對ros有了一個初步的瞭解。由於我所在的科研小組專案的需要,需要在raspberry pi 2B上搭建indigo ros的開發環境,在經過兩天的努力後終於搞定,在pi2上執行也十分流暢。

1、在https://wiki.ubuntu.com/ARM/RaspberryPi上下載Ubuntu 14.04 LTS。這個Ubuntu14.04(無桌面環境)是針對arm板開發,完全可以執行在樹莓派2B上,同時indigo ros指定的作業系統也是Ubuntu14.04,因此這是一個恰好滿足indigo ros要求,同時滿足樹莓派2B要求的linux系統。

2、用win32diskimager軟體將Ubuntu 14.04 LTS寫到16G的SD卡上。


3、安裝indigo ros前的相關操作。  

       將SD卡插到樹莓派2B的插槽裡,樹莓派連結顯示屏並通電後,剛才安裝的Ubuntu系統可以運行了,但是在安裝ros前需要做一下設定,以保證更要的執行和方便你使用這塊板子。 3.1  ROOT RESIZE

      There are no Raspbian-specific utilities included, specifically no automatic root resizer. However, it's not hard to do manually. Once booted:

    $ sudo fdisk /dev/mmcblk0

     Delete the second partition (d, 2), then re-create it using the defaults (n, p, 2, enter, enter), then write and exit (w). Reboot the system, then:

    $ sudo resize2fs /dev/mmcblk0p2

3.2   SWAP

      There is no swap partition/file included. If you want swap, it's recommended you do:

    $ sudo apt-get install dphys-swapfile

      You should have a (resized) SD card at least 4GB, because by default it will want to create a ~2GB swapfile.

3.3  WIFI FIRMWARE

      If you are using a wifi dongle, you will likely need to get the linux-firmware package:

    $ sudo apt-get install linux-firmware
 3.4 SSH SERVER

If you would like to install an SSH server for remote access:

   $ sudo apt-get install openssh-server

4、安裝indigo ros

4.1 Set your LocaleBoost and some of the ROS tools require that the system locale be set. You can set it with:
  sudo update-locale LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGES=POSIX

4.2 Setup your sources.list

Ubuntu 14.04 (Trusty armhf)

  • sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
4.3 Set up your keys
  sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net --recv-key 0xB01FA116
4.4 Installation
   sudo apt-get update

There are many different libraries and tools in ROS - not all compile fully on ARM. You can also install ROS packages individually.

  • ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.

    • sudo apt-get install ros-indigo-ros-base

4.5 Initialize rosdep
  sudo apt-get install python-rosdep
  sudo rosdep init
  rosdep update
4.6 Environment setup
echo "source /opt/ros/indigo/setup.zsh" >> ~/.zshrc
source ~/.zshrc
4.7 Getting rosinstall
sudo apt-get install python-rosinstall
到此樹莓派2B上安裝indigo ros基本完成,由於開發方便,和ros很多包需要圖形介面支援,所以建議安裝小型的桌面系統。

5 安裝Ubuntu桌面

以為樹莓派處理能力較弱,桌面選擇儘量選用xubuntu-desktop桌面

This is a small ubuntu-server image. If you want a full desktop, go ahead and do so:

$ sudo apt-get install xubuntu-desktop  # or
$ sudo apt-get install lubuntu-desktop  # or
$sudo apt-get install kubuntu-desktop  # etc

Ubuntu (Unity) and Ubuntu-GNOME just display a blank screen, presumably because they require 3D compositing. Kubuntu works but is slow unless you

turn off desktop effects under System Settings. Xubuntu and Lubuntu work fine out of the box.

建議選擇xubuntu-desktop桌面。

6 製作ubutnu+ros的系統映象

1.開啟終端。

2.將你的樹莓派的SD卡插入到電腦的讀卡器上去。

3.輸入sudo fdisk -l檢視磁碟列表。根據顯示的容量大小找到SD卡(名字通常是/dev/sdbX,對於一些內建的SD卡,這裡可能顯示為

/dev/ mmcblkX,這裡的X對應你電腦上相應的裝置編號)。

4.輸入sudo dd of=temporaryimage.img if=/dev/sdX bs=2M來讀取SD卡中的內容並寫入到temporaryimage.img檔案中


以上經過實踐操作實踐驗證,效果非常可以,希望為這方面需要的朋友提供參考和借鑑。