-
Notifications
You must be signed in to change notification settings - Fork 18.6k
add sanity check for command-int conversion #28866
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
base: master
Are you sure you want to change the base?
add sanity check for command-int conversion #28866
Conversation
e850849
to
46bd498
Compare
libraries/GCS_MAVLink/GCS_Common.cpp
Outdated
out.x = convert_COMMAND_LONG_loc_param(in.param5, stores_location); | ||
out.y = convert_COMMAND_LONG_loc_param(in.param6, stores_location); | ||
|
||
// we can't convert NaN/INF to an integer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are supposed to deal with NaNs, it might be fine if the command is not using those params. We could convert from NaN which is no value for float Int32 max which is no value for int32 according to the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof. Hmmm. Will think about this more in the morning.
Problem is that if we just squash them to zero them we may end up triggering the sanitise-using-a-default-location code....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec calls for INT32 max for invalid. (https://mavlink.io/en/messages/common.html#COMMAND_INT), so NaN should be converted to that. Then your new range check will bounce if it is a location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, squashed to INT32_MAX as you suggest - seems the best way forward here.
Note that this will be a behavioural change - previously we would have treated these as 0.
46bd498
to
7abba85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to see if the change of behaviour is safe
out.x = param5 * 1e7; | ||
out.y = param6 * 1e7; | ||
} else { | ||
out.x = param5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to see if there may be any commands that relied on the previous zero, and now will get INT32_MAX, motor test is a possible issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good now. We do generally need to be better handling incoming commands with invalid values.
7abba85
to
11f6f2b
Compare
Co-authored-by: Noah Markert <[email protected]>
... avoid race condition in modern ways
11f6f2b
to
649265e
Compare
Replaces #28790
This provides a useful return value to the GCS that they've passed in invalid lat/lng in their command-long positions. Which they shouldn't be using anyway.