Skip to content

Commit

Permalink
Merge pull request #1262 from k-okada/common_boot_sound
Browse files Browse the repository at this point in the history
  • Loading branch information
k-okada authored Jul 18, 2021
2 parents 4fddcdd + 0b8ba9b commit 09b968f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
lang: japanese
</rosparam>
</node>
<node if="$(arg boot_sound)" pkg="jsk_fetch_startup" name="boot_sound" type="boot_sound.py" />
<node if="$(arg boot_sound)" pkg="jsk_robot_startup" name="boot_sound" type="boot_sound.py" >
<param name="wav_file" value="$(find jsk_fetch_startup)/data/boot_sound.wav" />
</node>

<!-- look at human for Fetch -->
<node name="look_at_human"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@

if __name__ == "__main__":
rospy.init_node("boot_sound")
if rospy.has_param("~wav_file"):
wav_file = rospy.get_param("~wav_file")
else:
wav_file = "/usr/share/sounds/alsa/Front_Center.wav"

sound = SoundClient()
time.sleep(1) # ???
ac = actionlib.SimpleActionClient('sound_play', SoundRequestAction)
ac.wait_for_server()
if len(ni.ifaddresses('eth0')) > 2 :
ip = ni.ifaddresses('eth0')[2][0]['addr']
elif len(ni.ifaddresses('wlan0')) > 2 :
ip = ni.ifaddresses('wlan0')[2][0]['addr']


interfaces = [x for x in ni.interfaces() if x[0:3] in ['eth', 'enp', 'wla', 'wlp'] and
2 in ni.ifaddresses(x).keys()]
if len(interfaces) > 0 :
ip = ni.ifaddresses(interfaces[0])[2][0]['addr']
else:
ip = None

# play sound
rospack = rospkg.RosPack()
wav_file = os.path.join(rospack.get_path("jsk_fetch_startup"),"data/boot_sound.wav")
rospy.loginfo("Playing {}".format(wav_file))
sound.playWave(wav_file)
time.sleep(10) # make sure to topic is going out
Expand Down

0 comments on commit 09b968f

Please sign in to comment.