Monday, January 26, 2015

Arduino and Raspberry Pi via command line

Since I'm about to hook up an ArbotixM robot controller to a Raspberry Pi to control it with ROS, I needed to set up the tools to do that.  I'm avoiding the the raspberry desktop (which is quite fine mind you) for by robot and want to do it all via command line since so I can do this remotely via SSH.

Installing the 1.0 arduino environment for debian is just a matter of installing the debian package.

$ sudo apt-get install arduino

For the command line I found a very interesting set of tools called inotool.  To install that I did:

$ cd ~
$ mkdir repositories
$ cd repositories
$ git clone https://github.com/amperka/ino
$ sudo apt-get install python-setuptools
$ sudo easy_install pip
$ sudo pip install glob2
$ cd ino
$ sudo make install


there is a pip package available but it gave me issues later on when I wanted to add a new hardware board. More on that later.

Ino now allows me to create sketches, build, upload and communicate via serial.  Every thing the IDE would does for me. So to try that out do the following.

$ mkdir blinky 
$ cd blinky
$ ino init -t blink
$ ino build
$ ino unload

Immediately got me a blink program uploaded using a USB port connected Arduino UNO.  Ino actually makes educated guesses about what serial port to use and defaults to UNO. So far so good.

Since it isn't the UNO we want to program ultimately but an ArbotixM controller we need to add some magic to get that working for us.  First we need the arbotix hardware files for the arduino environment.  To be able to define additional board definitions with out adding the directly to the arduino install (which is bad manners) I had to switch to the git version as I noticed it was different from the pip package and able to deal with multiple directories.  It only searches in two places and on of the is the install directory and the other in /usr/local/share/arduiono.  So to get that set up I did the following.

$ git clone https://github.com/vanadiumlabs/arbotix
$ cd /usr/local/share/
$ sudo mkdir arduino
$ sudo cp -r ~/repositories/arbotix/hardware arduino/

The /usr/local/share/arduino folder should now contain hardware folder with an arbotix folder inside.

no we can build using the the arbotix target

$ cd ~/arduino_sketches/blinky
$ ino build -m arbotix

and we should end up with a nice arbotix blink program

Next lets test a serial program connected via a FTDI cable to the arbotix,  upload it and configure the ino.ini to make life easier.

No comments: