Skip to content

Commit

Permalink
tighting up the unit test for #29
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Dec 19, 2016
1 parent 8c321ff commit caa127f
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.junit.Test;

import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR;
import com.neuronrobotics.sdk.util.ThreadUtil;

// TODO: Auto-generated Javadoc
/**
Expand All @@ -18,16 +19,17 @@ public class RotationNRTest {
@Test
public void test() {
int failCount = 0;
for (int i = 0; i < 100; i++) {
double tilt = Math.toRadians(Math.random() * 360.0 - 180);
double elevation = Math.toRadians(Math.random() * 360.0 - 180);
double azumus = Math.toRadians(Math.random() * 360.0 - 180);
int iterations = 100;
for (int i = 0; i < iterations; i++) {
double tilt = Math.toRadians((Math.random() *360.0) - 180);
double elevation = Math.toRadians((Math.random() * 360.0) - 180);
double azumus = Math.toRadians((Math.random() * 360.0) - 180);
RotationNR rotTest = new RotationNR(Math.toDegrees(tilt), Math.toDegrees(azumus),
Math.toDegrees(elevation));
System.out.println("\n\nTest #" + i);
System.out.println("Testing Az=" + Math.toDegrees(azumus) + " El=" + Math.toDegrees(elevation) + " Tl="
+ Math.toDegrees(tilt));
System.out.println("Got Az=" + Math.toDegrees(rotTest.getRotationAzimuth()) + " El="
System.out.println("Got Az=" + Math.toDegrees(rotTest.getRotationAzimuth()) + " El="
+ Math.toDegrees(rotTest.getRotationElevation()) + " Tl="
+ Math.toDegrees(rotTest.getRotationTilt()));
if (!RotationNR.bound(tilt - .001, tilt + .001, rotTest.getRotationTilt())) {
Expand All @@ -45,10 +47,14 @@ public void test() {
System.err.println("Rotation Tilt is not consistant. expected " + Math.toDegrees(azumus) + " got "
+ Math.toDegrees(rotTest.getRotationAzimuth()));
}
ThreadUtil.wait(20);



}

if (failCount > 1) {
fail("Rotation failed " + failCount + " times");
fail("Rotation failed " + failCount + " times of "+iterations*3);

}

Expand Down

0 comments on commit caa127f

Please sign in to comment.