From 4d930e1f015f6449264647d3b270a7dedd45a975 Mon Sep 17 00:00:00 2001 From: Miles Punch Date: Sun, 28 Jun 2026 22:45:32 +0900 Subject: [PATCH 1/3] Add info about the Whistle Detector module --- src/book/02-system/05-modules/03-input.mdx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/book/02-system/05-modules/03-input.mdx b/src/book/02-system/05-modules/03-input.mdx index 06007975..266440fa 100644 --- a/src/book/02-system/05-modules/03-input.mdx +++ b/src/book/02-system/05-modules/03-input.mdx @@ -248,3 +248,24 @@ The resulting filtered data will then be outputted as `message::input::Sensors` - `message::input::ButtonMiddleDown` when button pressed. - `message::input::ButtonMiddleUp` when button released. - `message::eye::DataPoint` if log_level >= DEBUG, indicating if feet are down. + +## Whistle Detector + +### Description + +Reads from a microphone using ALSA, passes it through a Cooley-Tukey FFT, into a band-pass filter to filter out frequencies that aren't whistles. +After a certain number of consecutive detections above a threshold, it is assumed a whistle event has triggered; it emits a `message::input::Whistle` message. +The system also has a cool-down between allowed Whistle events, as well as a timer between module configuration and the first allowed Whistle event - this is because NUsense's beep likes to trigger this module. + +### Usage + +When installed, it expects a USB microphone connected to the NUgus. Not having this microphone is not fatal, however. +This device is connected to ALSA as `plughw:0,0`. To find this on the system, run `aplay -l` (this depends on having `alsa-utils`) + +### Consumes + +- Nothing + +### Emits + +- `messages::input::Whistle` with it's confidence of the whistle event and timestamp. From 3869b6d5fd7ad0e4694d22da449077bd6dee0d96 Mon Sep 17 00:00:00 2001 From: Miles Punch Date: Sun, 28 Jun 2026 22:50:17 +0900 Subject: [PATCH 2/3] changes to purpose/soccer --- src/book/02-system/05-modules/09-purpose.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/book/02-system/05-modules/09-purpose.mdx b/src/book/02-system/05-modules/09-purpose.mdx index e4804be5..27d5657b 100644 --- a/src/book/02-system/05-modules/09-purpose.mdx +++ b/src/book/02-system/05-modules/09-purpose.mdx @@ -428,6 +428,7 @@ Control flow: - Middle button (`ButtonMiddleDown`) disables idle mode after `disable_idle_delay` - On penalisation (`GameEvents::Penalisation` for self), purpose tasks are cancelled and localisation/servo state is reset - On unpenalisation, purpose and fall-recovery tasks are restarted (unless idling) +- If in `GameState::Phase::SET` state and we hear a `Whistle` event, move to `GameState::Phase::PLAYING`. ### Consumes @@ -440,6 +441,7 @@ Control flow: - `message::input::ButtonLeftUp` - `message::input::ButtonMiddleDown` - `message::input::ButtonMiddleUp` +- `message::input::Whistle` ### Emits From cbd7d350a6f6c16e9245bf0f763be1774be4794e Mon Sep 17 00:00:00 2001 From: Miles Punch Date: Sun, 28 Jun 2026 23:06:19 +0900 Subject: [PATCH 3/3] wording --- src/book/02-system/05-modules/03-input.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/book/02-system/05-modules/03-input.mdx b/src/book/02-system/05-modules/03-input.mdx index d37bb6c1..66327d35 100644 --- a/src/book/02-system/05-modules/03-input.mdx +++ b/src/book/02-system/05-modules/03-input.mdx @@ -260,7 +260,7 @@ The system also has a cool-down between allowed Whistle events, as well as a tim ### Usage When installed, it expects a USB microphone connected to the NUgus. Not having this microphone is not fatal, however. -This device is connected to ALSA as `plughw:0,0`. To find this on the system, run `aplay -l` (this depends on having `alsa-utils`) +This device is connected to ALSA as `plughw:0,0`. To find ALSA's list of inputs on the system, run `aplay -l` (this depends on having `alsa-utils`) ### Consumes