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

Use a simplified formulation of the relative task #82

Merged
merged 15 commits into from
Apr 2, 2024

Conversation

ymontmarin
Copy link
Collaborator

@ymontmarin ymontmarin commented Mar 29, 2024

This PR use a simpler formulation of the relative task, discarding some matrix multiplication in the Jacobian computation.
It follows the discussion in: #80

It also changes the cost setting, to match the typing signature of the function and add the calculus of the jacobian in the description.

pink/tasks/relative_frame_task.py Show resolved Hide resolved
pink/tasks/relative_frame_task.py Outdated Show resolved Hide resolved
pink/tasks/relative_frame_task.py Outdated Show resolved Hide resolved
pink/tasks/relative_frame_task.py Outdated Show resolved Hide resolved
@stephane-caron
Copy link
Owner

Thank you for this contribution 😃

We can expect the following test to fail: test_relative_jacobian (in tests/test_relative_frame_task.py) since you changed the sign of the Jacobian: you can simply put a minus in front of J_check, that should do it.

@coveralls
Copy link

coveralls commented Mar 29, 2024

Pull Request Test Coverage Report for Build 8483559586

Details

  • 9 of 21 (42.86%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.6%) to 98.84%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pink/tasks/relative_frame_task.py 9 21 42.86%
Totals Coverage Status
Change from base Build 8481800866: -0.6%
Covered Lines: 1278
Relevant Lines: 1293

💛 - Coveralls

@ymontmarin
Copy link
Collaborator Author

@stephane-caron I don't get the last formatting error concerning type annotation. Could you help ?

@stephane-caron
Copy link
Owner

stephane-caron commented Mar 29, 2024

@stephane-caron I don't get the last formatting error concerning type annotation. Could you help ?

The previous workaround for this was:

        if isinstance(self.cost, np.ndarray):  # helps mypy
            self.cost[0:3] = position_cost

MyPy is stating that the type if inferred for self.cost is float | Sequence[float] | ndarray[Any, Any] | None, which is correct since that's what we told it in the base class Task. (With such a general type we cannot evaluate self.cost[0:3], say if e.g. the runtime type is float or None.)

Looking at it again we can do better by adding a more precise type annotation in the class itself:

class RelativeFrameTask(Task):
    cost: np.ndarray
    frame: str
    ...

I checked locally and it fixes the MyPy error, so I suggest we go for that one ☝️

stephane-caron
stephane-caron previously approved these changes Mar 29, 2024
Copy link
Owner

@stephane-caron stephane-caron left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Feel free to merge.

CHANGELOG.md Outdated Show resolved Hide resolved
tests/test_relative_frame_task.py Outdated Show resolved Hide resolved
@ymontmarin
Copy link
Collaborator Author

@stephane-caron You can merge if you think its ready !

@stephane-caron stephane-caron merged commit 1bcfd48 into stephane-caron:main Apr 2, 2024
12 checks passed
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