3 import rospy, actionlib
4 from std_msgs.msg
import UInt16
5 from raspicat.msg
import MusicAction, MusicResult, MusicFeedback
8 bfile =
"/dev/rtbuzzer0" 10 with open(bfile,
"w")
as f:
11 f.write(str(hz) +
"\n")
13 rospy.logerr(
"can't write to " + bfile)
19 for i, f
in enumerate(goal.freqs):
20 fb.remaining_steps = len(goal.freqs) - i
21 music.publish_feedback(fb)
23 if music.is_preempt_requested():
26 music.set_preempted(r)
30 rospy.sleep(1.0
if i >= len(goal.durations)
else goal.durations[i])
33 music.set_succeeded(r)
37 if __name__ ==
'__main__':
38 rospy.init_node(
'buzzer')
39 rospy.Subscriber(
"buzzer", UInt16, recv_buzzer)
42 rospy.on_shutdown(write_freq)