test_actionlib_client.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 import roslib; roslib.load_manifest('sound_play')
4 import rospy
5 import actionlib
6 from sound_play.msg import SoundRequest, SoundRequestAction, SoundRequestGoal
7 
8 import os
9 
10 def sound_play_client(volume=1.0):
11  client = actionlib.SimpleActionClient('sound_play', SoundRequestAction)
12 
13  client.wait_for_server()
14 
15  print "Need Unplugging"
16  goal = SoundRequestGoal()
17  goal.sound_request.sound = SoundRequest.NEEDS_UNPLUGGING
18  goal.sound_request.command = SoundRequest.PLAY_ONCE
19  goal.sound_request.volume = volume
20 
21  client.send_goal(goal)
22  client.wait_for_result()
23  print client.get_result()
24  print "End Need Unplugging"
25  print
26 
27  print "Need Plugging"
28  goal = SoundRequestGoal()
29  goal.sound_request.sound = SoundRequest.NEEDS_PLUGGING
30  goal.sound_request.command = SoundRequest.PLAY_ONCE
31  goal.sound_request.volume = volume
32  client.send_goal(goal)
33  client.wait_for_result()
34  print client.get_result()
35  print "End Need Plugging"
36  print
37 
38  print "Say"
39  goal = SoundRequestGoal()
40  goal.sound_request.sound = SoundRequest.SAY
41  goal.sound_request.command = SoundRequest.PLAY_ONCE
42  goal.sound_request.arg = "Testing the actionlib interface A P I"
43  goal.sound_request.volume = volume
44  client.send_goal(goal)
45  client.wait_for_result()
46  print client.get_result()
47  print "End Say"
48  print
49 
50  print "Wav"
51  goal = SoundRequestGoal()
52  goal.sound_request.sound = SoundRequest.PLAY_FILE
53  goal.sound_request.command = SoundRequest.PLAY_ONCE
54  goal.sound_request.arg = os.path.join(roslib.packages.get_pkg_dir('sound_play'),'sounds') + "/say-beep.wav"
55  goal.sound_request.volume = volume
56  client.send_goal(goal)
57  client.wait_for_result()
58  print client.get_result()
59  print "End wav"
60  print
61 
62 if __name__ == '__main__':
63  rospy.init_node('soundplay_client_test')
def sound_play_client(volume=1.0)


sound_play
Author(s): Blaise Gassend
autogenerated on Tue Mar 26 2019 02:30:56