OpenROV Cape Test Program (No Beaglebone required)

November 30, 2013

I decided to modify the OpenROV 2.4 Arduino source code to create an automatic test program that stimulates each of the cape outputs periodically to see if the Arduino ATmega328 chip and connecting circuitry are operating correctly.  Software has been tested with the cape operating  stand alone.  Hopefully it will run in a OpenROV cape with a Beaglebone attached provided the cape.(TBD)

Hardware Requirements:

OpenROV cape

Servo

LED lights

Battery Pack (12v)

ATmega328 programmer (Arduino Uno will do)

Proceedure:

1) Remove the ATmeta328 chip from the Cape and use an Arduino board to load the Openrov_cape_test.ino with includes.

2)Place the ATmega328 chip back into the Cape and hook up the externals (motors, servo and lights) .

3) Connect the battery power to the Cape. (Typically 12v)

4) Watch motors , servo and light cycle periodically in sequence. Each command level lasts for 2 seconds.

20131130-171808.jpg

Software Files: Download OpenROV_cape_test  folder from my dropbox. In it you will find the following OpenRov_cape_test.ino file.   Just use it instead of OpenRov.ino file.

/* OpenROV_cape_test  Written by Chris Siegert, 11.30.13 , vamfun@yahoo.com, https://vamfun.wordpress.com This program is designed to test the OpenROV Cape.  Program generates commands that cycles motors, tilt servo and lights sequentially.  No Beaglebone is required for the test. Power the cape using the battery input terminals and connect the output devices. All motors are cycled simultaneously with 2 second steps at magnitudes {135,90,45,90}. Motors are left in reset mode. Next the servo is commanded to {170,10,90}Basically full tilt up to full tilt down and back to neutral. The light goes to full brihtness then to half brightness and then off. The device sequencing is then repeated continuously. If running without the Beaglebone, load the sketch and its includes into the ATmega chip using an Arduino project board or programmer.  Then reinsert the chip back into the cape.   If running with the Beaglebone, one might be able to just upload the program using the OPENROV cockpit utility. */

#include <Servo.h>

#include <Arduino.h>

#include “Motors.h”

#include “Command.h”

#include “Device.h”

#include “Timer.h”

Motors motors(9, 10, 11);

Command cmd;

Device vout(“vout”, 0, vout.analog, vout.in);

Device light(“light”, 5, light.analog, light.out);

Timer time;

Servo tilt;   int array[MAX_ARGS];

int case_no=1;   void setup(){

Serial.begin(9600);

pinMode(13, OUTPUT);

tilt.attach(3);

motors.reset();

light.write(0);

time.reset();

delay(3000);//wait for ESC to calibrate }

void loop(){

switch ( case_no)   {

case 1:

Serial.print(“motor”);

Serial.print(”  mag = “);

Serial.println(135);

motors.go(135,135,135);

delay(2000); //cds  set step delay

Serial.print(“motor”);

Serial.print(”  mag = “);

Serial.println(“90”);

motors.go(90,90,90);

delay(2000);

Serial.print(“motor”);

Serial.print(”  mag = “);

Serial.println(“45”);

motors.go(45,45,45);

delay(2000);

Serial.print(“motor”);

Serial.print(”  mag = “);

Serial.println(“90”);

Serial.println();    //motors.reset();

motors.go(90,90,90);

case_no++;

break;

case 2:

Serial.print(“servo” );

Serial.print(”  mag = “);

Serial.println(“170”);

tilt.write(170);

delay(2000);

tilt.write(90);

Serial.print(“servo” );

Serial.print(”  mag = “);

Serial.println(“90”);

delay(2000);

Serial.print(“servo” );

Serial.print(”  mag = “);

Serial.println(“10”);

tilt.write(10);

delay(2000);

Serial.print(“servo” );

Serial.print(”  mag = “);

Serial.println(“90”);

Serial.println();

tilt.write(90);

case_no++;

break;

case 3:

Serial.print(“light” );

Serial.print(”  mag = “);

Serial.println(255);

light.write(255);

delay(2000);

Serial.print(“light” );

Serial.print(”  mag = “);

Serial.println(128);

light.write(128);

delay(2000);

Serial.print(“light” );

Serial.print(”  mag = “);

Serial.println(0);

Serial.println();

light.write(0);

case_no++;

break;

default:

case_no = 1;  //repeat sequence

} //end switch

}


note 2 BeagleBone Black:building OpenROV software with Angstrom

August 9, 2013

I decided to try to get the OpenROV software working using the demo Angstrom distribution that comes installed in the BBB since it has a lot of the needed packages already installed and you don’t need an Ubuntu SD image.   There are 13 installation steps in the OpenROV/openrov-software/Readme.md file shown here.  I skipped step 1 since I am using Angstrom.  I postponed Step 2 for later if I get everything else working.

Step 3

upgrade software and install rerequisits (holy moly, there’re packages!):

sudo apt-get update
sudo apt-get install g++ curl pkg-config libv4l-dev libjpeg-dev build-essential libssl-dev vim cmake

I verified that most of the required packages were already installed and found only “build-essentials” missing from Angstrom.  Those that were installed were updated with opkg.

build-essentials was not found in searching Angstrom opkg.   However,  I did find packagegroup-core-buildessential-dev 1.0-r0.1 .  I installed this with opkg and seemed to work.

Installing SUDO:

Using opkg search I couldn’t find  a sudo package.  I did find an Angstrom dev package for sudo and installed that by downloading it to my computer from here and copying it to the BBB root.   I then used

root:/# opkg install ./sudo_1.8.4p4-r1_armv7a.ipk

The program unzipped the ipk package and successfully installed  sudo.

Step 4:

Install nvm (Node Version Manager):

git clone git://github.com/creationix/nvm.git ~/.nvm
echo ". ~/.nvm/nvm.sh" >> .bashrc
echo "export LD_LIBRARY_PATH=/usr/local/lib" >> .bashrc
echo "export PATH=$PATH:/opt/node/bin" >> .bashrc

And make those changes work now:

source ~/.bashrc

I followed these instructions and tried to install node v0.8.11 as per Steps 5 thru 7  but ran into a missing Python compiler.ast error so I opkg updated the Python compiler and then things worked.   Since Angstrom has v0.8.2 node installed already, I don’t think it is necessary to install v0.8.11 but I have yet to try this.

No /opt/ directory

It seems that my Angstrom dist doesn’t have an opt directory and I am not sure why since it is standard in the LInux directory tree.  Also many of the paths in OpenROV software assume it is populated.   My solution was to create the directory.   Later I would install OpenROV software into it.

Step 8

Install mjpg-streamer

Download mjpg-stream:

 wget http://downloads.sourceforge.net/project/mjpg-streamer/mjpg-streamer/Sourcecode/mjpg-streamer-r63.tar.gz

Prepare mjpg-streamer for make:

tar zxf mjpg-streamer-r63.tar.gz
cd mjpg-streamer-r63.tar.gz

Make and install OpenCV:

make && sudo make install

The r63.tar.gz package would not install because of  fatal error: videodev.h No such file or directory .   Apparently it uses videodev.h instead of videodev2.h which is in more recent library distributions of Linux..at least in my version of Angstrom.  I tried to fix it by just changing all the videodev.h to videodev2.h in all the source files that need it.  I got it to compile through most of the files but ran into some other problem which I don’t recall right now.   So I gave up and found a more recent version of mjpg-streamer on the github.com site that uses vidodev2.h.  You can download this from Dominik’s codewithpassion site as “mjpg-streamer or the sourceforge site that it is branched from.  You know you have the right version if mjpg_streamer.c has <linux/vidoedev2.h>.

I actually installed mjpeg-streamer-experimental in /root rather than /~ and tested it standalone and it seems to work fine with Chrome except there is about .5 second delay in the image.  I understand that the delay is roughly .2 to .3 seconds with Firefox browser but I didn’t try it.

Step 9 Download OpenROV ROVision:

cd ~
git clone git://github.com/OpenROV/openrov-software.git
cd openrov-software/

Change to development branch:

git checkout development

edit ~/.bashrc, add:

export LD_LIBRARY_PATH=/usr/local/lib

You’ll need to restart your shell:

source ~/.bashrc

Git OpenROV-software

Ok I did all this but I could not checkout development branch…it said that it didn’t exist.  I decided to use Dominiks codewithpassion/OPENROV code since it probably was more recent and also had a development branch which I checked out to 599ROV branch.

git clone git://github.com/codewithpassion/openrov-software/

git checkout remote/origin/development -b 599ROV

Step 10

Download modules:

npm install express socket.io serialport

Completed this step ok and had enough modules to start testing.  I did this from root directory.

Preliminary tests:

Restarted shell with

source  ~/.bashrc

node app

and got error that “forever-monitor’ module could not be found.   This is located in node.   I fixed this by reinstalling node in root rather than home.  The is is because the openrov software is now installed in /opt  I think.

Cockpit display now works and includes the Genius camera image!!

The next note will be on getting the Arduino firmware loaded to the OPENROV Cape.


 


Note 3 Beaglebone Black: Getting OpenROV software to load .hex file into Arduino

August 7, 2013

I tried to upload a new Arduino program to the OpenROV cape using the software routines and the procedure outlined here.   On the cockpit display you select setup and then select a program to upload.   This program is a tar or zip compression of the Arduino source files.   The tar file is automatically expanded and then an attempt is made to build the hex file required by the Cape Arduino processor for upload.   The program threw an error which I traced to Arduino “ino” command line toolkit  program not being installed on the BBB.   I attempted to load ino onto the BBB as described here but that failed since a setuptool file for Python was missing.   This was installed  using

cd /

opkg install python-setuptools

Next, I reran  /ino/make install and now it couldn’t find the file py.compile.  This file apparenty is used in later versions of Python.  Searching opkg angstrom packages I found  python-compile_2.7.2-r3.17_armv7a.ipk\ which was downloaded to my pc and ssh to BBB.  I then used opkg service to install  it:

cd /

opkg install python-compile_2.7.2-r3.17_armv7a.ipk

ino seemed to be installed without errors.  Now tried to upload an Arduino file and of course more problems arose.  Seems that the ino makefile puts some of ino Python libraries in the wrong folder and when the ino calls were made several library functions were not found.    A search showed up this post which discussed the libraries and one of the comments to the post said that installing ino with Python commands works.  So I reinstalled ino using

cd /ino

python setup.py install

At last success!!   I ran another upload and got a little further until more errors showed up.    Here is the log file output:

Received ‘arduinofirmware-startupload’ for file: OpenROV_arduino.zip file: undefined going to install the uploaded file: OpenROV_arduino.zip unpack: build dir is /tmp/tmp.klu0me4aEo

Archive:  /opt/openrov/src/temp/OpenROV_arduino.zip    creating: OpenROV/   inflating: OpenROV/Command.cpp   inflating: OpenROV/Command.h   inflating: OpenROV/Device.cpp   inflating: OpenROV/Device.h   inflating: OpenROV/Motors.cpp   inflating: OpenROV/Motors.h   inflating: OpenROV/OpenROV.ino   inflating: OpenROV/Timer.cpp   inflating: OpenROV/Timer.h

unziped /opt/openrov/src/temp/OpenROV_arduino.zip in /tmp/tmp.klu0me4aEo/src

Unpacked firmware file into Searching for Board description file (boards.txt) … FAILED Board description file (boards.txt) not found. Searched in following places:   – /usr/local/share/arduino/hardware/arduino   – /usr/share/arduino/hardware/arduino

Compiled firmware in directory Closing serial connection for firmware upload Setting up uploader

Searching for Board description file (boards.txt) … FAILED Board description file (boards.txt) not found. Searched in following places:   – /usr/local/share/arduino/hardware/arduino   – /usr/share/arduino/hardware/arduino

Initiating arduino reset

/opt/openrov/linux/reset.sh: line 18: /sys/kernel/debug/omap_mux/gpmc_ad0: No such file or directory

upload failed, trying again. Searching for Board description file (boards.txt) … FAILED Board description file (boards.txt) not found. Searched in following places: – /usr/local/share/arduino/hardware/arduino – /usr/sh are/arduino/hardware/arduino

Initiating arduino reset

So it can’t find the board description and it is missing sys/kernel/debug/omap_mux/gpmc_ad0.   Back later when I figure this out.

 Ok… I’m back.   The missing board .txt file indicates that I need to install the Arduino IDE.   Normally ino uses AVERDUDE to boot up files to the Arduino but this is not installed on BBB.  I I tried to opkg averdude but Angstrom doesn’t have that .  However, all these files are in the Arduino IDE.  So I downloaded the  linux Arduino .tgz from here and ssh it to my root. Then installed this way

cd /usr/share

tar -xzf /arduino-1.0.5-linux32.tgz

Cool, now I have board.txt and averdude.

 

I fixed the gpmc_ad0 error by updating rc.local to make use of the .dt0 file overlay files supplied with Angstrom for BBB which are located in /lib/firmware.   Basically, I commented any reference to omap_mux and add code to set up UART1.  I will write a more detailed post on how to do this.

Using .hex file instead of .tar file of source

Why not build the .tar file on the host PC and then ask the OpenROV software to just upload the .hex file to the Arduino?   First, it took me a while to find where the Arduino puts the IDE.  Some said that holding the shift key down while compiling will show the file.   This didn’t seem to work so I just searched for the project name in temp files and found my .hex program in this build directory.

C:\Users\vamfun\AppData\Local\Temp\build802015884711230598.tmp

Next I will work on how to make the OpenROV uploader use the file in .hex format rather than the expected .tar format.  You still need ino installed to do the hex file upload.  But it could save a few steps in the overall upload procedure.