### 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

#### 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.

### Activity

RT @chr1sa: Just a week to go before our next @DIYRobocars race at @circuitlaunch, complete with famous Brazilian BBQ. It's free, fun for k…
1 hour ago
How to use the new @donkey_car graphical UI to edit driving data for better training https://www.youtube.com/watch?v=J5-zHNeNebQ
Monday
RT @SmallpixelCar: Wrote a program to find the light positions at @circuitlaunch. Here is the hypothesis of the light locations updating ba…
Nov 26
RT @SmallpixelCar: Broke my @HokuyoUsa Lidar today. Luckily the non-cone localization, based on @a1k0n LightSLAM idea, works. It will help…
Nov 25
@gclue_akira CC @NVIDIAEmbedded
Nov 23
RT @luxonis: OAK-D PoE Autonomous Vehicle (Courtesy of zonyl in our Discord: https://discord.gg/EPsZHkg9Nx) https://t.co/PNDewvJdrb
Nov 23
RT @f1tenth: It is getting dark and rainy on the F1TENTH racetrack in the @LGSVLSimulator. Testing out the new flood lights for the racetra…
Nov 23
RT @JoeSpeeds: Live Now! Alex of @IndyAChallenge winning @TU_Muenchen team talking about their racing strategy and open source @OpenRobotic…
Nov 20
RT @DAVGtech: Live NOW! Alexander Wischnewski of Indy Autonomous Challenge winning TUM team talking racing @diyrobocars @Heavy02011 @Ottawa…
Nov 20
Incredible training performance with Donkeycar https://www.youtube.com/watch?v=9yy7ASttw04
Nov 9
RT @JoeSpeeds: Sat Nov 6 Virtual DonkeyCar (and other cars, too) Race. So bring any car? @diyrobocars @IndyAChallenge https://t.co/nZQTff5…
Oct 31
RT @JoeSpeeds: @chr1sa awesomely scary to see in person as our \$1M robot almost clipped the walls as it spun at 140mph. But it was also awe…
Oct 29