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

Invert appears to return improper results when using a double Array #41

Closed
NWalker4483 opened this issue Dec 25, 2021 · 1 comment
Closed

Comments

@NWalker4483
Copy link

NWalker4483 commented Dec 25, 2021

I'm using a teensy 4.1 and the following code.

Matrix<6, 6, Array<6, 6, double>> motor_reductions = {
  1. / 48., 0, 0,         0, 0, 0,
  0, 1. / 48., 0,         0, 0, 0,
  0, -1. / 48., 1. / 48., 0, 0, 0,
  0, 0, 0,                 1. / 24., 0, 0,
  0, 0, 0,                -1. / 28.8, 1. / 28.8, 0,
  0, 0, 0,                -1. / 12., 1. / 24., 1. / 24.
};

Matrix<6, 6,Array<6,6,double>> degrees_per_step;
Matrix<6, 6,Array<6,6,double>> degrees_per_step_inv;

void setup(){
degrees_per_step = motor_reductions * ((360. / (double)SPR);
Invert(degrees_per_step, degrees_per_step_inv);
}
// degrees_per_step_inv(0,0) == 26.6666660308837891;
// When it should equal
// degrees_per_step_inv(0,0) == 26.666666666666668L;
@NWalker4483 NWalker4483 changed the title Invert returns improper results when using a double Array Invert appears to return improper results when using a double Array Dec 25, 2021
@tomstewart89
Copy link
Owner

tomstewart89 commented Dec 26, 2021

Hey @NWalker4483,

Thanks for the info, you're right there was a bug in the way I was declaring some intermediate variables in the invert functions. I just released an update (containing this commit) which should fix the problem. If you update to version 3.3 then the element in that inverse should equal 80 / 3 up to double precision (at least on arduinos that support 64-bit floats anyway).

I'll close this issue but if you have any more trouble feel free to re-open it!

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

No branches or pull requests

2 participants