Artificial Horizon in processing 2.0

I found a program written in processing 2.0 that takes mouse movement and displays it in an artificial horizon and a heading indicator.  I added serial and changed the input from mouseX and mouseY to the Euler angles coming from the ArduIMU.  The heading indicator works perfectly.  The problem is pitch and roll movement is limited to about 45 degrees roll and 0 - 90 degrees pitch.  I'm not sure how to fix it and hope somebody will try it out and take a look at it. 

I tried to replace the mapping of the mouse with sin(Euler[1]) and cos(Euler[2]).  The map() in processing takes an input, then it needs the upper and lower range of the input, and then the upper and lower range of the target.  For sin and cos, I used -1 to 1 as the input range. 

To try it out, you need to run FreeIMU on the ArduIMU and you need processing 2.0.  There's a line in the first sketch to select your comport.  Mine was COM4 so just edit that to match yours.

It almost works, just needs something.  Thanks for helping.

ArtificialHorizon_rev2-131219a.zip

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies


  • float X = (Euler[2]);
    float Y = (-Euler[1]);
    float newX = map(X, -PI/2, PI/2, -150, 150);
    float newY = map(Y,-PI/2,PI/2, -150,150 )+150;


    I changed those 4 lines in the movingHorizon sketch. It's much better, so if you try it with your IMU
    I recommend making that change. I changed the range of the input to -PI/2 to PI/2 and I added 150 to the Y and that brings the indicator to level at start.

    I'd really like some input to improve it. Thanks.

This reply was deleted.

Activity