42 if __name__ ==
'__main__':
43 if len(sys.argv) < 3
or len(sys.argv) > 4
or sys.argv[1] ==
'--help':
44 print(
'Usage: %s package sound_to_play.(ogg|wav) [volume]' % sys.argv[0])
46 print(
'Plays an .OGG or .WAV file. The path to the file should be relative to the package, and be valid on the computer on which sound_play is running. \n The (optional) volume parameter sets the volume for the sound as a value between 0 and 1.0, where 0 is mute.')
51 from sound_play.msg
import SoundRequest
54 rospy.init_node(
'play', anonymous=
True)
57 volume = float(sys.argv[3])
if len(sys.argv) == 4
else 1.0
60 rospy.loginfo(
'Playing "%s" from pkg "%s".' % (sys.argv[2], sys.argv[1]))
61 soundhandle.playWaveFromPkg(sys.argv[1], sys.argv[2], volume)
This class is a helper class for communicating with the sound_play node via the sound_play.SoundRequest message.