From b4d1d0f9189df7d91991dcbeccee7fd867db2707 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 20 Dec 2016 14:18:18 +1100 Subject: [PATCH] AP_Gripper: servo gripper not valid unless aux channel assigned --- libraries/AP_Gripper/AP_Gripper_Backend.h | 2 +- libraries/AP_Gripper/AP_Gripper_Servo.cpp | 11 +++++++++++ libraries/AP_Gripper/AP_Gripper_Servo.h | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Gripper/AP_Gripper_Backend.h b/libraries/AP_Gripper/AP_Gripper_Backend.h index 06b68d51fb..30fb9f8a1d 100644 --- a/libraries/AP_Gripper/AP_Gripper_Backend.h +++ b/libraries/AP_Gripper/AP_Gripper_Backend.h @@ -35,7 +35,7 @@ public: virtual void release() = 0; // valid - returns true if the backend should be working - bool valid() const { return true; }; + virtual bool valid() const { return true; }; // released - returns true if currently in released position virtual bool released() const = 0; diff --git a/libraries/AP_Gripper/AP_Gripper_Servo.cpp b/libraries/AP_Gripper/AP_Gripper_Servo.cpp index 737a1037f9..3bc2752e61 100644 --- a/libraries/AP_Gripper/AP_Gripper_Servo.cpp +++ b/libraries/AP_Gripper/AP_Gripper_Servo.cpp @@ -55,3 +55,14 @@ bool AP_Gripper_Servo::grabbed() const // type-specific periodic updates: void AP_Gripper_Servo::update_gripper() { }; + +bool AP_Gripper_Servo::valid() const +{ + if (!AP_Gripper_Backend::valid()) { + return false; + } + if (!RC_Channel_aux::function_assigned(RC_Channel_aux::k_gripper)) { + return false; + } + return true; +} diff --git a/libraries/AP_Gripper/AP_Gripper_Servo.h b/libraries/AP_Gripper/AP_Gripper_Servo.h index 30ed1cde5e..1db0977208 100644 --- a/libraries/AP_Gripper/AP_Gripper_Servo.h +++ b/libraries/AP_Gripper/AP_Gripper_Servo.h @@ -36,6 +36,9 @@ public: // released - returns true if gripper in released state bool released() const override; + // valid - returns true if the backend should be working + bool valid() const; + protected: // type-specific intiailisations: