def callback_service_on_request(self, req): rospy.loginfo('\033[94m' + " >>> Gripper Activate: {}".format(req.activate_gripper) + '\033[0m') rospy.loginfo('\033[94m' + " >>> Gripper Flag Pickable: {}".format(self.pickable_flag) + '\033[0m') if((req.activate_gripper == True) and (self.pickable_flag == 'True') ): self.activate_gripper() return GripperResponse(True) else: self.deactivate_gripper() return GripperResponse(False)
def callback_service_on_request(self, req): pickable, box_name = self.check() rospy.loginfo('\033[94m' + " >>> Gripper Activate: {}".format(req.activate_gripper) + '\033[0m') rospy.loginfo('\033[94m' + " >>> Gripper Flag Pickable: {}".format(str(pickable)) + '\033[0m') if pickable: if(req.activate_gripper is True): self.activate_gripper(box_name) return GripperResponse(True) else: self.deactivate_gripper(box_name) return GripperResponse(False) else: return GripperResponse(False)
def attach(): ''' Purpose: --- This function is used to activate gripper and if the box gets attached with drone it checks value of result and change the global variable grip_res=1 Input Arguments: --- None Returns: --- None ''' req = 0 resp = 0 activate = 0 rospy.wait_for_service('/edrone/activate_gripper') activate = rospy.ServiceProxy('/edrone/activate_gripper', Gripper) req = GripperRequest(True) resp = activate(req) GripperResponse(resp) global grip_res if(req.activate_gripper == True and resp.result == True): grip_res = 1
def check_pick_gripper(self): ''' Purpose: --- Function to check if gripper status is true or not and requests for gripping when available. Input Arguments: --- None Returns: --- None Example call: --- self.check_pick_gripper() ''' # print(self.gripper) while self.gripper == False: rospy.logwarn("gripping unavailable") continue # Fetching Gripper Response res = GripperResponse() # if grip is successsful while not res.result: res = self.gripper_srv(True) rospy.loginfo("Pick up successful") self.isLoaded = True
def check_pick_gripper(self): print(self.gripper) while self.gripper == False: rospy.logwarn("gripping unavailable") continue res = GripperResponse() while not res.result: res = self.gripper_srv(True) rospy.loginfo("Pick up successful") self.isLoaded = True
def dettach(): ''' Purpose: --- This function is used to deactivate gripper and dettached box with drone Input Arguments: --- None Returns: --- None ''' req = 0 resp = 0 activate = 0 rospy.wait_for_service('/edrone/activate_gripper') activate = rospy.ServiceProxy('/edrone/activate_gripper', Gripper) req = GripperRequest(False) resp = activate(req) GripperResponse(resp)