diff --git a/libraries/AC_Sprayer/AC_Sprayer.cpp b/libraries/AC_Sprayer/AC_Sprayer.cpp index 7eaa91a09b..75c8076a53 100644 --- a/libraries/AC_Sprayer/AC_Sprayer.cpp +++ b/libraries/AC_Sprayer/AC_Sprayer.cpp @@ -93,6 +93,11 @@ void AC_Sprayer::run(const bool activate) return; } + // exit immediately if the pump function has not been set-up for any servos + if (!SRV_Channels::function_assigned(SRV_Channel::k_sprayer_pump)) { + return; + } + // set flag indicate whether spraying is permitted: // do not allow running to be set to true if we are currently not enabled _flags.running = _enabled && activate; @@ -120,11 +125,6 @@ void AC_Sprayer::update() return; } - // exit immediately if the pump function has not been set-up for any servo - if (!SRV_Channels::function_assigned(SRV_Channel::k_sprayer_pump)) { - return; - } - // get horizontal velocity Vector3f velocity; if (!AP::ahrs().get_velocity_NED(velocity)) {