Saturday, November 9, 2013

BBB: Adventures in ROS - Getting Setup

Originally written about a month ago when I started this project. I will be posting more as I make progress.

Now that I finally have a Beaglebone Black, I can start to explore and have some fun. I want to get back to working on the SBot and with all the features I want to add, I was leaning towards an onboard Linux system with an Arduino or similar to do the low level timing stuff. Originally I wasn't going to go the ROS route and write everything from scratch, but the more I dive into ROS (Robot Operating System), this seems the way to go.

So first things first, get ROS running on the BBB and see what I can do with it. It's a little tricky getting to work and you have to setup cross compiling. It's not too bad but it does take awhile to setup. Here is how I did it.



I found the Beagle-ROS project to get me started, at least pointing me in the right direction. First off, start with the section Getting ROSCORE running from https://github.com/vmayoral/beagle-ros. This gets you to the point where you can actually run ROSCORE. Only change I did: I used the stock image for the BBB instead of downloading Angstrom. Now there isn't much you can do with that. The fun is adding packages and talking to hardware. My first goal is getting camera support but I may have to take it easy and do something that is ready for the BBB. I have a few Sharp IR sensors that may do the trick. Then comes the hard part: interfacing with a Arduino sketch to get motor control.

Once ROSCORE is running I needed to setup cross-compiling for Angstrom on a desktop. I have Ubuntu 12.04 LTS running on my VMWare ESXi server.

I started with this site:
http://www.angstrom-distribution.org/building-angstrom

Which worked for the most part but had issues with step 2. Then I found:
http://cwraig.id.au/?p=507
This site has a list of packages you need before you setup bitbake.

Finally, I found this site which gets you compiling a quick "hello world" c program to make sure you are in business.

http://datko.net/2013/05/06/cross-compiling-applications-for-the-beaglebone/

Step 6 mentions commenting INHERIT += "rm_work", but since I am working just on ROS packages I decided not to do that. It keeps the kernel sources, uses about 4Gb, but you may need them.

Found this site about commenting it out.
http://wind.cs.purdue.edu/doc/crosscompile.html


Here is the down and dirty:

Starting from your home directory:

sudo apt-get install sed wget cvs subversion git-core coreutils unzip texi2html texinfo docbook-utils gawk python-pysqlite2 diffstat help2man make gcc build-essential g++ desktop-file-utils chrpath dosfstools kpartx

also add 
zlib1g-dev (this is needed later for compiling boost when doing recipes.)

mkdir BBB

cd BBB

git clone git://github.com/Angstrom-distribution/setup-scripts.git


cd setup-scripts

./oebb.sh config beaglebone/
./oebb.sh bitbake virtual/kernel (takes awhile)

At this point you can try to compile the 'hello world' test. First you need to set the compiler in your path. I couldn't get this to work yet, so I had to use absolute paths. 

Adjust as needed for your setup, I had to change x86_64-linux to i686-linux.

PATH=$PATH:~/setup-scripts/build/tmp-angstrom_v2012_12-eglibc/sysroots/i686-linux/usr/bin/armv7a-vfp-neon-angstrom-linux-gnueabi

cd ~/BBB
nano hello.c

paste the following:

#include <stdio.h> int main(void) { printf("Hello Beaglebone world!\n"); return 0; }


Compile with 
arm-angstrom-linux-gnueabi-gcc -o hello hello.c

Now you shouldn't be able to run the output. 

chmod +x ./hello

./hello


Then copy to your BBB and run. It should output "Hello BeagleBone world!"

I copied it over using SCP.
scp ~/BBB/hello user@beagleboneIP:~/

This confirms you are able to cross-compile and run it on the BBB.

Now it's off to learn ROS packages and compiling using recipes! Yay!






2 comments:

  1. I will check it out. I think I was prepping for ROS cross-compiling which has more dependencies. Then the Hello World was to test the C compiler and running it on the BBB.

    ReplyDelete
    Replies
    1. Yeah, please let me know... Even I'm starting out with ROS on BBB and a bit confused :)

      Delete