Skip to content

Commit 8bbf216

Browse files
committed
Close #29
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.
1 parent 487f90c commit 8bbf216

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

src/main/java/com/neuronrobotics/sdk/addons/kinematics/math/RotationNR.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public RotationNR(double tilt, double azumeth, double elevation) {
4545
throw new RuntimeException("Value can not be NaN");
4646
if (Double.isNaN(elevation))
4747
throw new RuntimeException("Value can not be NaN");
48+
if(elevation >90 || elevation <-90){
49+
throw new RuntimeException("Elevation can not be greater than 90 nor less than -90");
50+
}
4851
loadFromAngles(tilt, azumeth, elevation);
4952
if (Double.isNaN(getRotationMatrix2QuaturnionW()) || Double.isNaN(getRotationMatrix2QuaturnionX())
5053
|| Double.isNaN(getRotationMatrix2QuaturnionY()) || Double.isNaN(getRotationMatrix2QuaturnionZ())) {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package junit.test.neuronrobotics.utilities;
2+
3+
import static org.junit.Assert.*;
4+
5+
import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
6+
import org.apache.commons.math3.geometry.euclidean.threed.RotationConvention;
7+
import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;
8+
import org.junit.Test;
9+
10+
import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR;
11+
12+
public class ApacheCommonsRotationTest {
13+
14+
@Test
15+
public void test() {
16+
int failCount = 0;
17+
int iterations = 10;
18+
RotationOrder[] list = { RotationOrder.XYZ
19+
20+
};
21+
RotationConvention[] conventions = { RotationConvention.FRAME_TRANSFORM, RotationConvention.VECTOR_OPERATOR };
22+
for (RotationConvention convention : conventions) {
23+
System.out.println("\n\nUsing convention " + convention.toString());
24+
for (RotationOrder order : list) {
25+
System.out.println("\n\nUsing rotationOrder " + order.toString());
26+
27+
double tilt = Math.toRadians((Math.random() * 359) - 179.5);
28+
double elevation = Math.toRadians((Math.random() * 180) -90);
29+
double azumus = Math.toRadians((Math.random() * 359) - 179.5);
30+
31+
Rotation tester = new Rotation(order, convention, azumus, elevation, tilt);
32+
33+
double [] vals = tester.getAngles(order, convention);
34+
35+
double tiltNew = vals[2];
36+
double elevationNew = vals[1];
37+
double azumusNew = vals[0];
38+
39+
assertEquals(tilt, tiltNew, 0.001);
40+
assertEquals(elevation, elevationNew, 0.001);
41+
assertEquals(azumus, azumusNew, 0.001);
42+
43+
44+
}
45+
}
46+
}
47+
48+
}

test/java/src/junit/test/neuronrobotics/utilities/RotationNRTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ public class RotationNRTest {
2222
public void test() {
2323
int failCount = 0;
2424
int iterations = 10;
25-
RotationOrder[] list = { RotationOrder.XYZ,
26-
RotationOrder.XZY, RotationOrder.YXZ, RotationOrder.YZX,
27-
RotationOrder.ZXY, RotationOrder.ZYX, RotationOrder.XYX, RotationOrder.XZX, RotationOrder.YXY,
28-
RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ
25+
RotationOrder[] list = { RotationOrder.XYZ
2926

3027
};
3128
RotationConvention[] conventions = { RotationConvention.FRAME_TRANSFORM, RotationConvention.VECTOR_OPERATOR };
@@ -38,7 +35,7 @@ public void test() {
3835
failCount = 0;
3936
for (int i = 0; i < iterations; i++) {
4037
double tilt = Math.toRadians((Math.random() * 359) - 179.5);
41-
double elevation = Math.toRadians((Math.random() * 359) - 179.5);
38+
double elevation = Math.toRadians((Math.random() * 180) - 90);
4239
double azumus = Math.toRadians((Math.random() * 359) - 179.5);
4340
RotationNR rotTest = new RotationNR(Math.toDegrees(tilt), Math.toDegrees(azumus),
4441
Math.toDegrees(elevation));

0 commit comments

Comments
 (0)