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  rospy.loginfo("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  rospy.loginfo("End Need Unplugging")
25 
26  rospy.loginfo("Need Plugging")
27  goal = SoundRequestGoal()
28  goal.sound_request.sound = SoundRequest.NEEDS_PLUGGING
29  goal.sound_request.command = SoundRequest.PLAY_ONCE
30  goal.sound_request.volume = volume
31  client.send_goal(goal)
32  client.wait_for_result()
33  # print client.get_result()
34  rospy.loginfo("End Need Plugging")
35 
36  rospy.loginfo("Say")
37  goal = SoundRequestGoal()
38  goal.sound_request.sound = SoundRequest.SAY
39  goal.sound_request.command = SoundRequest.PLAY_ONCE
40  goal.sound_request.arg = "Testing the actionlib interface A P I"
41  goal.sound_request.volume = volume
42  client.send_goal(goal)
43  client.wait_for_result()
44  # print client.get_result()
45  rospy.loginfo("End Say")
46 
47  rospy.loginfo("Wav")
48  goal = SoundRequestGoal()
49  goal.sound_request.sound = SoundRequest.PLAY_FILE
50  goal.sound_request.command = SoundRequest.PLAY_ONCE
51  goal.sound_request.arg = os.path.join(roslib.packages.get_pkg_dir('sound_play'),'sounds') + "/say-beep.wav"
52  goal.sound_request.volume = volume
53  client.send_goal(goal)
54  client.wait_for_result()
55  # print client.get_result()
56  rospy.loginfo("End wav")
57 
58 if __name__ == '__main__':
59  rospy.init_node('soundplay_client_test')
def sound_play_client(volume=1.0)


sound_play
Author(s): Blaise Gassend
autogenerated on Fri Jun 9 2023 02:47:15