Closed Bennett-Petzold closed 10 months ago
Now fixed on main. Will be in next 1.1.0 release.
When sending nan, inf, or other out of range values, the command is not rejected. The control board forces values into the valid range for arguments. In the case of nan or inf, they will be treated as zeros. This is consistent with the behavior described in the docs.
While it may be useful in this specific case to have out of range values be rejected with an "INVALID_ARG" error, this error is primarily intended to mean "incorrect number of arguments". Furthermore, rejecting out of range value with INVALID_ARG could cause other problems. For example, if the code sending speeds to the control board calculates 1.05 instead of 1.00 due to floating point errors, it would be undesirable for control board to reject the command. As such, out of range values are (by design) forced into range by the control board.
It is recommended to have value checks (for nan, inf, values with magnitudes much larger than 1, etc) in code using the control board (the code issuing commands). This can allow warnings to be logged if invalid values are generated before sending to the control board.
Once sent to the control board, it will force values into range to make it possible to execute the command.
Describe the bug Sending NaN as a motor speed causes a reset with code -6.
Tested Versions v1 and v2
Impacted Versions v1 and v2
To Reproduce Send a stability_assist_2 command with a NaN as the x value.
Expected behavior Some non-crash behavior, likely a rejection of the message.
Additional context The code crashes because it gets stuck in a loop.