mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 03:53:34 +08:00
navigator: use mission topic to notify about geofence & safe point changes
This avoids the need to regularly access dataman for checking.
This commit is contained in:
@@ -168,6 +168,9 @@ void Navigator::run()
|
||||
fds[2].fd = _mission_sub;
|
||||
fds[2].events = POLLIN;
|
||||
|
||||
int16_t geofence_update_counter{0};
|
||||
int16_t safe_points_update_counter{0};
|
||||
|
||||
/* rate-limit position subscription to 20 Hz / 50 ms */
|
||||
orb_set_interval(_local_pos_sub, 50);
|
||||
|
||||
@@ -192,9 +195,18 @@ void Navigator::run()
|
||||
orb_copy(ORB_ID(vehicle_status), _vehicle_status_sub, &_vstatus);
|
||||
|
||||
if (fds[2].revents & POLLIN) {
|
||||
// copy mission to clear any update
|
||||
mission_s mission;
|
||||
orb_copy(ORB_ID(mission), _mission_sub, &mission);
|
||||
|
||||
if (mission.geofence_update_counter != geofence_update_counter) {
|
||||
geofence_update_counter = mission.geofence_update_counter;
|
||||
_geofence.updateFence();
|
||||
}
|
||||
|
||||
if (mission.safe_points_update_counter != safe_points_update_counter) {
|
||||
safe_points_update_counter = mission.safe_points_update_counter;
|
||||
_rtl.updateSafePoints();
|
||||
}
|
||||
}
|
||||
|
||||
/* gps updated */
|
||||
|
||||
@@ -122,6 +122,8 @@ public:
|
||||
|
||||
void resetRtlState() { _rtl_state = RTL_STATE_NONE; }
|
||||
|
||||
void updateSafePoints() { _initiate_safe_points_updated = true; }
|
||||
|
||||
private:
|
||||
|
||||
void set_rtl_item();
|
||||
|
||||
Reference in New Issue
Block a user