Active Camera Stabilization: Servo + Self Leveling Script


#1

I am interested in setting up something similar to this: Super Simple Gimbal Design. The reason being that I could actively correct the video camera position deviations due to proposing, tilting, water current changes, etc..

I need a sanity check in getting started.

Adding a servo to the 2.5 board should use an Analog In, Ground, and 5V. No special additional circuitry is required. Correct?

Will code similar to this provide read access to the telemetry? If not where should I start?

void loop for the X axis:

sensorValX = analogRead(sensorXPin);
sensorValX = constrain(sensorValX, calibrateXMin, calibrateXMax);
tiltX = map(sensorValX, calibrateXMin, calibrateXMax, 0, 179);
servoValX = constrain(servoValX - (tiltX - 89),0,179);
servoX.write(servoValX);
delay(15);

Goal:

Add a servo to roll the camera CCW and CW. Write a script controlling both camera rotation and roll via

Motivation:

Several of my friends have commented that watching OpenRov cockpit video is often disorienting, makes them sick, or dizzy. They comment on the activation of controls causing jerks and the porposing. Also I've seen several videos where the camera angle appears to be tilted or the craft is not level.

Some References I've Found:

Thesis Arduino Self-Leveling Platform

Forum Discussion with Code


#2

Hi Quantum:

I see that the question you are trying to solve, is quite close to the "Dead Reckoning"+Autopilot project.

You're right, that tendency to dive when full ahead, results on quite a swinging video recording. Software/hardware+hydrodynamic balance can solve the problem.

A couple of days ago, I posted a question on the software section, where I asked what programming lenguage has to be used for the ROV. I got no answers.

Could you please tell me which one is it?

Some sources for data filtering ....

Quite a good filtering algorithm with 3D data, crossed processing and correction

http://wiki.paparazziuav.org/wiki/Index.php/Main_Page

Flightgear flight simulator. Search for autopilot software.

Kind regards.

Lets go on ¡¡¡


#3

Hi Ion,

The software is well described in the GitHub. That said there are two clearly different languages bing used for different purposes. I think of it like this:

1. Hardware interfacing/control and calibration etc..: Arudino

2. Web GUI: see the GitHub ReadMe

3. OS/Software management: bash scripts

So for our purposes we would be using Arduio's language. I cut a section from their FAQ for you.

Can I program in C?
The Arduino language is merely a set of C/C++ functions that can be called from your code. Your sketch undergoes minor changes (e.g. automatic generation of function prototypes) and then is passed directly to a C/C++ compiler (avr-g++). All standard C and C++ constructs supported by avr-g++ should work in Arduino. For more details, see the page on the Arduino build process.

Can I use a different IDE to program the Arduino board?
It is possible to compile programs for the Arduino using other build tools (e.g. Makefiles and/or AVR Studio). You'll need to configure these to link against the appropriate files in the Arduino core libraries. See the description of the Arduino build process.
Can I use an Arduino board without the Arduino software?
Sure. It's just an AVR development board, you can use straight AVR C or C++ (with avr-gcc and avrdude or AVR Studio) to program it.

#4

Thanks a lot Quantum.

Im still on trying to design a more hydrodynamic hull for the ROV, but, at the same time, Im studying the Laser telemeter and image recognition questions.

I've written some test code in C++ using the OpenCV libraries, and it works.

The idea spinning around my head is that the Autopilot, Inertial DR, and any further improvement(Telemetetry software ......), would better be run at the "surface" computer.

I think it can be done in C++, Isn't it ?

Kind regards


#5

I would probably go ahead and extend the basic 1 axis camera tilt code we have in the arduino library right now. If you look at the latest auto pilot code we have in the dev repository you can see how we access the telemetry data:

https://github.com/OpenROV/openrov-software/blob/master/arduino/OpenROV/Pilot.cpp#L128

You can see all of the axis of telemetry data getting assigned here:

https://github.com/OpenROV/openrov-software/blob/master/arduino/OpenROV/MPU9150.cpp#L41

(And yes, please forgive the bastardization of heading in the code at the moment, I'm working on that ;-)


#6

Hi Brian:

Thanks a lot for pointing me to those pieces of code, which I din't know to be alredy done.

About the second link: I see the Euler integration is defined in the MPU library, that's a good new.

Hence, angles are aready done. Now, it would be fine getting linear accelerations in order to start with DR.

About the first link:

Seems it has been implemented a partial PID system, or may be I didn't pay the due attention.

I see the integrator term, but cannot find the differential one.

Regards


#7

Yep. Its a P.i.....d controller :-)

This was just the start so that folks that live and breath control systems can see where and how to interact with the rest of the ROV. If you or anyone else is interested in tightening the implementation up, or playing with alternative control systems, go for it!