(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Raspberry Pi Setup

Description: This tutorial shows how to setup a Raspberry Pi and connect it to AscTec MAVs' HighLevel Processors.

Keywords: raspberrypi, asctec, pelican, firefly, autopilot, onboard computer, quadcopter, hexacopter

Tutorial Level: BEGINNER

Overview

This tutorial shows how to setup the Raspberry Pi on AscTec MAVs, connecting it to the HighLevel Processor. We assume that there is a WiFi network where the Pi can connect to.

Setting up the Raspberry Pi

Get a current Raspbian Image from the Raspberry Pi download page (a "raw" Raspbian image) and flash it to an SD card as described there. Boot the Pi with the SD card, in the raspi-config, expand to the full file system, give the Pi a suitable Hostname (Advanced Options -> Hostname) and change the password for the pi user away from raspberry. Configure your WiFi using the WiFi Config tool located on the desktop (startx), you need a WiFi dongle for that. Afterwards, you can conveniently putty/ssh to the Pi.

Installing ROS

We do not intent to run a "full" ROS on the Raspberry Pi, but rather install some basic packages along with the dependencies for the asctec_mav_Framework! If you need more of the ROS packages, you may install them, though.

The easiest way to install ROS is to use the (experimental groovy) repository that is described here and here. Add it to your repositories by using these commands:

sudo echo "deb http://64.91.227.57/repos/rospbian wheezy main" >> /etc/apt/sources.list
wget http://64.91.227.57/repos/rospbian.key -O - | sudo apt-key add - 
sudo apt-get update

A list of available packages in this repository is to be found here. Install a ROS backbone (roscore, roscpp, rospy, ...) by calling:

sudo apt-get install ros-groovy-ros-comm

As you may imagine, this takes a while.

Source the groovy path at every startup by invoking:

echo "source /opt/ros/groovy/setup.bash" >> ~/.bashrc 
~/.bashrc

The basic ROS commands should work now. You can check this by calling:

export | grep ROS

Installing the asctec_mav_framework

Preparations

Now, add a workspace (here: in your home folder):

mkdir -p ~/workspace_groovy/src 
cd ~/workspace_groovy/src 
catkin_init_workspace 
echo "source ~/workspace_groovy/devel/setup.bash" >> ~/.bashrc 
echo "export ROS_PACKAGE_PATH=~/workspace_groovy:$ROS_PACKAGE_PATH" >> ~/.bashrc
~/.bashrc

And download additional dependencies of the framework:

sudo apt-get install ros-groovy-tf ros-groovy-dynamic_reconfigure libeigen3-dev ros-groovy-actionlib* ros-groovy-diagnostic-updater
cd ~/workspace_groovy 
rosdep init 
rosdep update

For us, the rosdep update threw two errors, probably due to the ROS repositories not knowing the "Raspbian Wheezy" OS. The further steps did work, anyways.

Download and install additional ROS packages

The ethzasl_sensor_fusion and asctec_mav_framework are not (yet) part of the repository. They need to be downloaded separately:

cd ~/workspace_groovy
git clone git://github.com/ethz-asl/ethzasl_sensor_fusion.git ethzasl_sensor_fusion
git clone git://github.com/ethz-asl/asctec_mav_framework.git asctec_mav_framework

Make ethzasl_sensor_fusion by calling:

rosmake ethzasl_sensor_fusion

This, too, takes some time. To give you an idea:

  • sensor_fusion_comm compiles around 3minutes
  • ssf_core compiles around 15 minutes with 6 warnings)
  • ssf_update compiles around 15 minutes

And then the make asctec_mav_framework:

rosmake asctec_mav_framework

Again, some compile times:

  • asctec_hl_comm (~5minutes)
  • asctec_hl_gps (~12 minutes, 3 warnings)
  • asctec_hl_interface (~40 minutes, 23 warnings)

Configure fcu_parameters.yaml like this:

serial_port:            /dev/ttyAMA0
...
state_estimation:       HighLevel_SSDK
position_control:       HighLevel

Adapt the other values as they seem fit or leave them as they are.

Specify the reference frame and tracked frame in the ssdk_parameters.yaml as they fit.

Configuring ROS to use a different host

In order for the ROS nodes running on the Pi to connect to a roscore on a different machine, you will have to export some variables:

export ROS_MASTER_URI=http://[Master IP]:11311
export ROS_HOSTNAME=[Pi's IP/`localhost`]
export ROS_IP=[Pi's IP/`localhost`]

You may also add this to your local ~/.bashrc so that this configuration gets done on each startup.

By default, the master's variables should be configured like this:

export ROS_MASTER_URI=http://[Master IP/`localhost`]:11311
export ROS_HOSTNAME=[Master IP/`localhost`]
export ROS_IP=[Master IP/`localhost`]

If you encounter communication problems, check this first.

Configure the GPIO serial interface

/dev/ttyAMA0 was mentioned above - this is a serial interface available at the GPIO pins. By default, it is configured to serve as a terminal interface. In order to deactivate the login prompt, comment out the last line (T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100) from /etc/inittab by inserting a # before it.

sudo nano /etc/inittab

In order to suppress booting messages from this interface, change the content of /boot/cmdline.txt from

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

to

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

That is, remove all occurences of ttyAMA0:

sudo nano /boot/cmdline.txt

You need to reboot your system for these changes to take effect:

sudo shutdown -r now

This information stems from here. There is also a nice way to test whether the interface works behind that link.

Wiring

Serial

The Pin layout of the GPIO Pins at the Pi can be seen here. The layout on the other end of the wire needed can be seen in AscTec's AutoPilot Manual in section 4.1. Keep in mind that the Rx and Tx lines need to be swapped in between and pull the CTS line to ground. This will result in a non-twisted cable with a fork. As of our understanding, this is no standard cable and you will need to crimp/solder it yourself.

Power

The Pi needs 5V input power via a micro-USB plug. !Asctec's PowerBoard offers 5V, so you will need to solder the VCC/GND cables of a micro-USB cable to the +/- ports at the PowerBoard. The Layout of that board is to be found in the AutoPilot Manual, section 1.1.2; USB specs can be found here. As the resulting cable will offer higher currents than USB usually does, we suggest shorting the D+/D- wires, which is usually done for micro-USB chargers.

Performance

The serial port was tested for baud rates up to 921k6, which proved working.

We ran the hl_node with standard packet rates defined in ssdk_parameters.yaml on a Pi model B with a CPU load of 50-55%, which could be reduced to ~40% when using only 1Hz data. This information is based on information obained from top while vicon data was available at 100Hz.

See also

This tutorial was written after the suggestion in this thread.

Wiki: asctec_mav_framework/Tutorials/Raspberry Pi Setup (last edited 2013-06-06 12:53:51 by JoachimMueller)