From 4f42facefc06a2ac79157c62eb009c050b0cb6e2 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 29 Aug 2017 16:37:43 -0700 Subject: [PATCH] global: use static method to construct AC_Avoid --- ArduCopter/Copter.cpp | 3 --- ArduCopter/Copter.h | 2 +- ArduSub/Sub.cpp | 3 --- ArduSub/Sub.h | 8 ++++---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/ArduCopter/Copter.cpp b/ArduCopter/Copter.cpp index 73fa627a5b..fe74c38820 100644 --- a/ArduCopter/Copter.cpp +++ b/ArduCopter/Copter.cpp @@ -66,9 +66,6 @@ Copter::Copter(void) mainLoop_count(0), rtl_loiter_start_time(0), auto_trim_counter(0), -#if AC_AVOID_ENABLED == ENABLED - avoid(ahrs, inertial_nav, fence, g2.proximity, &g2.beacon), -#endif #if SPRAYER == ENABLED sprayer(&inertial_nav), #endif diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index ffe531ecd4..9d4cc4d8c1 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -558,7 +558,7 @@ private: #endif #if AC_AVOID_ENABLED == ENABLED - AC_Avoid avoid; + AC_Avoid avoid = AC_Avoid::create(ahrs, inertial_nav, fence, g2.proximity, &g2.beacon); #endif // Rally library diff --git a/ArduSub/Sub.cpp b/ArduSub/Sub.cpp index 224c3d625a..340fdf987d 100644 --- a/ArduSub/Sub.cpp +++ b/ArduSub/Sub.cpp @@ -51,9 +51,6 @@ Sub::Sub(void) pos_control(ahrs_view, inertial_nav, motors, attitude_control, g.p_alt_hold, g.p_vel_z, g.pid_accel_z, g.p_pos_xy, g.pi_vel_xy), -#if AVOIDANCE_ENABLED == ENABLED - avoid(ahrs, inertial_nav, fence, g2.proximity), -#endif wp_nav(inertial_nav, ahrs_view, pos_control, attitude_control), circle_nav(inertial_nav, ahrs_view, pos_control), pmTest1(0), diff --git a/ArduSub/Sub.h b/ArduSub/Sub.h index c6b160e46e..d0f3085043 100644 --- a/ArduSub/Sub.h +++ b/ArduSub/Sub.h @@ -390,10 +390,6 @@ private: AC_PosControl_Sub pos_control; -#if AVOIDANCE_ENABLED == ENABLED - AC_Avoid avoid; -#endif - AC_WPNav wp_nav; AC_Circle circle_nav; @@ -429,6 +425,10 @@ private: AC_Fence fence = AC_Fence::create(ahrs, inertial_nav); #endif +#if AVOIDANCE_ENABLED == ENABLED + AC_Avoid avoid = AC_Avoid::create(ahrs, inertial_nav, fence, g2.proximity, &g2.beacon); +#endif + // Rally library #if AC_RALLY == ENABLED AP_Rally rally = AP_Rally::create(ahrs);