Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Sensors (http://www.chiefdelphi.com/forums/forumdisplay.php?f=173)
-   -   NavX Field-Centric drive (LabView) (http://www.chiefdelphi.com/forums/showthread.php?t=133627)

jojoguy10 28-01-2015 17:55

NavX Field-Centric drive (LabView)
 
Hello,

I noticed, after playing with the NavX from KuaiLabs a bit, that the GetYaw has a range from -180 to +180. My teams is planning to use field-centric driving.

From a LabView perspective (using the Holonomic drive VI), will it take an input of -180 to +180? Also, how is the best way to "zero" the yaw? In other words, how can I let the robot which way North is (field-centrically)?

Also, I looked at this example: https://code.google.com/p/navx-mxp/w...dOrientedDrive And it doesn't look like they compensated for the -180 to +180 range at all (we just added 180 to the output to get a 0-360 range)

Thanks!

Ether 28-01-2015 18:30

Re: NavX Field-Centric drive (LabView)
 
Quote:

Originally Posted by jojoguy10 (Post 1435345)
From a LabView perspective (using the Holonomic drive VI), will it take an input of -180 to +180?

The Java WPILib code will. There's a good chance the LabVIEW will too.

It's a very simple vector rotation.
Code:

    /**
    * Rotate a vector in Cartesian space.
    */
    protected static double[] rotateVector(double x, double y, double angle) {
        double cosA = Math.cos(angle * (3.14159 / 180.0));
        double sinA = Math.sin(angle * (3.14159 / 180.0));
        double out[] = new double[2];
        out[0] = x * cosA - y * sinA;
        out[1] = x * sinA + y * cosA;
        return out;
    }

What's important is that the gyro angle is increasing in the clockwise direction.



jojoguy10 28-01-2015 19:00

Re: NavX Field-Centric drive (LabView)
 
Quote:

Originally Posted by Ether (Post 1435363)
The Java WPILib code will. There's a good chance the LabVIEW will too.

It's a very simple vector rotation.
Code:

    /**
    * Rotate a vector in Cartesian space.
    */
    protected static double[] rotateVector(double x, double y, double angle) {
        double cosA = Math.cos(angle * (3.14159 / 180.0));
        double sinA = Math.sin(angle * (3.14159 / 180.0));
        double out[] = new double[2];
        out[0] = x * cosA - y * sinA;
        out[1] = x * sinA + y * cosA;
        return out;
    }

What's important is that the gyro angle is increasing in the clockwise direction.



Right, inside the Holonomic VI, this calculation is going on. Will it handle negative inputs?

Ether 28-01-2015 19:15

Re: NavX Field-Centric drive (LabView)
 
Quote:

Originally Posted by jojoguy10 (Post 1435376)
Right, inside the Holonomic VI, this calculation is going on. Will it handle negative inputs?

Sin(-pi/2) gives the same value as Sin(+3pi/2).

Same with Cosine.

Try it in Excel or on your calculator.

Or better yet, try it in a little LabVIEW program.



jojoguy10 29-01-2015 00:32

Re: NavX Field-Centric drive (LabView)
 
Quote:

Originally Posted by Ether (Post 1435378)
Sin(-pi/2) gives the same value as Sin(+3pi/2).

Same with Cosine.

Try it in Excel or on your calculator.

Or better yet, try it in a little LabVIEW program.



Duh! You're right. We'll try it out next time.


All times are GMT -5. The time now is 08:00.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi