mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-19 19:59:07 +08:00
mavlink_mission: round lat/lon
This avoids casting errors. An alternative to `std::round` would be to add 0.5 before casting for positive values and subtract 0.5 before casting for negative values.
This commit is contained in:
parent
d4c87132e4
commit
e1472818dc
@ -1560,8 +1560,8 @@ MavlinkMissionManager::format_mavlink_mission_item(const struct mission_item_s *
|
||||
mavlink_mission_item_int_t *item_int =
|
||||
reinterpret_cast<mavlink_mission_item_int_t *>(mavlink_mission_item);
|
||||
|
||||
item_int->x = (int32_t)(mission_item->lat * 1e7);
|
||||
item_int->y = (int32_t)(mission_item->lon * 1e7);
|
||||
item_int->x = std::round(mission_item->lat * 1e7);
|
||||
item_int->y = std::round(mission_item->lon * 1e7);
|
||||
|
||||
} else {
|
||||
mavlink_mission_item->x = (float)mission_item->lat;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user