loiter: only accept reposition setpoint if commanded within last 0.5 sec

guards against left over reposition commands (potentially set via geofence) from previous flights
This commit is contained in:
Thomas Stastny 2023-09-13 19:14:50 +02:00 committed by Daniel Agar
parent e5f4a6b074
commit 2d80291b43
1 changed files with 4 additions and 2 deletions

View File

@ -51,7 +51,8 @@ Loiter::Loiter(Navigator *navigator) :
void
Loiter::on_activation()
{
if (_navigator->get_reposition_triplet()->current.valid) {
if (_navigator->get_reposition_triplet()->current.valid
&& hrt_elapsed_time(&_navigator->get_reposition_triplet()->current.timestamp) < 500_ms) {
reposition();
} else {
@ -66,7 +67,8 @@ Loiter::on_activation()
void
Loiter::on_active()
{
if (_navigator->get_reposition_triplet()->current.valid) {
if (_navigator->get_reposition_triplet()->current.valid
&& hrt_elapsed_time(&_navigator->get_reposition_triplet()->current.timestamp) < 500_ms) {
reposition();
}
}