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

Division by zero problem #22

Open
yakunsjtu opened this issue Apr 20, 2024 · 4 comments
Open

Division by zero problem #22

yakunsjtu opened this issue Apr 20, 2024 · 4 comments

Comments

@yakunsjtu
Copy link

yakunsjtu commented Apr 20, 2024

I tried the code on TwinCAT3 and found the PLC will run into fault because the denominator is zero (3 places as shown in the following figure). I am wondering how to fix it?

image

image

image

Also the sqrt of a negative number will occasionally happen:
image

@stefanbesler
Copy link
Owner

stefanbesler commented Apr 20, 2024

Thanks for finding those, one big part of porting from C++ to ST involves to handle those exceptions as C++ doesn’t throw on those and the calculation is thrown away later if this happens. Could you post the trajectories you are trying to compute please (start,end,limits,…), then I can add unittests for them.

The fix is to check if those arguments are 0 and skip the calculation if they are. Struckig is always calculation all potential solutions and the using the fastest one.
Since you seem to use the main branch of Struckig and not a release, you could fix them simply by adding checks like IF ABS(C) < Constants.DoubleEpsilon and skipping to calculating the next possible solution. I’d appreciate if your do a PR after fixing them, but if not I can do it in the coming days.

@stefanbesler
Copy link
Owner

Seeing the in the last commit the unittests failed, this could also be a regression, you could try with an actual release by downloading it from

https://github.com/stefanbesler/struckig/releases

or checking out the tag of the release (git checkout v0.9.3)

but anyway, this needs a fix :-)

stefanbesler added a commit that referenced this issue Apr 20, 2024
@stefanbesler
Copy link
Owner

Issue should be fixed with the latest commit b9ca5aa

Unittests don't cover this path at the moment, would be great if you could send me the trajectories where you got these exceptions.

@yakunsjtu
Copy link
Author

@stefanbesler Thanks for your fix. I did not record the original input. Will verify this fix after your merge.

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