mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-10-06 09:02:52 +08:00
fix(navigator): only update mission cache when mission properly copied
This commit is contained in:
@@ -250,6 +250,7 @@ void Navigator::run()
|
||||
|
||||
uint32_t geofence_id{0};
|
||||
mission_s mission{};
|
||||
bool mission_received{false};
|
||||
|
||||
/* rate-limit position subscription to 20 Hz / 50 ms */
|
||||
orb_set_interval(_local_pos_sub, 50);
|
||||
@@ -275,16 +276,23 @@ void Navigator::run()
|
||||
orb_copy(ORB_ID(vehicle_status), _vehicle_status_sub, &_vstatus);
|
||||
|
||||
if (fds[2].revents & POLLIN) {
|
||||
orb_copy(ORB_ID(mission), _mission_sub, &mission);
|
||||
mission_s mission_update{};
|
||||
|
||||
if (mission.geofence_id != geofence_id) {
|
||||
geofence_id = mission.geofence_id;
|
||||
_geofence.updateFence();
|
||||
if (orb_copy(ORB_ID(mission), _mission_sub, &mission_update) == PX4_OK) {
|
||||
mission = mission_update;
|
||||
mission_received = true;
|
||||
|
||||
if (mission.geofence_id != geofence_id) {
|
||||
geofence_id = mission.geofence_id;
|
||||
_geofence.updateFence();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_mission_route_cache.update(mission);
|
||||
if (mission_received) {
|
||||
_mission_route_cache.update(mission);
|
||||
}
|
||||
|
||||
/* gps updated */
|
||||
if (_gps_pos_sub.updated()) {
|
||||
|
||||
Reference in New Issue
Block a user