Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compute_forward_vector_angle function #376

Merged
merged 13 commits into from
Jan 28, 2025
Merged

Conversation

niksirbi
Copy link
Member

@niksirbi niksirbi commented Jan 16, 2025

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

This is a refresh and continuation of #315.

What does this PR do?

This PR introduces three new functions:

  1. kinematics.compute_forward_vector_angle()
    We have moved away from the term "heading angle" in favour of a name more consistent with our existing function naming conventions. This function calls compute_forward_vector() and then computes the angle between the resulting forward vector and a specified reference vector (using the function described below).

  2. utils.vector.compute_signed_angle_2d()
    A purely mathematical implementation of the signed angle between two 2D vectors, following the arctan2 convention. We expect this general-purpose utility to be used in a variety of scenarios going forward.

  3. validators.arrays.validate_reference_vector()
    A helper function that validates the reference vectors passed to compute_forward_vector_angle(). It supports both static and time-varying reference vectors, in multiple array-like formats.

References

#238
#315

How has this PR been tested?

Yes, thanks to @willGraham01. The tests were implemented in #385 which has been merge onto this branch.

Is this a breaking change?

No.

Does this PR require an update to the documentation?

The new functions come with extensive docstrings, and API docs are automatically updated.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@niksirbi niksirbi mentioned this pull request Jan 16, 2025
7 tasks
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.80%. Comparing base (fc30b5a) to head (ac22354).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #376      +/-   ##
==========================================
+ Coverage   99.79%   99.80%   +0.01%     
==========================================
  Files          14       14              
  Lines         969     1044      +75     
==========================================
+ Hits          967     1042      +75     
  Misses          2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

* Breakout vector valiadator with skeleton test

* Write validator tests, fix bug in missing .get method

* Fix dims and coords returned by `compute_forward_vector` (#382)

* Implement the expected fix

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.8.6](astral-sh/ruff-pre-commit@v0.8.1...v0.8.6)
- [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](pre-commit/mirrors-mypy@v1.13.0...v1.14.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Revert "Implement the expected fix"

This reverts commit edbaa9c.

* Update method to explicitly construct and drop spatial z dimensions

* Force nan test to check for preserved coordinates

* Force explicit coordinate preservation checks in input/output test

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Standardise compute_signed_angle_2d function as a purely mathematical impementation

* Patch up compute_forward_vector_angle

* Start on tests but encounter NaN bug that needs rebase fix

* Fix mapping of -pi to pi in signed_angle

* Write antisymmetry test

* Write invariance under transforms test

* Add tests for missing lines

* Apply batch suggestions from code review

Co-authored-by: Niko Sirmpilatze <niko.sirbiladze@gmail.com>

* Fix computer_forward_vector__angle docstring

* Remove unnecessary validation checks

* Use camera view variable name for codebase consistency

* Fix validator docstring backticks

* Move ref vector validator into array validators

* Fix typehints and test broken by removing earlier error check

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Niko Sirmpilatze <niko.sirbiladze@gmail.com>
Copy link

@willGraham01
Copy link
Contributor

@niksirbi pending the CI, and with #385 merged, we should be good to merge this I think? I can't re-request myself as a reviewer to approve it though!

@niksirbi niksirbi requested a review from willGraham01 January 28, 2025 11:07
@niksirbi
Copy link
Member Author

@niksirbi pending the CI, and with #385 merged, we should be good to merge this I think? I can't re-request myself as a reviewer to approve it though!

Thanks! I've just re-requested review from you, so you may approve and merge.

@niksirbi niksirbi marked this pull request as ready for review January 28, 2025 11:15
@niksirbi niksirbi changed the title Add compute_heading_angle function Add compute_forward_vector_angle function Jan 28, 2025
@willGraham01 willGraham01 added this pull request to the merge queue Jan 28, 2025
Merged via the queue into main with commit df4b4b1 Jan 28, 2025
28 checks passed
@willGraham01 willGraham01 deleted the ns-heading-angle branch January 28, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants