Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 音声のON/OFFを切り替える設定を追加 #90

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/signage/config/signage_param.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,13 @@ signage:
accept_start: 5.0 # second
monitor_width: 1920
monitor_height: 540
announce:
emergency: true
restart_engage: true
door_close: true
door_open: true
engage: true
thank_you: true
in_emergency: true
going_to_depart: true
going_to_arrive: true
Binary file removed src/signage/resource/sound/arrived.wav
Binary file not shown.
Binary file added src/signage/resource/sound/restart_engage.wav
Binary file not shown.
Binary file not shown.
Binary file removed src/signage/resource/sound/wait_for_walker.wav
Binary file not shown.
12 changes: 12 additions & 0 deletions src/signage/src/signage/announce_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, node, autoware_interface, parameter_interface):

self._node = node
self._parameter = parameter_interface.parameter
self._announce_settings = parameter_interface.announce_settings
self._current_announce = ""
self._pending_announce_list = []
self._sound = QSound("")
Expand Down Expand Up @@ -62,10 +63,21 @@ def play_sound(self, message):
self._sound = QSound(self._package_path + message + ".wav")
self._sound.play()

# skip announce by setting
def check_announce_or_not(self, message):
try:
return getattr(self._announce_settings, message)
except Exception as e:
self._node.get_logger().error("check announce or not: " + str(e))
return False

def send_announce(self, message):
priority = PRIORITY_DICT.get(message, 0)
previous_priority = PRIORITY_DICT.get(self._current_announce, 0)

if not self.check_announce_or_not(message):
return

if priority == 3:
self._sound.stop()
self.play_sound(message)
Expand Down
33 changes: 33 additions & 0 deletions src/signage/src/signage/parameter_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,23 @@ class SignageParameter:
monitor_width: int = 1920
monitor_height: int = 540

@dataclass
class AnnounceParameter:
emergency: bool = True
restart_engage: bool = True
door_close: bool = True
door_open: bool = True
engage: bool = True
arrived: bool = True
thank_you: bool = True
in_emergency: bool = True
going_to_depart: bool = True
going_to_arrive: bool = True

class ParameterInterface:
def __init__(self, node):
self.parameter = SignageParameter()
self.announce_settings = AnnounceParameter()

node.declare_parameter("signage_stand_alone", False)
node.declare_parameter("ignore_manual_driving", False)
Expand Down Expand Up @@ -64,3 +77,23 @@ def __init__(self, node):
self.parameter.monitor_height = (
node.get_parameter("monitor_height").get_parameter_value().integer_value
)

node.declare_parameter("announce.emergency", True)
node.declare_parameter("announce.restart_engage", True)
node.declare_parameter("announce.door_close", True)
node.declare_parameter("announce.door_open", True)
node.declare_parameter("announce.engage", True)
node.declare_parameter("announce.thank_you", True)
node.declare_parameter("announce.in_emergency", True)
node.declare_parameter("announce.going_to_depart", True)
node.declare_parameter("gannounce.oing_to_arrive", True)

announce_prefix = node.get_parameters_by_prefix("announce")

for key in announce_prefix.keys():
setattr(
self.announce_settings,
key,
announce_prefix[key].get_parameter_value().bool_value,
)

2 changes: 1 addition & 1 deletion src/signage/src/signage/route_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def announce_engage_when_starting(self):
self._engage_trigger_time,
self._parameter.accept_start,
):
self._announce_interface.send_announce("engage")
self._announce_interface.send_announce("restart_engage")
self._engage_trigger_time = self._node.get_clock().now()

if self._autoware.information.motion_state == MotionState.STARTING:
Expand Down
Loading