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

Wrapped feedback always returns positive output when the shortest path is wrapped #11

Open
logos-electromechanical opened this issue Sep 28, 2024 · 0 comments

Comments

@logos-electromechanical

In the case where the wrapped feedback is set to true, the code should output the command that provides the shortest distance between the two points, even if it crosses the wrap point. The library currently returns the absolute value of the command. The error, at least in the CPP version, is on lines 185 and 189 of PID.cpp. It currently is:

else if(altErr1Abs < regErrAbs && altErr1Abs < altErr2Abs) //If altErr1Abs is smallest
{
  error = altErr1Abs;
}
else if(altErr2Abs < regErrAbs && altErr2Abs < altErr1Abs) //If altErr2Abs is smallest
{
  error = altErr2Abs;
}

It should be:

else if(altErr1Abs < regErrAbs && altErr1Abs < altErr2Abs) //If altErr1Abs is smallest
{
  error = altErr1;
}
else if(altErr2Abs < regErrAbs && altErr2Abs < altErr1Abs) //If altErr2Abs is smallest
{
  error = altErr2;
}

The error is also present in the C version, with nearly identical code on lines 156-161. I'll put together an updated version and make a pull request with the fix in the next couple of days.

logos-electromechanical pushed a commit to ProjectLadon/PID that referenced this issue Sep 28, 2024
…so that it provides the correct sign for the error for path nicholastmosher#3
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

1 participant