Detecting AR Tags with ROS on Odroid U3

THIS PAGE IS OUTDATED

Shopping List

  • Odroid U3 Case
  • Odroid U3 eMMC card (at least 16 GB)
  • MicroSD to USB adapter. I recommend Transcend USB 3.0 (TS-RDF5K). Click here for compatible units.
  • Power supply
  • Odroid SERIAL console cable
  • Logitect C920 Webcam
  • Pixhawk Autopilot

Overview

These instructions will get a multi-rotor hovering over AR markers. The webcam (pointing downwards) will detect the AR markers using the ROS package ar_track_alvar. This publishes a topic with the position and pose estimate of the camera relative to the AR marker. The mavlink_ros node then subscribes to this topic and converts it to the vicon position esitmate mavlink message and sends it to the Pixhawk via the UART. The PX4 autopilot firmware will then feed the position estimate into the position controller to keep the multi-rotor positioned above the marker. FIXME

Hardware Setup

  • Connect the eMMC card to its adapter, insert the microSD card into a card reader (e.g. via a microSD to SD adapter).
  • Lipo to 5V power supply

Software Setup

Setup the required software on the Odroid U3.

Flash eMMC card with Linaro Ubuntu 12.11

Download the Robotics Edition V2 image from Odroid. This image is optimised for Odroid:

Confirm the downloaded image MD5 check sum matches this file.

If you get these commands wrong, you can wipe your hard drive

Linux:

To check which drive is the USB SD card reader, list the current drives with the following command then insert the USB SD card reader run the command again and take note of the new drive. Replace /dev/sdX in the commands below with this, normally it will be /dev/sdb if you only have one harddrive.

df -h

Follow these commands to flash the image to eMMC on Linux. Heres the official Odroid guide.

mount
umount /dev/sdX
xz -d xubuntu-13.04-desktop-armhf_odroidu2_20130503.img.xz
sudo dd if=/dev/zero of=/dev/sdX bs=4M
sudo dd if=xubuntu-13.04-desktop-armhf_odroidu2_20130503.img of=/dev/sdX bs=4M
sync

Mac OSX:

Follow these commands to flash the image to eMMC on a Mac (same as Linux). Heres the official Odroid guide.

mount
umount /dev/sdX
xz -d xubuntu-13.04-desktop-armhf_odroidu2_20130503.img.xz
sudo dd if=/dev/zero of=/dev/sdX bs=4M
sudo dd if=xubuntu-13.04-desktop-armhf_odroidu2_20130503.img of=/dev/sdX bs=4M
sudo diskutil eject /dev/sdX

Windows:

A Odroid specific version of Win32DiskImager found here can be used to flash the image to the eMMC.

Getting up and running

Remove the eMMC from the microSD adapter and connect the eMMC to the back of the Odroid board.

  • Note you can't start eMMC and SD card at the same time (I think you can but it wouldn't work for me).

You need to enlarge the eMMC to use all available space. This can be done while the eMMC, in microSD adapter, is connected to a host Ubuntu PC using gparted. Or running 'sudo odroid-config' command on the Odroid? (this isn't available on this image) FIXME

You will need to connect a screen, keyboard and mouse initially to setup SSH (unless you have the UART console cable). Once this is running then you no longer need these peripherals connected. Connect the Odroid to the internet via cable. Power up the Odroid.

Enable SSH server:

sudo apt-get install openssh-server

Get the System Up to Date

sudo apt-get update
sudo apt-get upgrade

Install Prerequisites and Tools

sudo apt-get install v4l-utils libopencv-* guvcview

Install ROS (Robot Operating System) Hydro

Follow these instructions to install ROS Hydro for armhf.

Install the base ROS package:

sudo apt-get install ros-hydro-ros-base

Install ar_track_alvar ROS package

Ar_track_alvar package is a ROS wrapper for Alvar, an open source AR tag tracking library.

Install prerequisites for ar_track_alvar:

sudo apt-get install ros-hydro-image-transport ros-hydro-resource-retriever ros-hydro-visualization-msgs ros-hydro-cv-bridge

Setup a catkin build environment:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

Add the setup file to bashrc and make sure to re-source the bash file:

echo 'source devel/setup.bash' >> ~/.bashrc
source ~/.bashrc

Clone the ar_track_alvar package:

cd ~/catkin_ws/src
git clone https://github.com/sniekum/ar_track_alvar -b hydro-devel 

Build the project:

cd ~/catkin_ws
catkin_make

If you get an error here saying:

"virtual memory exhausted: Cannot allocate memory"

Then try increasing the virtual memory following the instruction here or re-running catkin_make. If you get the following error even after increasing the virtual memory, the try re-running catkin_make.

"c++: internal compiler error: Killed (program cc1plus)"

Install other ROS packages

Required:

sudo apt-get install ros-hydro-camera-umd ros-hydro-image-proc ros-hydro-camera-calibration

Optional:

sudo apt-get install ros-hydro-image-view ros-hydro-usb-cam 

Calibrate Camera

The camera needs to be calibrated to account for fish eye and other lens effects.

Follow this guide to calibrate the camera. You need to download the large checkerboard and print it off. Then stick it to a flat panel.

Connect the Logitech C920 webcam and start the node to produce images:

rosrun uvc_camera uvc_camera_node width:=640 height:=480 frame:=camera device:=/dev/video0

Run the camera_calibration node.

rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.495 image:=/image_raw camera:=/

Follow the instructions on the tutorial.

FIXME Where does it store this file to be used for correcting image.

Create ROS Launch Files

FIXME Need to correct the location of the calibration file.

Create the launch file:

cd ~catkin_ws/src/ar_track_alvar/launch
nano mav_track.launch

Add the following to the mav_track.launch file.

<launch>
  <node pkg="tf" type="static_transform_publisher" name="mav_to_camera" output="screen" 
    	args="0 0 0 0.785398163 0 0 mav camera 10" />
 
  <node ns="camera" pkg="image_proc" type="image_proc" name="image_proc"/>
  <node ns="camera" pkg="uvc_camera" type="uvc_camera_node" name="uvc_camera"
    output="screen">
    <param name="width" type="int" value="640" />
    <param name="height" type="int" value="480" />
    <param name="fps" type="int" value="30" />
    <param name="frame" type="string" value="camera" />
    <param name="device" type="string" value="/dev/video0" />
    <!-- param name="camera_info_url" type="string"
      value="file://$(find uvc_camera)/camera_calibration.yaml" / -->
    <param name="camera_info_url" type="string"
      value="file://$(find ar_track_alvar)/c920_640.yaml" />
  </node>	
 
 
 
	<arg name="marker_size" default="6.8" />
	<arg name="max_new_marker_error" default="0.08" />
	<arg name="max_track_error" default="0.2" />
	<arg name="cam_image_topic" default="/camera/image_raw" />
	<arg name="cam_info_topic" default="/camera/camera_info" />	
	<arg name="output_frame" default="/camera" />
 
	<node name="ar_track_alvar" pkg="ar_track_alvar" type="individualMarkersNoKinect" respawn="false" output="screen" args="$(arg marker_size) $(arg max_new_marker_error) $(arg max_track_error) $(arg cam_image_topic) $(arg cam_info_topic) $(arg output_frame)" />
</launch>

Setup Network Capabilities

ROS is a distributed computing environment. This allows nodes to be distributed across multiple computers to share the workload. We can use this functionality to enable visualisation and debugging from our main development computer.

Add hostnames to the host file so IP addresses are resolvable by hostname:

Edit the hosts file with your favourite editor:

sudo nano /etc/hosts

Add the folowing lines (change these to suit the actual hostnames and IP addresses of your machines):

192.168.1.10	odroid-ros		        # Odroid-U3
192.168.1.11	ubuntu-ros			# Host machine

Need to restart the file (this couldn't find the file, but the hostname was resolved). Maybe it auto detects changes??

/etc/rc.d/init.d/network restart

Test you can ping the Odroid from development computer and vice-versa:

ping odroid-ros
ping ubuntu-ros

Add this to the ~/.bashrc of both machines and re-source bash file:

echo 'export ROS_MASTER_URI=http://odroid-ros:11311' >> ~/.bashrc
source ~/.bashrc

Setting Up A Visualisation / Debugging Environment

On your development computer install ROS Hydro.

Install RViz:

sudo apt-get install ros-hydro-rviz

FIXME Add link to pre-setup *.rviz file

Running It All

On the Odroid run the launch file:

roslaunch ar_track_alvar mav_track.launch

On the development computer run RViz. From here you can add topics to view:

rosrun rviz rviz
  • Present a AR tag in front of the camera.
  • The camera window will how the live C920 video with a overlay on the detected markers.
  • The main window will show the transforms.

Coming Soon!

  • ROS - Mavlink bridge
  • Using an updated Ubuntu image
  • Add package to visualise quad in RViz

Other items to add:

- Install x11vnc

- Shared folders

Translations of this page:


Quick Links

QR Code: URL of current page