Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. #! /usr/bin/env python
  2.  
  3. import rospy
  4.  
  5. import actionlib
  6.  
  7. import actionlib_tutorials.msg
  8. import control_msgs.msg
  9.  
  10. def gripper_client():
  11.     # Creates the SimpleActionClient, passing the type of the action
  12.     # (GripperCommandAction) to the constructor.
  13.     client = actionlib.SimpleActionClient('/gripper/goal', control_msgs.msg.GripperCommandAction)
  14.  
  15.     # Waits until the action server has started up and started
  16.     # listening for goals.
  17.     client.wait_for_server()
  18.  
  19.     # Creates a goal to send to the action server.
  20.     goal = control_msgs.msg.GripperCommandActionGoal('header: {seq: 0, stamp: {secs: 0, nsecs: 0}, frame_id: ''}',
  21.                                                      ' goal_id: {stamp: {secs: 0, nsec: 0}, id: '' }',
  22.                                                      ' goal: {command: {position: 0.0, max_effort: 100 } }')
  23.  
  24.     # Sends the goal to the action server.
  25.     client.send_goal(goal)
  26.  
  27.     # Waits for the server to finish performing the action.
  28.     client.wait_for_result()
  29.  
  30.     # Prints out the result of executing the action
  31.     return client.get_result()
  32.  
  33. if __name__ == '__main__':
  34.     # Initializes a rospy node so that the SimpleActionClient can
  35.     # publish and subscribe over ROS.
  36.     rospy.init_node('gripper_control')
  37.     gripper_client()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement