Skip to content

Commit dd39d2b

Browse files
committed
Clean up pixi.toml + move rust examples
1 parent 711d430 commit dd39d2b

5 files changed

Lines changed: 270 additions & 183 deletions

File tree

File renamed without changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//! High-level look around example
2+
//!
3+
//! This example demonstrates basic look around behavior using the `B1LocoClient`.
4+
//!
5+
//! Run with: cargo run --example `look_around`
6+
7+
use booster_sdk::client::B1LocoClient;
8+
use tokio::time::Duration;
9+
10+
#[tokio::main]
11+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
12+
// Initialize logging
13+
tracing_subscriber::fmt().with_env_filter("info").init();
14+
15+
tracing::info!("Starting look around example");
16+
17+
// Create client with 2-second timeout
18+
let client = B1LocoClient::with_timeout(Duration::from_millis(2000)).await?;
19+
20+
// Get current mode
21+
match client.get_mode().await {
22+
Ok(mode) => tracing::info!("Current mode: {:?}", mode),
23+
Err(e) => tracing::error!("Failed to get mode: {}", e),
24+
}
25+
26+
// Rotate head
27+
tracing::info!("Looking around");
28+
29+
// scan from left to right with a sine wave
30+
let steps = 4000;
31+
for i in 0..=steps {
32+
let angle = (i as f32 / steps as f32) * std::f32::consts::TAU;
33+
let head_yaw = (6.0 * angle).cos() * 1.0;
34+
let head_pitch = (6.0 * angle).sin() * 0.4;
35+
client.rotate_head(head_pitch, head_yaw).await?;
36+
tokio::time::sleep(Duration::from_millis(10)).await;
37+
}
38+
39+
// set head back to center
40+
tracing::info!("Centering head");
41+
client.rotate_head(0.0, 0.0).await?;
42+
43+
Ok(())
44+
}

0 commit comments

Comments
 (0)