7 from jsk_topic_tools
import ConnectionBasedTransport
9 from eus_teleop.msg
import EusTeleopStatusArray
10 from sound_play.msg
import SoundRequest
16 super(EusTeleopStatusSounder, self).
__init__()
17 self.
pub = self.advertise(
'~output/sound', SoundRequest, queue_size=1)
18 self.
enable = {
'larm':
False,
'rarm':
False}
29 '~input/status', EusTeleopStatusArray, self.
_status_cb)
35 larm_enable = self.
enable[
'larm']
40 larm_start = larm_enable
and not self.
prev_enable[
'larm']
41 larm_stop =
not larm_enable
and self.
prev_enable[
'larm']
50 larm_collision = self.
collision[
'larm']
if larm_enable
else False
51 larm_track_error = self.
track_error[
'larm']
if larm_enable
else False
53 rarm_enable = self.
enable[
'rarm']
58 rarm_start = rarm_enable
and not self.
prev_enable[
'rarm']
59 rarm_stop =
not rarm_enable
and self.
prev_enable[
'rarm']
68 rarm_collision = self.
collision[
'rarm']
if rarm_enable
else False
69 rarm_collision = self.
collision[
'rarm']
if rarm_enable
else False
70 rarm_track_error = self.
track_error[
'rarm']
if rarm_enable
else False
81 if larm_start
or rarm_start:
82 sound_msg = SoundRequest()
83 sound_msg.sound = SoundRequest.PLAY_FILE
84 sound_msg.command = SoundRequest.PLAY_ONCE
85 sound_msg.volume = 0.6
86 sound_msg.arg = os.path.join(
87 self.
rospack.get_path(
'eus_teleop'),
'sounds/start.wav')
88 self.
pub.publish(sound_msg)
90 warning_msg = SoundRequest()
91 warning_msg.sound = SoundRequest.SAY
92 warning_msg.command = SoundRequest.PLAY_ONCE
93 warning_msg.volume = 0.6
94 if larm_start
and rarm_start:
95 warning_msg.arg =
"both arm starting"
97 warning_msg.arg =
"left arm starting"
99 warning_msg.arg =
"right arm starting"
100 self.
pub.publish(warning_msg)
101 elif larm_stop
or rarm_stop:
102 sound_msg = SoundRequest()
103 sound_msg.sound = SoundRequest.PLAY_FILE
104 sound_msg.command = SoundRequest.PLAY_ONCE
105 sound_msg.volume = 0.6
106 sound_msg.arg = os.path.join(
107 self.
rospack.get_path(
'eus_teleop'),
'sounds/stop.wav')
108 self.
pub.publish(sound_msg)
110 warning_msg = SoundRequest()
111 warning_msg.sound = SoundRequest.SAY
112 warning_msg.command = SoundRequest.PLAY_ONCE
113 warning_msg.volume = 0.6
114 if larm_stop
and rarm_stop:
115 warning_msg.arg =
"both arm stopping"
117 warning_msg.arg =
"left arm stopping"
119 warning_msg.arg =
"right arm stopping"
120 self.
pub.publish(warning_msg)
122 elif lhand_open
or rhand_open:
123 sound_msg = SoundRequest()
124 sound_msg.sound = SoundRequest.PLAY_FILE
125 sound_msg.command = SoundRequest.PLAY_ONCE
126 sound_msg.volume = 0.6
127 sound_msg.arg = os.path.join(
128 self.
rospack.get_path(
'eus_teleop'),
'sounds/gripper.wav')
129 self.
pub.publish(sound_msg)
131 warning_msg = SoundRequest()
132 warning_msg.sound = SoundRequest.SAY
133 warning_msg.command = SoundRequest.PLAY_ONCE
134 warning_msg.volume = 0.6
135 if lhand_open
and rhand_open:
136 warning_msg.arg =
"both hand opening"
138 warning_msg.arg =
"left hand opening"
140 warning_msg.arg =
"right hand opening"
141 self.
pub.publish(warning_msg)
144 elif lhand_close
or rhand_close:
145 sound_msg = SoundRequest()
146 sound_msg.sound = SoundRequest.PLAY_FILE
147 sound_msg.command = SoundRequest.PLAY_ONCE
148 sound_msg.volume = 0.6
149 sound_msg.arg = os.path.join(
150 self.
rospack.get_path(
'eus_teleop'),
'sounds/gripper.wav')
151 self.
pub.publish(sound_msg)
153 warning_msg = SoundRequest()
154 warning_msg.sound = SoundRequest.SAY
155 warning_msg.command = SoundRequest.PLAY_ONCE
156 warning_msg.volume = 0.6
157 if lhand_close
and rhand_close:
158 warning_msg.arg =
"both hand closing"
160 warning_msg.arg =
"left hand closing"
162 warning_msg.arg =
"right hand closing"
163 self.
pub.publish(warning_msg)
166 elif larm_collision
or rarm_collision:
167 sound_msg = SoundRequest()
168 sound_msg.sound = SoundRequest.PLAY_FILE
169 sound_msg.command = SoundRequest.PLAY_ONCE
170 sound_msg.volume = 0.6
171 sound_msg.arg = os.path.join(
172 self.
rospack.get_path(
'eus_teleop'),
'sounds/alert.wav')
173 self.
pub.publish(sound_msg)
175 warning_msg = SoundRequest()
176 warning_msg.sound = SoundRequest.SAY
177 warning_msg.command = SoundRequest.PLAY_ONCE
178 warning_msg.volume = 0.6
179 if larm_collision
and rarm_collision:
180 warning_msg.arg =
"both arm collision error"
182 warning_msg.arg =
"left arm collision error"
184 warning_msg.arg =
"right arm collision error"
185 self.
pub.publish(warning_msg)
187 elif larm_track_error
or rarm_track_error:
188 sound_msg = SoundRequest()
189 sound_msg.sound = SoundRequest.PLAY_FILE
190 sound_msg.command = SoundRequest.PLAY_ONCE
191 sound_msg.volume = 0.6
192 sound_msg.arg = os.path.join(
193 self.
rospack.get_path(
'eus_teleop'),
'sounds/warn.wav')
194 self.
pub.publish(sound_msg)
196 warning_msg = SoundRequest()
197 warning_msg.sound = SoundRequest.SAY
198 warning_msg.command = SoundRequest.PLAY_ONCE
199 warning_msg.volume = 0.6
200 if larm_track_error
and rarm_track_error:
201 warning_msg.arg =
"both arm tracking error"
202 elif larm_track_error:
203 warning_msg.arg =
"left arm tracking error"
205 warning_msg.arg =
"right arm tracking error"
206 self.
pub.publish(warning_msg)
210 for status
in msg.status:
211 if status.part_name
in self.
enable:
212 self.
enable[status.part_name] = status.enable
216 self.
collision[status.part_name] = status.collision
218 self.
track_error[status.part_name] = status.track_error
220 self.
hand_close[status.part_name] = status.hand_close
225 if __name__ ==
'__main__':
226 rospy.init_node(
'eus_teleop_status_sounder')