Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.
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
43 changes: 37 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ async-trait = "0.1.89"
clap = { version = "4.6.1", features = ["derive"] }
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread", "time", "signal", "sync", "fs"] }
tracing = "0.1.44"
phoxal = { version = "0.16" }
# git bridge to the #00 framework until it is released to crates.io (plan #00).
phoxal = { git = "https://github.com/phoxal/framework", rev = "e8c4ce8395ef9afeb676a6c20e24f0eee00e8aee" }
phoxal-api = { git = "https://github.com/phoxal/framework", rev = "e8c4ce8395ef9afeb676a6c20e24f0eee00e8aee" }

[workspace.lints.rust]
unused = "warn"
Expand Down
3 changes: 2 additions & 1 deletion bno085/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition.workspace = true
rust-version.workspace = true
license.workspace = true
publish = false
description = "Phoxal catalog component bno085."
description = "Phoxal catalog component - bno085."
documentation.workspace = true
homepage.workspace = true
repository.workspace = true
Expand All @@ -16,6 +16,7 @@ workspace = true
[dependencies]
anyhow = { workspace = true }
phoxal = { workspace = true }
phoxal-api = { workspace = true }

[dev-dependencies]
serde_json = "1"
56 changes: 31 additions & 25 deletions bno085/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
//! `bno085` — BNO085 IMU component driver stub.

use anyhow::{Result, bail};
use phoxal::api::y2026_1 as api;
use phoxal::model::component::v1::capability::Capability;
use phoxal::prelude::*;
use phoxal_api::y2026_1 as api;

const STEP_HZ: f64 = 100.0;

#[derive(phoxal::Runtime)]
#[phoxal(id = "bno085", api = y2026_1)]
struct Bno085 {
imu: Vec<Publisher<api::component::ImuSample>>,
imu: Vec<Publisher<api::component::imu::Sample>>,
imu_divisors: Vec<u64>,
accelerometer: Vec<Publisher<api::component::AccelerometerSample>>,
accelerometer: Vec<Publisher<api::component::accelerometer::Sample>>,
accelerometer_divisors: Vec<u64>,
gyroscope: Vec<Publisher<api::component::GyroscopeSample>>,
gyroscope: Vec<Publisher<api::component::gyroscope::Sample>>,
gyroscope_divisors: Vec<u64>,
}

Expand All @@ -28,6 +28,9 @@ struct CapabilitySchedule {
impl Bno085 {
#[setup]
async fn setup(ctx: &mut SetupContext<Self>) -> Result<Self> {
// Owner opt-in (plan #00 L2): the runner-minted capability that the owner
// (`internal`) topic builder requires. This driver OWNS its component node.
let cap = ctx.owner_capability();
let instance = ctx.component()?.to_string();
let (imu_slots, accelerometer_slots, gyroscope_slots) = {
let robot = ctx.robot()?;
Expand Down Expand Up @@ -69,9 +72,10 @@ impl Bno085 {
for slot in imu_slots {
imu.push(
ctx.publisher(
api::topic::new()
.component()
.imu_sample(&instance, &slot.capability_id),
api::topic::internal::new(cap)
.component(&instance)
.imu(&slot.capability_id)
.sample(),
)
.await?,
);
Expand All @@ -83,9 +87,10 @@ impl Bno085 {
for slot in accelerometer_slots {
accelerometer.push(
ctx.publisher(
api::topic::new()
.component()
.accelerometer_sample(&instance, &slot.capability_id),
api::topic::internal::new(cap)
.component(&instance)
.accelerometer(&slot.capability_id)
.sample(),
)
.await?,
);
Expand All @@ -97,9 +102,10 @@ impl Bno085 {
for slot in gyroscope_slots {
gyroscope.push(
ctx.publisher(
api::topic::new()
.component()
.gyroscope_sample(&instance, &slot.capability_id),
api::topic::internal::new(cap)
.component(&instance)
.gyroscope(&slot.capability_id)
.sample(),
)
.await?,
);
Expand Down Expand Up @@ -171,28 +177,28 @@ fn is_due(step_index: u64, divisor: u64) -> bool {
divisor <= 1 || step_index % divisor == 0
}

fn imu_sample() -> api::component::ImuSample {
api::component::ImuSample {
fn imu_sample() -> api::component::imu::Sample {
api::component::imu::Sample {
orientation: Some([1.0, 0.0, 0.0, 0.0]),
angular_velocity_radps: [0.0; 3],
linear_acceleration_mps2: [0.0; 3],
covariance: None,
noise_density: None,
sensor_frame_id: None,
measured_at_ns: None,
health: api::component::SensorHealth::Nominal,
health: api::component::imu::SensorHealth::Nominal,
bias: None,
}
}

fn accelerometer_sample() -> api::component::AccelerometerSample {
api::component::AccelerometerSample {
fn accelerometer_sample() -> api::component::accelerometer::Sample {
api::component::accelerometer::Sample {
linear_acceleration: [0.0; 3],
}
}

fn gyroscope_sample() -> api::component::GyroscopeSample {
api::component::GyroscopeSample {
fn gyroscope_sample() -> api::component::gyroscope::Sample {
api::component::gyroscope::Sample {
angular_velocity: [0.0; 3],
}
}
Expand All @@ -204,8 +210,8 @@ fn main() -> phoxal::Result<()> {
#[cfg(test)]
mod tests {
use super::{Bno085, divisor_for_rate, is_due};
use phoxal::api::ContractBody;
use phoxal::api::y2026_1 as api;
use phoxal_api::ContractBody;
use phoxal_api::y2026_1 as api;

#[test]
fn divisor_rounds_to_fixed_step_clock() {
Expand All @@ -224,9 +230,9 @@ mod tests {
assert_eq!(value["artifact"]["id"], "bno085");
let contracts = value["required_contracts"].as_array().unwrap();
for family in [
<api::component::ImuSample as ContractBody>::FAMILY,
<api::component::AccelerometerSample as ContractBody>::FAMILY,
<api::component::GyroscopeSample as ContractBody>::FAMILY,
<api::component::imu::Sample as ContractBody>::FAMILY,
<api::component::accelerometer::Sample as ContractBody>::FAMILY,
<api::component::gyroscope::Sample as ContractBody>::FAMILY,
] {
assert!(
contracts
Expand Down
3 changes: 2 additions & 1 deletion ddsm115/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition.workspace = true
rust-version.workspace = true
license.workspace = true
publish = false
description = "Phoxal catalog component ddsm115."
description = "Phoxal catalog component - ddsm115."
documentation.workspace = true
homepage.workspace = true
repository.workspace = true
Expand All @@ -16,6 +16,7 @@ workspace = true
[dependencies]
anyhow = { workspace = true }
phoxal = { workspace = true }
phoxal-api = { workspace = true }

[dev-dependencies]
serde_json = "1"
Loading
Loading