Skip to content

Commit eeb5a13

Browse files
authored
Simplify DDS subscriber + fix tracing setup (#7)
1 parent 7592c40 commit eeb5a13

16 files changed

Lines changed: 281 additions & 178 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/target
22

3+
examples/rust/**/target
4+
35
.ruff_cache/
46
.mypy_cache/
57

Cargo.lock

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
[workspace]
2-
members = ["booster_sdk", "booster_sdk_py"]
2+
members = [
3+
"booster_sdk",
4+
"booster_sdk_py",
5+
"examples/rust/locomotion",
6+
"examples/rust/look_around",
7+
]
38
resolver = "2"
49

510
[workspace.package]
6-
version = "0.1.0-alpha.10"
11+
version = "0.1.0-alpha.11"
712
edition = "2024"
813
authors = ["Team whIRLwind"]
914
license = "MIT OR Apache-2.0"
@@ -25,6 +30,7 @@ pedantic = { level = "warn", priority = -1 }
2530
booster_sdk = { path = "booster_sdk" }
2631

2732
tokio = { version = "1.42", features = ["full"] }
33+
futures = "0.3"
2834
rustdds = "0.11.8"
2935
serde = { version = "1.0", features = ["derive"] }
3036
serde_json = "1.0"

booster_sdk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ readme.workspace = true
1010

1111
[dependencies]
1212
tokio = { workspace = true }
13+
futures = { workspace = true }
1314
serde = { workspace = true }
1415
serde_json = { workspace = true }
1516
thiserror = { workspace = true }

booster_sdk/examples/gripper_control.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
77
use booster_sdk::client::loco::{BoosterClient, GripperCommand};
88
use booster_sdk::types::{Hand, RobotMode};
9+
use tracing_subscriber::EnvFilter;
910

1011
#[tokio::main]
1112
async fn main() -> Result<(), Box<dyn std::error::Error>> {
1213
// Initialize logging
13-
tracing_subscriber::fmt().with_env_filter("info").init();
14+
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
15+
tracing_subscriber::fmt().with_env_filter(env_filter).init();
1416

1517
tracing::info!("Starting gripper control example");
1618

booster_sdk/src/client/ai.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ impl AiClient {
117117

118118
/// Create an AI client with a custom startup wait before first RPC.
119119
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
120-
Self::with_options(RpcClientOptions::for_service(AI_API_TOPIC).with_startup_wait(startup_wait))
120+
Self::with_options(
121+
RpcClientOptions::for_service(AI_API_TOPIC).with_startup_wait(startup_wait),
122+
)
121123
}
122124

123125
/// Create an AI client with custom RPC options.
@@ -175,7 +177,9 @@ impl LuiClient {
175177

176178
/// Create a LUI client with a custom startup wait before first RPC.
177179
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
178-
Self::with_options(RpcClientOptions::for_service(LUI_API_TOPIC).with_startup_wait(startup_wait))
180+
Self::with_options(
181+
RpcClientOptions::for_service(LUI_API_TOPIC).with_startup_wait(startup_wait),
182+
)
179183
}
180184

181185
/// Create a LUI client with custom RPC options.

booster_sdk/src/client/loco.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ use serde::{Deserialize, Serialize};
2020
use serde_json::json;
2121
use typed_builder::TypedBuilder;
2222

23-
// The controller may send an intermediate pending status (-1) before the
24-
// final success response. Mode transitions (especially PREPARE) can take
25-
// several seconds.
26-
const CHANGE_MODE_TIMEOUT: Duration = Duration::from_secs(30);
27-
2823
/// High-level client for B1 locomotion control and telemetry.
2924
pub struct BoosterClient {
3025
rpc: RpcClient,
@@ -68,9 +63,7 @@ impl BoosterClient {
6863
/// Change the robot mode.
6964
pub async fn change_mode(&self, mode: RobotMode) -> Result<()> {
7065
let param = json!({ "mode": i32::from(mode) }).to_string();
71-
self.rpc
72-
.call_void_with_timeout(LocoApiId::ChangeMode, param, Some(CHANGE_MODE_TIMEOUT))
73-
.await
66+
self.rpc.call_void(LocoApiId::ChangeMode, param).await
7467
}
7568

7669
/// Get the current robot mode.

0 commit comments

Comments
 (0)