Fix NaN poses from orientation JSON that omits its zero fields - #941
Open
East Agile Tracker (eastagiletracker) wants to merge 1 commit into
Conversation
Go's unmarshal reads an absent scalar as zero, so RDK accepts a frame orientation that leaves its zero-valued fields out. The euler_angles and axis_angles branches passed those absent fields straight through: the first produced a NaN quaternion, taking the frame's pose and matrix with it, and the second failed its axis-length check and fell back to identity while warning about a zero axis. Default them to zero, as the quaternion branch already does, and cover every encoding with a partial value.
🦋 Changeset detectedLatest commit: a5d9ff0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes reading a
spatialmathorientation that omits its zero-valued fields the way RDK does, instead of decoding it to a NaN pose. We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/321. You can sign in with your GitHub ID to claim ownership of the project.What this fixes
Go's unmarshal reads an absent scalar as zero, so
{"type": "euler_angles", "value": {"yaw": 1.5707963267948966}}is a valid frame orientation to RDK — a hand-written machine config leaves the zero fields out.quatFromJsonpasses those absent fields straight into three.js:Euler.set(undefined, undefined, yaw)gives a NaN quaternion, soPose.setFromFramereturns a pose whose orientation and theta are all NaN, andtoMatrix4returns an all-NaN rotation block — the frame and everything parented to it can no longer be placed in the scene.axis_anglestakes the same input to a NaNlengthSq, fails its> 0axis check, and silently falls back to identity while warning about a zero axis it does not have. Thequaternionbranch already defaults omitted fields to Go's zero, and the two orientation-vector branches get it for free fromOrientationVector.set, so this was the last pair of encodings not following the rule your own spatial-math notes state: "protobuf materialises absent scalars as0and RDK'sNormalizedoes the same substitution".Reproduced on
mainat a934603:The change is four lines in
orientationJson.ts: default theeuler_anglesandaxis_anglescomponents to0, and typeEulerJson/OvJsonas partial records the wayQuatJsonalready is, so the wire shape is what the types say it is. Values that carry every field decode exactly as before.The tests cover all five encodings twice — the same 90° turn about +X spelled with its zero fields omitted, through
poseFromJsonand throughPose.setFromFrame(which also asserts a finite matrix) — plus an emptyvaluefor each encoding that resolves to identity. Reverting onlyorientationJson.tstakes 5 of them red (Tests 5 failed | 117 passed) while theov_degrees,ov_radiansandquaternioncases stay green, which is the split the diff predicts. On the full suitepnpm testgoes from 682 passing on a934603 to 696 passing here with no new failures, andpnpm check,pnpm lint:prettierandpnpm lint:eslintare clean. Heads up that #912 also editsspatialJson.ts, but ingeometryCenterInFramerather than the decoder, so the two should not collide.How this was managed
We imported this repository's issues and pull requests into a live agile board — 915 stories and 6 labels — and worked this fix on it as Partial spatialmath orientation JSON decodes to a NaN pose, on the board at https://eastagiletracker.com/projects/321.
If you'd rather not receive contributions like this, reply
no-more-prson this pull request and we won't open any further ones on your repositories.Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com