Go to the documentation of this file.00001
00002
00003
00004
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
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)
00034
00035
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)
00041
00042
00043
00044
00045