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

✨ Arbitrary pose derivatives & bugfixes #12

Merged
merged 9 commits into from
Jul 5, 2024
Merged

Conversation

Aang099
Copy link
Member

@Aang099 Aang099 commented Jun 28, 2024

Refactors Pose to be an abstract class allowing for arbitrary time derivatives. In doing so, also makes the template header only again. Additionally, fix issues with + or - operators between a named quantity type (IE the Length class) and the equivalent Quantity failing, while at the same time improving error messages when using mismatched types in either of those operations.

@Aang099 Aang099 requested review from SizzinSeal and sufferiing June 28, 2024 21:31
@Aang099 Aang099 self-assigned this Jun 28, 2024
@Aang099 Aang099 added the enhancement New feature or request label Jun 28, 2024
@sufferiing
Copy link
Member

sufferiing commented Jun 29, 2024

Everything looks good code wise.

I'm not totally sure that static_asserts are the right way to handle binary operators not working with the nominal types though. It would require all the asserts to be in every operator defined outside of Quantity (not just + and -), and I'm a bit worried it might screw up overloading since static asserts do not prevent a template from being selected during overload resolution.

Pose derivatives look all good.

Copy link
Member

@SizzinSeal SizzinSeal left a comment

Choose a reason for hiding this comment

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

LGTM

@sufferiing
Copy link
Member

OK so some bad news and some good news:

The bad news: This problem applies to more than just operators. It actually applied to any function which takes >1 quantity values of the same type (eg.min, max, ceil, floor, round, mod)

The good news: The issue lies in the fact that the a single type parameter is used for the function parameters. Template instantiation requires types to be strictly equal, not just convertible, and so no implicit conversion can happen.

This is pretty easy to solve: We take a different quantity type for each parameter. This fixes the issue, but allows these functions to be instantiated with all different quantity types. This still errors, but not as nicely, as the template must be instantiated first. I think the best course of action here is to create some kind of type convertible trait/concept to restrict the parameters.
This would allow the operators to work between isomorphic quantity types instead of erroring out

template<typename Q, typename... Quantities>
concept Isomorphic = ((std::convertible_to<Q, Quantities> && std::convertible_to<Quantities, Q>) && ...);

Copy link
Member

@sufferiing sufferiing left a comment

Choose a reason for hiding this comment

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

Looks all good to me!

@Aang099 Aang099 merged commit d6e93f7 into main Jul 5, 2024
4 checks passed
@Aang099 Aang099 deleted the pose-derivatives branch July 5, 2024 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants