henriksod/Fabrik2DArduino

Board hangs when running example_3DOFToolAngle

xchg-dot-ca opened this issue · 8 comments

Weird issue, but Adafruit Trinked M0 ( Atmel ATSAMD21 based board )
Hangs when running example_3DOFToolAngle sketch, unmodified!
I cannot wrap my mind why this is happening, but this clearly related to the fact that I has to solve the IK when tool has to be at the certain angle.
Do you have any ideas how can I debug this?
Thank you.

Tested on Adafruit ItsiBitsy nFR52840 - same issue, it hangs pretty much the same way!

Hi, does it hang when it is in the solve function or outside? Try to do some prints to Serial at different locations

Thank you for the reply,
It seems to me as this is stack(memory?) corruption or something to this extend

As it enters the function and calculates the solution:
it return successfully from:
returns from bool solvable = solve(oc_x, oc_y, lengths);
continues to the very end of
bool Fabrik2D::solve2(float x, float y, float z, float toolAngle, float grippingOffset, int* lengths)
and after that never comes back to the main loop! and just hangs

Oh wow, I think I have found a bug !
Funciton:

bool Fabrik2D::solve2(float x, float y, float z, float toolAngle, float grippingOffset, int* lengths)

Missing a return statement, and I guess some implementations are getting confused....
I will post a PR

Wondering if I can set somewhere -Wreturn-type or -Wall in Arduino IDE to prevent such thing from compiling and happening again!

Issue resolved, fix committed

Looks like there's one more missing return, as the latest (v1.0.3) library still crashes on ESP32 and ESP8266 boards.
I fixed it by adding return solvable; to the end of the function
bool Fabrik2D::solve2(float x, float y, float z, float toolAngle, float grippingOffset, int* lengths) in FABRIK2D.cpp

Hi, I guess we need to create a new tag based on master to get the fix into arduino libraries