UTM_GLOBAL_POSITION: prevent uint16 overflow

Signed-off-by: RomanBapst <bapstroman@gmail.com>
This commit is contained in:
RomanBapst 2023-09-21 14:06:41 +03:00 committed by Daniel Agar
parent be56f74c1d
commit 4f1682c3c8
1 changed files with 2 additions and 2 deletions

View File

@ -101,8 +101,8 @@ private:
msg.lon = global_pos.lon * 1e7;
msg.alt = global_pos.alt_ellipsoid * 1000.f;
msg.h_acc = global_pos.eph * 1000.f;
msg.v_acc = global_pos.epv * 1000.f;
msg.h_acc = math::min(global_pos.eph * 1000.0f, (float)UINT16_MAX);
msg.v_acc = math::min(global_pos.epv * 1000.0f, (float)UINT16_MAX);
msg.flags |= UTM_DATA_AVAIL_FLAGS_POSITION_AVAILABLE;
msg.flags |= UTM_DATA_AVAIL_FLAGS_ALTITUDE_AVAILABLE;