Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions spatialmath/orientation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,13 @@ func testCompatibility(t *testing.T, o Orientation) {
}
}
}

func TestOrientationVectorPoleRadius(t *testing.T) {
ov := &OrientationVector{Theta: 90.2029644505, OX: 0.0050164674, OY: 0.0079070413, OZ: 0.9999561559}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to use OrientationVectorDegrees here. The test still fails, but much more reasonably:

=== RUN   TestOrientationVectorPoleRadius
    orientation_test.go:161: Expected '90.20295555178383' to almost equal '90.2029644505' (but it didn't)!

I am confused though why if I instead change everything to radians, the test failure gets worse. Code:

	ov := &OrientationVector{Theta: 1.5743387247206226, OX: 0.0050164674, OY: 0.0079070413, OZ: 0.9999561559}
	q := Quaternion(ov.Quaternion())
	composedOv := q.OrientationVectorRadians()
	test.That(t, composedOv.Theta, test.ShouldAlmostEqual, ov.Theta, 0.000001)

Gives:

=== RUN   TestOrientationVectorPoleRadius
    orientation_test.go:162: Expected '0.009364093511798814' to almost equal '0.00501646740007625' (but it didn't)!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I assume theta is the only thing in degrees/radians, but I don't really know any of this stuff)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this test was meant to fail. I was meant to use OrientationVectorDegrees, but this orientation_test.go:162: Expected '0.009364093511798814' to almost equal '0.00501646740007625' (but it didn't)! is what im experiencing and real life and wanted to create a test to capture the failure. I'm working with @nicksanford on this

q := Quaternion(ov.Quaternion())
composedOv := q.OrientationVectorDegrees()
test.That(t, composedOv.Theta, test.ShouldAlmostEqual, ov.Theta, 0.000001)
test.That(t, composedOv.OX, test.ShouldAlmostEqual, ov.OX, 0.000001)
test.That(t, composedOv.OY, test.ShouldAlmostEqual, ov.OY, 0.000001)
test.That(t, composedOv.OZ, test.ShouldAlmostEqual, ov.OZ, 0.000001)
}
Loading