def gripper_action_client():
    gripper_client = actionlib.SimpleActionClient('xm_move_gripper', xm_GripperCommandAction)
    rospy.loginfo("Waiting for xm_move_gripper action server")
    gripper_client.wait_for_server()
    rospy.loginfo("Connected to xm_move_gripper action server")

    gripper_goal = xm_GripperCommandGoal()
    gripper_goal.command.position = 0.05
    gripper_goal.command.torque = 0.5

    rospy.loginfo("Preparing for sending goal to the action server")
    gripper_client.send_goal(gripper_goal)
    gripper_client.wait_for_result()
    rospy.loginfo("Send goal to the action server successfully!")

    return gripper_client.get_result()
Ejemplo n.º 2
0
def gripper_action_client():
    gripper_client = actionlib.SimpleActionClient('xm_move_gripper',
                                                  xm_GripperCommandAction)
    rospy.loginfo("Waiting for xm_move_gripper action server")
    gripper_client.wait_for_server()
    rospy.loginfo("Connected to xm_move_gripper action server")

    gripper_goal = xm_GripperCommandGoal()
    gripper_goal.command.position = 0.05
    gripper_goal.command.torque = 0.5

    rospy.loginfo("Preparing for sending goal to the action server")
    gripper_client.send_goal(gripper_goal)
    gripper_client.wait_for_result()
    rospy.loginfo("Send goal to the action server successfully!")

    return gripper_client.get_result()
 def __init__(self):
     rospy.init_node("test_gripper_smach", anonymous=False)
     gripper_goal = xm_GripperCommandGoal()
     gripper_goal.command.position = 0.10
     gripper_goal.command.torque = 0.5
     gripper_state = SimpleActionState(
         "xm_move_gripper",
         xm_GripperCommandAction,
         goal=gripper_goal,
         result_cb=self.gripper_state_cb,
         exec_timeout=rospy.Duration(10),
         server_wait_timeout=rospy.Duration(10),
     )
     self.gripper_smach = StateMachine(outcomes=["succeeded", "aborted", "preempted"])
     with self.gripper_smach:
         StateMachine.add(
             "GRIPPER_OPEN", gripper_state, transitions={"succeeded": "", "aborted": "", "preempted": ""}
         )
     gripper_outcome = self.gripper_smach.execute()
     rospy.loginfo("State Machine Outcome: " + str(gripper_outcome))
 def __init__(self):
     rospy.init_node('test_gripper_smach', anonymous=False)
     gripper_goal = xm_GripperCommandGoal()
     gripper_goal.command.position = 0.10
     gripper_goal.command.torque = 0.5
     gripper_state = SimpleActionState(
         'xm_move_gripper',
         xm_GripperCommandAction,
         goal=gripper_goal,
         result_cb=self.gripper_state_cb,
         exec_timeout=rospy.Duration(10),
         server_wait_timeout=rospy.Duration(10))
     self.gripper_smach = StateMachine(
         outcomes=['succeeded', 'aborted', 'preempted'])
     with self.gripper_smach:
         StateMachine.add('GRIPPER_OPEN',
                          gripper_state,
                          transitions={
                              'succeeded': '',
                              'aborted': '',
                              'preempted': ''
                          })
     gripper_outcome = self.gripper_smach.execute()
     rospy.loginfo('State Machine Outcome: ' + str(gripper_outcome))