AP_Gripper: Add feedback when already in state

This commit is contained in:
Leonard Hall 2022-08-05 19:04:03 +09:30 committed by Peter Barker
parent 64d69c5977
commit 4bf622dbaf

View File

@ -16,6 +16,19 @@ void AP_Gripper_Servo::init_gripper()
void AP_Gripper_Servo::grab()
{
// check if we are already grabbing
if (config.state == AP_Gripper::STATE_GRABBING) {
// do nothing
return;
}
// check if we are already grabbed
if (config.state == AP_Gripper::STATE_GRABBED) {
// inform user that we are already grabbed
gcs().send_text(MAV_SEVERITY_INFO, "Gripper load grabbing");
return;
}
// flag we are active and grabbing cargo
config.state = AP_Gripper::STATE_GRABBING;
@ -28,6 +41,19 @@ void AP_Gripper_Servo::grab()
void AP_Gripper_Servo::release()
{
// check if we are already releasing
if (config.state == AP_Gripper::STATE_RELEASING) {
// do nothing
return;
}
// check if we are already released
if (config.state == AP_Gripper::STATE_RELEASED) {
// inform user that we are already released
gcs().send_text(MAV_SEVERITY_INFO, "Gripper load released");
return;
}
// flag we are releasing cargo
config.state = AP_Gripper::STATE_RELEASING;