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

setDegreeForAllServos parses parameters (degrees) as int, not float #85

Closed
2 tasks
navdotnetreqs opened this issue Mar 5, 2023 · 2 comments
Closed
2 tasks
Labels
bug Something isn't working

Comments

@navdotnetreqs
Copy link

navdotnetreqs commented Mar 5, 2023

Hi and thanks for the library!

Something weird happens wen I try to use setDegreesForAllServos and this causes my servos to fly all over the place.
If I assign the ServoEasingNextPositionArray-elements one at a time directly, everything works as expected.
ServoEasing::ServoEasingNextPositionArray[i] = abs(theta[i + 1])
etc.

But if I assign them using setDegreeForAllServos, and then query the values, I get unexpected results.

Serial.printf("DE %f %f %f %f %f %f\n", abs(theta[1]), abs(180 - theta[2]), abs(theta[3]), abs(theta[4] + 90), abs(theta[5] + 90), abs(theta[6]));
setDegreeForAllServos(6, abs(theta[1]), abs(180 - theta[2]), abs(theta[3]), abs(theta[4] + 90), abs(theta[5] + 90), abs(theta[6]));
Serial.printf("SE %f %f %f %f %f %f\n", ServoEasing::ServoEasingNextPositionArray[0], ServoEasing::ServoEasingNextPositionArray[1].. )

Output:
DE 92.000000 115.000000 3.000000 90.000000 10.000000 16.000000
SE 1074266112.000000 0.000000 1079443456.000000 0.000000 1079820288.000000 0.000000

For even more interesting results:

std::array<float, THETAS> theta = {0, 92, 115, 3, 90,10, 16}; // [0] not in use
Serial.printf("DE %f %f %f %f %f %f\n", abs(theta[1]), abs(180 - theta[2]), abs(theta[3]), abs(theta[4] + 90), abs(theta[5] + 90), abs(theta[6]));
setDegreeForAllServos(6, abs(theta[1]), 180, (float)abs(theta[3]), theta[4], 90.0f, abs(theta[6]));
ServoEasing::ServoEasingNextPositionArray[0] = abs(theta[1]);
Serial.printf("SE %f %f %f %f %f %f\n", ServoEasing::ServoEasingNextPositionArray[0], ServoEasing::ServoEasingNextPositionArray[1], ServoEasing::ServoEasingNextPositionArray[2], ServoEasing::ServoEasingNextPositionArray[3], ServoEasing::ServoEasingNextPositionArray[4], ServoEasing::ServoEasingNextPositionArray[5]);

Output:

DE 92.000000 115.000000 3.000000 90.000000 10.000000 16.000000
SE 92.000000 0.000000 1079443456.000000 180.000000 1073421888.000000 0.000000

setDegreeForAllServos(6, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);

Does not work either. So an issue with va_arg.. ?

Board

  • ESP32 board

IDE

  • PlatformIO IDE
@navdotnetreqs
Copy link
Author

@ArminJo ArminJo added the bug Something isn't working label Mar 5, 2023
@ArminJo
Copy link
Owner

ArminJo commented Mar 5, 2023

Thanks for reporting. I fixed it in the new 3.2.1 release by adding function setFloatDegreeForAllServos().

@ArminJo ArminJo closed this as completed Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants