HomePosition: Add an instance counter

This commit is contained in:
Konrad 2023-11-20 13:54:09 +01:00 committed by Beat Küng
parent 3ac7ed6afa
commit 5e1f0b73ce
2 changed files with 7 additions and 0 deletions

View File

@ -17,3 +17,5 @@ bool valid_hpos # true when the latitude and longitude have been set
bool valid_lpos # true when the local position (xyz) has been set
bool manual_home # true when home position was set manually
uint32 update_count # update counter of the home position

View File

@ -129,6 +129,7 @@ bool HomePosition::setHomePosition(bool force)
if (updated) {
home.timestamp = hrt_absolute_time();
home.manual_home = false;
home.update_count = _home_position_pub.get().update_count + 1U;
updated = _home_position_pub.update(home);
}
@ -193,6 +194,7 @@ void HomePosition::setInAirHomePosition()
setHomePosValid();
home.timestamp = hrt_absolute_time();
home.update_count++;
_home_position_pub.update();
} else if (!_failsafe_flags.local_position_invalid && _gps_position_for_home_valid) {
@ -211,6 +213,7 @@ void HomePosition::setInAirHomePosition()
setHomePosValid();
home.timestamp = hrt_absolute_time();
home.update_count++;
_home_position_pub.update();
}
@ -230,6 +233,7 @@ void HomePosition::setInAirHomePosition()
fillLocalHomePos(home, home_x, home_y, home_z, NAN);
home.timestamp = hrt_absolute_time();
home.update_count++;
_home_position_pub.update();
}
@ -268,6 +272,7 @@ bool HomePosition::setManually(double lat, double lon, float alt, float yaw)
home.yaw = yaw;
home.timestamp = hrt_absolute_time();
home.update_count++;
_home_position_pub.update();
setHomePosValid();
return true;