From 8bb5c49cc9878e6cd4770fe372df194f568f01b5 Mon Sep 17 00:00:00 2001 From: jbernavaprah Date: Thu, 11 Jun 2026 12:08:12 +0200 Subject: [PATCH] feat: restore microphone and speaker visualization on phoxal v0.6.0 The v0.5.0 typed-bus migration dropped the microphone and speaker visualization paths because the topic tree had no fluent leaves for those capabilities. phoxal v0.6.0 adds `component(id).microphone(cap).data()` and `component(id).speaker(cap).audio()`, so re-wire both: - microphone: subscribe to the data leaf, log audio frame byte count as a scalar - speaker: subscribe to the audio leaf, log output byte count as a scalar Restores the dropped `capability::{microphone,speaker}` log modules, the `Microphone`/`SpeakerData` events, their subscriptions, and dispatch arms. Bumps the phoxal dependency to 0.6.0. Co-Authored-By: Claude Opus 4.8 --- Cargo.lock | 4 ++-- Cargo.toml | 3 ++- src/capability/microphone.rs | 19 +++++++++++++++++++ src/capability/mod.rs | 22 ++++++++++++++++++++++ src/capability/speaker.rs | 19 +++++++++++++++++++ src/event.rs | 4 ++++ src/main.rs | 8 ++++++++ src/subscriptions.rs | 22 ++++++++++++++++++++-- 8 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 src/capability/microphone.rs create mode 100644 src/capability/speaker.rs diff --git a/Cargo.lock b/Cargo.lock index bc68e00..96563e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3141,9 +3141,9 @@ dependencies = [ [[package]] name = "phoxal" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28e98fd325a693585a7ba0db4dfbffa940b913217630bd412c3e82f077f77ce4" +checksum = "e03c85717b2412f60f950a7b9256b3deac56da6e72460154910cdddd5b4c418a" dependencies = [ "anyhow", "arc-swap", diff --git a/Cargo.toml b/Cargo.toml index 3adc032..51b2166 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ serde = { version = "1.0.228", features = ["derive"] } tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread", "time", "signal", "sync", "fs"] } tracing = "0.1.44" urdf-rs = "0.9.0" -phoxal = { version = "0.5.0" } +phoxal = { version = "0.6.0" } [workspace.lints.rust] unused = "warn" @@ -64,3 +64,4 @@ urdf-rs = { workspace = true } [lints] workspace = true + diff --git a/src/capability/microphone.rs b/src/capability/microphone.rs new file mode 100644 index 0000000..ea3640c --- /dev/null +++ b/src/capability/microphone.rs @@ -0,0 +1,19 @@ +use anyhow::Result; +use phoxal::api::v1::component::capability::microphone::Frame; +use phoxal::bus::typed::Received; +use rerun::{RecordingStream, Scalars}; + +use crate::logging::helpers::set_logical_time; + +pub(crate) fn log( + rec: &RecordingStream, + capability_entity_path: &str, + received: &Received, +) -> Result<()> { + set_logical_time(rec, received.at_ns); + rec.log( + format!("{capability_entity_path}/audio_bytes").as_str(), + &Scalars::new([received.value.data().len() as f64]), + )?; + Ok(()) +} diff --git a/src/capability/mod.rs b/src/capability/mod.rs index adf0c1a..0ef3a84 100644 --- a/src/capability/mod.rs +++ b/src/capability/mod.rs @@ -8,8 +8,10 @@ mod gyroscope; mod imu; mod lidar; mod magnetometer; +mod microphone; mod mmwave; mod range; +mod speaker; use crate::scene::SceneModel; use anyhow::Result; @@ -23,8 +25,10 @@ use phoxal::api::v1::component::capability::gyroscope::Sample as GyroscopeSample use phoxal::api::v1::component::capability::imu::Sample as ImuSample; use phoxal::api::v1::component::capability::lidar::Scan as LidarScan; use phoxal::api::v1::component::capability::magnetometer::Sample as MagnetometerSample; +use phoxal::api::v1::component::capability::microphone::Frame as MicrophoneFrame; use phoxal::api::v1::component::capability::mmwave::Scan as MmwaveScan; use phoxal::api::v1::component::capability::range::Sample as RangeSample; +use phoxal::api::v1::component::capability::speaker::audio::Audio; use phoxal::bus::typed::Received; use rerun::RecordingStream; @@ -141,3 +145,21 @@ pub(crate) fn log_mmwave( ) -> Result<()> { mmwave::log(rec, scene.capability_entity_path(capability_id)?, received) } + +pub(crate) fn log_microphone( + rec: &RecordingStream, + scene: &SceneModel, + capability_id: &str, + received: &Received, +) -> Result<()> { + microphone::log(rec, scene.capability_entity_path(capability_id)?, received) +} + +pub(crate) fn log_speaker_data( + rec: &RecordingStream, + scene: &SceneModel, + capability_id: &str, + received: &Received