test_mimic.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import roslib
19 import rospy
20 import sys
21 
22 # Brings in the SimpleActionClient
23 import actionlib
24 
25 # Brings in the messages used by the set_mimic action, including the
26 # goal message and the result message.
27 import cob_mimic.msg
28 
30  # Creates the SimpleActionClient, passing the type of the action
31  # to the constructor.
32  client = actionlib.SimpleActionClient('/mimic/set_mimic', cob_mimic.msg.SetMimicAction)
33 
34  # Waits until the action server has started up and started
35  # listening for goals.
36  client.wait_for_server()
37 
38  # Creates a goal to send to the action server.
39  goal = cob_mimic.msg.SetMimicGoal()
40  goal.mimic = sys.argv[1]
41 
42  # Sends the goal to the action server.
43  client.send_goal(goal)
44 
45  # Waits for the server to finish performing the action.
46  client.wait_for_result()
47 
48  # Prints out the result of executing the action
49  return client.get_result()
50 
51 if __name__ == '__main__':
52  try:
53  # Initializes a rospy node so that the SimpleActionClient can
54  # publish and subscribe over ROS.
55  if len(sys.argv) != 2:
56  print("Error: please specify mimic string as input")
57  sys.exit(1)
58 
59  rospy.init_node('mimic_test_node')
60  result = mimic_client()
61  except rospy.ROSInterruptException:
62  print("program interrupted before completion")
def mimic_client()
Definition: test_mimic.py:29


cob_mimic
Author(s): Nadia Hammoudeh Garcia , Benjamin Maidel
autogenerated on Wed Apr 7 2021 02:11:42