diff --git a/src/signage/src/signage/announce_controller.py b/src/signage/src/signage/announce_controller.py index 36f1c41..9920550 100644 --- a/src/signage/src/signage/announce_controller.py +++ b/src/signage/src/signage/announce_controller.py @@ -4,7 +4,6 @@ from PyQt5.QtMultimedia import QSound from rclpy.duration import Duration -from rclpy.qos import QoSProfile, DurabilityPolicy from ament_index_python.packages import get_package_share_directory from pulsectl import Pulse @@ -44,15 +43,10 @@ def __init__(self, node, autoware_interface, parameter_interface): self._pulse = Pulse() # Get default sink at startup self._sink = self._pulse.get_sink_by_name(self._pulse.server_info().default_sink_name) - self._get_volume_pub = self._node.create_publisher( - Float32, - "~/get/volume", - QoSProfile(depth=1, durability=DurabilityPolicy.TRANSIENT_LOCAL), - ) + self._get_volume_pub = self._node.create_publisher(Float32, "~/get/volume", 1) + self._node.create_timer(1.0, self.publish_volume_callback) self._node.create_service(SetVolume, "~/set/volume", self.set_volume) - self._get_volume_pub.publish(Float32(data=self._sink.volume.value_flat)) - def process_pending_announce(self): try: for play_sound in self._pending_announce_list: @@ -120,10 +114,12 @@ def announce_going_to_depart_and_arrive(self, message): self.send_announce(message) self._prev_depart_and_arrive_type = message + def publish_volume_callback(self): + self._get_volume_pub.publish(Float32(data=self._sink.volume.value_flat)) + def set_volume(self, request, response): try: self._pulse.volume_set_all_chans(self._sink, request.volume) - self._get_volume_pub.publish(Float32(data=self._sink.volume.value_flat)) response.status.code = ResponseStatus.SUCCESS except Exception: response.status.code = ResponseStatus.ERROR