-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.rs
More file actions
45 lines (33 loc) · 1.36 KB
/
main.rs
File metadata and controls
45 lines (33 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! High-level locomotion control example.
//!
//! Run with:
//! `cargo run -p locomotion`
use booster_sdk::client::loco::BoosterClient;
use booster_sdk::types::RobotMode;
use tokio::time::Duration;
use tracing_subscriber::EnvFilter;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let env_filter = EnvFilter::new("off,booster_sdk=debug");
tracing_subscriber::fmt().with_env_filter(env_filter).init();
tracing::info!("Starting locomotion control example");
let client = BoosterClient::new()?;
tracing::info!("Changing to walking mode...");
client.change_mode(RobotMode::Walking).await?;
tracing::info!("Mode changed successfully");
tokio::time::sleep(Duration::from_secs(2)).await;
tracing::info!("Moving forward at 0.5 m/s for 3 seconds");
client.move_robot(0.5, 0.0, 0.0).await?;
tokio::time::sleep(Duration::from_secs(3)).await;
tracing::info!("Stopping");
client.move_robot(0.0, 0.0, 0.0).await?;
tokio::time::sleep(Duration::from_secs(1)).await;
tracing::info!("Turning left for 2 seconds");
client.move_robot(0.0, 0.0, 0.6).await?;
tokio::time::sleep(Duration::from_secs(2)).await;
tracing::info!("Stopping");
client.move_robot(0.0, 0.0, 0.0).await?;
tokio::time::sleep(Duration::from_secs(1)).await;
tracing::info!("Example completed successfully");
Ok(())
}