From 96837acdbee7aa93baabe506211355802a6a5ca1 Mon Sep 17 00:00:00 2001 From: Tomas Baca Date: Thu, 5 Oct 2023 15:39:36 +0200 Subject: [PATCH] optimized queries for min_z --- src/mpc_tracker/mpc_tracker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mpc_tracker/mpc_tracker.cpp b/src/mpc_tracker/mpc_tracker.cpp index 3297c2e..76a846b 100644 --- a/src/mpc_tracker/mpc_tracker.cpp +++ b/src/mpc_tracker/mpc_tracker.cpp @@ -1814,9 +1814,11 @@ double MpcTracker::checkTrajectoryForCollisions(int& first_collision_index) { // we are not avoiding any collisions, so we slowly reduce the collision avoidance offset to return to normal flight collision_free_altitude_ -= 2.0 / (1.0 / dt1); - if (collision_free_altitude_ < common_handlers_->safety_area.getMinZ()) { + double safety_area_min_z = common_handlers_->safety_area.getMinZ(); - collision_free_altitude_ = common_handlers_->safety_area.getMinZ(); + if (collision_free_altitude_ < safety_area_min_z) { + + collision_free_altitude_ = safety_area_min_z; } }