Repository navigation
fix(robot): the line of sight of vision_collision_damper is oriented correctly for parallel and antiparallel vectors - #845
Merged
Conversation
…t orientation for parallel and antiparallel vectors The orientation was computed from arccos and a cross product, which for parallel or antiparallel vectors is a rotation about a zero axis. That is the identity today, wrongly for antiparallel vectors, and a ValueError once SpatialMath rejects a zero axis. Use SO3.RotatedVector, which is in the released SpatialMath, and test the helper. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
petercorke
enabled auto-merge (squash)
October 19, 2026 04:54
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 2 high |
🟢 Metrics 11 complexity · 0 duplication
Metric Results Complexity 11 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #845 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 146 146
Lines 16836 16838 +2
=====================================
- Misses 16836 16838 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fixes #843.
The line of sight of
Robot.vision_collision_damperwas oriented witharccosof the dot product and the cross product of the two vectors. For a camera directly above or below the target the vectors are parallel or antiparallel, the cross product is zero, and the rotation is about no axis. Today that gives the identity, which is wrong for the antiparallel case (a camera below the target draws the line of sight the wrong way), and once SpatialMath rejects a zero axis (rai-opensource/spatialmath-python#267) it would be aValueError.arccosalso givesnanwhen the dot product is 1.0000000000000002.The orientation is now
SE3(SO3.RotatedVector(a, b)), in a small module-level function,_rotation_between_vectors, so it can be tested.SO3.RotatedVectoris in the released SpatialMath 1.1.18, so no change to the pin.Tests:
tests/test_vision_collision_orientation.py(20 cases: parallel, parallel to rounding, antiparallel, generic and random vectors, a camera above and below a target, and no warnings). Each checks that the rotation is proper and takes the direction ofato that ofb. With the old computation in place, 10 of them fail.Checked against both SpatialMath behaviours, running the function from this branch in two throwaway virtual environments:
ValueErrorfor antiparallel and for parallel-to-rounding vectors, the new code is correct in every caseAlso 500 random pairs, with no failures in either. The test suite here runs against the #267 behaviour, since the SpatialMath checkout in this environment is on that branch. No change to behaviour other than for these degenerate cases.
Written with Claude Code.
🤖 Generated with Claude Code