From 492e40a1394e4f1bb1d2228a0e83aab7fcf98b23 Mon Sep 17 00:00:00 2001 From: Martina Date: Tue, 12 Jun 2018 13:35:43 +0200 Subject: [PATCH] mc_pos_control: enable obstacle avoidance only in mission and rtl --- src/modules/mc_pos_control/mc_pos_control_main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index 47c9bb8c70..97d7c43e7b 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -3495,9 +3495,11 @@ MulticopterPositionControl::use_obstacle_avoidance() { /* check that external obstacle avoidance is sending data and that the first point is valid */ - return (_test_obstacle_avoidance.get() && (hrt_elapsed_time((hrt_abstime *)&_traj_wp_avoidance.timestamp) < - TRAJECTORY_STREAM_TIMEOUT_US) - && (_traj_wp_avoidance.waypoints[vehicle_trajectory_waypoint_s::POINT_0].point_valid == true)); + return (_test_obstacle_avoidance.get() + && (hrt_elapsed_time((hrt_abstime *)&_traj_wp_avoidance.timestamp) < TRAJECTORY_STREAM_TIMEOUT_US) + && (_traj_wp_avoidance.waypoints[vehicle_trajectory_waypoint_s::POINT_0].point_valid == true) + && ((_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION) || + (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_RTL))); } bool