Log in

View Full Version : NavX Field-Centric drive (LabView)


jojoguy10
28-01-2015, 17:55
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/wiki/FieldOrientedDrive 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
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.
/**
* 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
The Java WPILib code will. There's a good chance the LabVIEW will too.

It's a very simple vector rotation.
/**
* 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
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
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.