boot_sound.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # https://www.youtube.com/watch?v=HM-xG0qXaeA&&
00004 # ffmpeg -i R2D2\ all\ Sounds\ -\ Star\ Wars\ free\ sounds.mp4 -ss 48 -t 10 R2D2.wav
00005 
00006 import rospy
00007 import time, socket, os
00008 import netifaces as ni
00009 import rospkg
00010 
00011 from sound_play.libsoundplay import SoundClient
00012 import actionlib
00013 from sound_play.msg import SoundRequestAction
00014 
00015 if __name__ == "__main__":
00016     rospy.init_node("boot_sound")
00017     sound = SoundClient()
00018     time.sleep(1) # ???
00019     ac = actionlib.SimpleActionClient('sound_play', SoundRequestAction)
00020     ac.wait_for_server()
00021     if len(ni.ifaddresses('eth0')) > 2 :
00022         ip = ni.ifaddresses('eth0')[2][0]['addr']
00023     elif len(ni.ifaddresses('wlan0')) > 2 :
00024         ip = ni.ifaddresses('wlan0')[2][0]['addr']
00025     else:
00026         ip = None
00027 
00028     # play sound
00029     rospack = rospkg.RosPack()
00030     wav_file = os.path.join(rospack.get_path("jsk_fetch_startup"),"data/boot_sound.wav")
00031     rospy.loginfo("Playing {}".format(wav_file))
00032     sound.playWave(wav_file)
00033     time.sleep(10) # make sure to topic is going out
00034 
00035     # notify ip address
00036     ip_text = "My internet address is {}".format(ip)
00037     rospy.loginfo(ip_text)
00038     ip_text = ip_text.replace('.', ', ')
00039     sound.say(ip_text)
00040     time.sleep(1) # make sure to topic is going out
00041 
00042 
00043 
00044 
00045 


jsk_fetch_startup
Author(s):
autogenerated on Sat Jul 1 2017 02:42:26