Skip to content
chuck-h edited this page Feb 22, 2015 · 23 revisions

A master "brain" supervises a number of culture-chamber "slave" microcontrollers.

(Note: the master controller configuration is under development and this page may become stale often.)

We are using the Raspberry Pi 2 Model B (released early in 2015) as this master controller. This low-cost single-board computer runs Ubuntu 14.10 and ROS. It communicates with the slaves (using a virtual serial port protocol) over USB.

Raspberry Pi Initial Setup

Create Ubuntu OS Image on Micro SD Card

See also this

  1. Download the Ubuntu 14.10 (uneric) version compiled for RPi2 from torrent or zipfile mirror onto your laptop/desktop.

  2. Check the file integrity:

sha1sum raspuntu-tjc-2015-02-16.zip 39b1806ffcb063af0f36026900fdf188bb8d4aed raspuntu-tjc-2015-02-16.zip


1. Extract the OS image from the zip file, with

  `unzip raspuntu-tjc-2015-02-16.zip`

1. Transfer to a micro SD card, minimum 4GB. (These Linux instructions are condensed from [eLinux.org](http://elinux.org/RPi_Easy_SD_Card_Setup#Flashing_the_SD_Card_using_Linux_.28including_on_a_Raspberry_Pi.21.29); Windows instructions are also available on the same web page.) Perform the following steps on a laptop or desktop computer running linux (e.g. Ubuntu).
 1. Run

    `df -h`

    to see what devices are currently mounted.
 1. Insert the SD card. Run `df -h` again. The device that wasn't there last time is your SD card. The left column gives the device name of your SD card. It will be listed as something like "/dev/sdd1" or "/dev/mmcblk0p1". The last part ("1" or "p1" respectively) is the partition number. (Note: removing partition suffix will give the "whole SD card" device name needed later.)
 1. Unmount the partition(s).

    `umount /dev/sdd1`

    (Replace "/dev/sdd1" with your actual device name if different.) If your SD card shows up with multiple partitions, unmount all of them.
 1. In the terminal write the image to the card with this command, making sure you replace the input file `if=` argument with the path to your .img file, and the "/dev/sdd" in the output file `of=` argument with the device name of the whole SD card, not just a partition of it (for example, sdd, not sdds1 or sddp1, or mmcblk0 not mmcblk0p1)

   `sudo dd bs=4M if=~/Downloads/raspuntu-tjc.img of=/dev/sdd`

 1. The dd command does not give any information of its progress and so may appear to have frozen. It could take more than five minutes to finish writing to the card. Be patient. After the transfer is complete, run the sync command (this will ensure the write cache is flushed and that it is safe to unmount your SD card):

    `sudo sync` 

1. Remove SD card from card reader, and insert it in the Raspberry Pi.

### Configure OS

1. Connect monitor, keyboard, and mouse to the RPi, insert the micro SD card, and apply power. Sign in with the default user "linaro", password "linaro".

1. If you have a USB-wifi adapter installed, you will need to edit a configuration file to make it useful. (More info [here](http://www.maketecheasier.com/setup-wifi-on-raspberry-pi))
 1. Start the editor

   `gksudo leafpad /etc/wpa_supplicant/wpa_supplicant.conf`

 1. Enter text similar to this (this is the setup for my home DSL router):
    ```
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
            ssid="myqwest7732"
            psk="wirelesspasswd"
            proto=RSN
            key_mgmt=WPA-PSK
            pairwise=CCMP
            auth_alg=OPEN
    }
  1. There is, unfortunately, a USB device ID conflict related to the serial device in our "slave" microcontroller boards. To keep them from masquerading as electronic thermometers, do
    sudo -s
    echo "blacklist cytherm" >> /etc/modprobe.d/blacklist-cytherm.conf
    exit
    

1. Set up repositories for `apt-get`.
 1. Check that the `/etc/apt/sources.list.d` file contains the ubuntu main repo's; if not, edit. File should contain
    ```
    deb http://ports.ubuntu.com/ubuntu-ports/ utopic main restricted universe multiverse
    deb-src http://ports.ubuntu.com/ubuntu-ports/ utopic main restricted universe multiverse
  1. Add the ROS repositories:
    sudo -s
    echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
    exit
    

### Install ROS

Condensed from [these instructions](http://wiki.ros.org/indigo/Installation/UbuntuARM), which you should probably read.

1. Install core ROS system.
 sudo update-locale LANG=C LANGUAGE=C LC_ALL=C LC_MESSAGES=POSIX
 wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
 sudo apt-get update
 sudo apt-get install ros-indigo-ros-base
 sudo apt-get install python-rosdep
 sudo rosdep init
 rosdep update
 sudo apt-get install python-rosinstall
 echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
 source ~/.bashrc

1. Installation check. Run "roscore", then kill it with control-C. Output should be similar to this:

linaro@raspberry:~$ roscore ... logging to /home/linaro/.ros/log/81fd68ec-bab7-11e4-b3a7-00212f2ff845/roslaunch-raspberry-2140.log 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 server http://raspberry:55791/ ros_comm version 1.11.9

SUMMARY

PARAMETERS

  • /rosdistro: indigo
  • /rosversion: 1.11.9

NODES

auto-starting new master process[master]: started with pid [2152] ROS_MASTER_URI=http://raspberry:11311/

setting /run_id to 81fd68ec-bab7-11e4-b3a7-00212f2ff845 process[rosout-1]: started with pid [2166] started core service [/rosout]

^C[rosout-1] killing on exit [master] killing on exit Unhandled exception in thread started by sys.excepthook is missing lost sys.stderr shutting down processing monitor... ... shutting down processing monitor complete done linaro@raspberry:~$

1. Install rosbridge.
 sudo apt-get install ros-indigo-rosbridge-server

1. Make a catkin workspace for development. (condensed from [here](http://wiki.ros.org/catkin/Tutorials/create_a_workspace))
cd ~/
mkdir -p catkin_ws/src
cd catkin_ws/src/
catkin_init_workspace
cd ..
catkin_make

1. Get rosserial, a package for ROS communications with small embedded systems (like our slave microcontrollers) which are too lightweight to support the standard ROS TCP/IP messaging. There is a standard rosserial package available, but it does not include PSoC4 support. Therefore we use the forked rosserial from chuck-h.

cd ~/catkin_ws/src/ git clone https://github.com/chuck-h/rosserial.git cd rosserial/ git checkout indigo-devel


1. Build the rosserial package (this takes a while).

cd ~/catkin_ws catkin_make install


1. Test installation.
 1. Attach the slave microcontroller to a USB port on the Raspberry Pi; check that it has installed itself:
     ```
     linaro@raspberry:~$ ls /dev/ttyACM*
     /dev/ttyACM0
  (Note: Failure to install may be due to a cytherm conflict; look at the output of `dmesg` and see blacklist instructions above.)
  1. Run roscore (allow it time to start up) and then rosserial:
    roscore &
    source install/setup.sh
    rosrun rosserial_python serial_node.py /dev/ttyACM0
    

 1. In a second terminal window, observe output:
     ```
     linaro@raspberry:~$ source catkin_ws/install/setup.sh
     linaro@raspberry:~$ rostopic echo chatter
     data: hello world!
     ---
     data: hello world!
     ---
     ^C
     linaro@raspberry:~$

Components

Tested components

item mfr P/N
Single Board Computer Raspberry Pi 2 Model B MCM 83-16530 $35.00 ea
USB Wifi Adapter WiPi MCM 831-3058 $9.69 ea
USB Wifi Adapter Airlink AWLL5099 Amazon $16.00 ea
16GB MicroSD memory card Lexar Office Depot