Skip to content

Commit

Permalink
HomePosition: Add an instance counter
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradRudin authored and bkueng committed Nov 24, 2023
1 parent 3ac7ed6 commit 5e1f0b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions msg/HomePosition.msg
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/modules/commander/HomePosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand All @@ -211,6 +213,7 @@ void HomePosition::setInAirHomePosition()

setHomePosValid();
home.timestamp = hrt_absolute_time();
home.update_count++;
_home_position_pub.update();
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5e1f0b7

Please sign in to comment.