Skip to content

Commit

Permalink
Close #29
Browse files Browse the repository at this point in the history
Based on the documentation of euler angles, the bounds for holonomic
computation of elevation is from 90 to -90 degrees. this bound needs to
be enforced by the rotation object.
  • Loading branch information
madhephaestus committed Dec 20, 2016
1 parent 487f90c commit 8bbf216
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public RotationNR(double tilt, double azumeth, double elevation) {
throw new RuntimeException("Value can not be NaN");
if (Double.isNaN(elevation))
throw new RuntimeException("Value can not be NaN");
if(elevation >90 || elevation <-90){
throw new RuntimeException("Elevation can not be greater than 90 nor less than -90");
}
loadFromAngles(tilt, azumeth, elevation);
if (Double.isNaN(getRotationMatrix2QuaturnionW()) || Double.isNaN(getRotationMatrix2QuaturnionX())
|| Double.isNaN(getRotationMatrix2QuaturnionY()) || Double.isNaN(getRotationMatrix2QuaturnionZ())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package junit.test.neuronrobotics.utilities;

import static org.junit.Assert.*;

import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention;
import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;
import org.junit.Test;

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

public class ApacheCommonsRotationTest {

@Test
public void test() {
int failCount = 0;
int iterations = 10;
RotationOrder[] list = { RotationOrder.XYZ

};
RotationConvention[] conventions = { RotationConvention.FRAME_TRANSFORM, RotationConvention.VECTOR_OPERATOR };
for (RotationConvention convention : conventions) {
System.out.println("\n\nUsing convention " + convention.toString());
for (RotationOrder order : list) {
System.out.println("\n\nUsing rotationOrder " + order.toString());

double tilt = Math.toRadians((Math.random() * 359) - 179.5);
double elevation = Math.toRadians((Math.random() * 180) -90);
double azumus = Math.toRadians((Math.random() * 359) - 179.5);

Rotation tester = new Rotation(order, convention, azumus, elevation, tilt);

double [] vals = tester.getAngles(order, convention);

double tiltNew = vals[2];
double elevationNew = vals[1];
double azumusNew = vals[0];

assertEquals(tilt, tiltNew, 0.001);
assertEquals(elevation, elevationNew, 0.001);
assertEquals(azumus, azumusNew, 0.001);


}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ public class RotationNRTest {
public void test() {
int failCount = 0;
int iterations = 10;
RotationOrder[] list = { RotationOrder.XYZ,
RotationOrder.XZY, RotationOrder.YXZ, RotationOrder.YZX,
RotationOrder.ZXY, RotationOrder.ZYX, RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
RotationOrder[] list = { RotationOrder.XYZ

};
RotationConvention[] conventions = { RotationConvention.FRAME_TRANSFORM, RotationConvention.VECTOR_OPERATOR };
Expand All @@ -38,7 +35,7 @@ public void test() {
failCount = 0;
for (int i = 0; i < iterations; i++) {
double tilt = Math.toRadians((Math.random() * 359) - 179.5);
double elevation = Math.toRadians((Math.random() * 359) - 179.5);
double elevation = Math.toRadians((Math.random() * 180) - 90);
double azumus = Math.toRadians((Math.random() * 359) - 179.5);
RotationNR rotTest = new RotationNR(Math.toDegrees(tilt), Math.toDegrees(azumus),
Math.toDegrees(elevation));
Expand Down

0 comments on commit 8bbf216

Please sign in to comment.