Skip to content
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
5 changes: 3 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["booster_sdk", "booster_sdk_py"]
resolver = "2"

[workspace.package]
version = "0.1.0-alpha.8"
version = "0.1.0-alpha.10"
edition = "2024"
authors = ["Team whIRLwind"]
license = "MIT OR Apache-2.0"
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ pip install booster-sdk

### Python API Example

Note: Python bindings are experimental.

```python
from booster_sdk.client.booster import BoosterClient
from booster_sdk.types import GripperCommand, Hand, RobotMode
from booster_sdk.client.booster import BoosterClient, GripperCommand, Hand, RobotMode

client = BoosterClient()

Expand Down
12 changes: 12 additions & 0 deletions booster_sdk/src/client/ai.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! AI and LUI high-level RPC clients.

use std::time::Duration;

use serde::{Deserialize, Serialize};

use crate::dds::{
Expand Down Expand Up @@ -113,6 +115,11 @@ impl AiClient {
Self::with_options(RpcClientOptions::for_service(AI_API_TOPIC))
}

/// Create an AI client with a custom startup wait before first RPC.
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
Self::with_options(RpcClientOptions::for_service(AI_API_TOPIC).with_startup_wait(startup_wait))
}

/// Create an AI client with custom RPC options.
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
let rpc = RpcClient::for_topic(options, AI_API_TOPIC)?;
Expand Down Expand Up @@ -166,6 +173,11 @@ impl LuiClient {
Self::with_options(RpcClientOptions::for_service(LUI_API_TOPIC))
}

/// Create a LUI client with a custom startup wait before first RPC.
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
Self::with_options(RpcClientOptions::for_service(LUI_API_TOPIC).with_startup_wait(startup_wait))
}

/// Create a LUI client with custom RPC options.
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
let rpc = RpcClient::for_topic(options, LUI_API_TOPIC)?;
Expand Down
9 changes: 9 additions & 0 deletions booster_sdk/src/client/light_control.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! LED light control RPC client.

use std::time::Duration;

use serde::{Deserialize, Serialize};

use crate::dds::{LIGHT_CONTROL_API_TOPIC, RpcClient, RpcClientOptions};
Expand Down Expand Up @@ -49,6 +51,13 @@ impl LightControlClient {
Self::with_options(RpcClientOptions::for_service(LIGHT_CONTROL_API_TOPIC))
}

/// Create a light control client with a custom startup wait before first RPC.
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
Self::with_options(
RpcClientOptions::for_service(LIGHT_CONTROL_API_TOPIC).with_startup_wait(startup_wait),
)
}

/// Create a light control client with custom RPC options.
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
let rpc = RpcClient::for_topic(options, LIGHT_CONTROL_API_TOPIC)?;
Expand Down
9 changes: 8 additions & 1 deletion booster_sdk/src/client/loco.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! High-level B1 locomotion client built on DDS RPC and topic I/O.

use std::time::Duration;

use crate::dds::{
BatteryState, BinaryData, ButtonEventMsg, DdsNode, DdsPublisher, DdsSubscription,
GripperControl, LightControlMsg, MotionState, RemoteControllerState, RobotProcessStateMsg,
Expand All @@ -21,7 +23,7 @@ use typed_builder::TypedBuilder;
// The controller may send an intermediate pending status (-1) before the
// final success response. Mode transitions (especially PREPARE) can take
// several seconds.
const CHANGE_MODE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
const CHANGE_MODE_TIMEOUT: Duration = Duration::from_secs(30);

/// High-level client for B1 locomotion control and telemetry.
pub struct BoosterClient {
Expand All @@ -37,6 +39,11 @@ impl BoosterClient {
Self::with_options(RpcClientOptions::default())
}

/// Create a locomotion client with a custom startup wait before first RPC.
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
Self::with_options(RpcClientOptions::default().with_startup_wait(startup_wait))
}

/// Create a locomotion client with custom RPC options.
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
let rpc = RpcClient::new(options)?;
Expand Down
9 changes: 9 additions & 0 deletions booster_sdk/src/client/vision.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Vision service RPC client.

use std::time::Duration;

use serde::{Deserialize, Serialize};
use serde_json::Value;

Expand Down Expand Up @@ -59,6 +61,13 @@ impl VisionClient {
Self::with_options(RpcClientOptions::for_service(VISION_API_TOPIC))
}

/// Create a vision client with a custom startup wait before first RPC.
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
Self::with_options(
RpcClientOptions::for_service(VISION_API_TOPIC).with_startup_wait(startup_wait),
)
}

/// Create a vision client with custom RPC options.
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
let rpc = RpcClient::for_topic(options, VISION_API_TOPIC)?;
Expand Down
10 changes: 10 additions & 0 deletions booster_sdk/src/client/x5_camera.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! X5 camera control RPC client.

use std::time::Duration;

use serde::{Deserialize, Serialize};

use crate::dds::{RpcClient, RpcClientOptions, X5_CAMERA_CONTROL_API_TOPIC};
Expand Down Expand Up @@ -64,6 +66,14 @@ impl X5CameraClient {
Self::with_options(RpcClientOptions::for_service(X5_CAMERA_CONTROL_API_TOPIC))
}

/// Create an X5 camera client with a custom startup wait before first RPC.
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
Self::with_options(
RpcClientOptions::for_service(X5_CAMERA_CONTROL_API_TOPIC)
.with_startup_wait(startup_wait),
)
}

/// Create an X5 camera client with custom RPC options.
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
let rpc = RpcClient::for_topic(options, X5_CAMERA_CONTROL_API_TOPIC)?;
Expand Down
12 changes: 11 additions & 1 deletion booster_sdk/src/dds/qos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use rustdds::{
Duration, QosPolicies, QosPolicyBuilder,
policy::{History, Reliability},
policy::{Durability, History, Reliability},
};

pub fn qos_best_effort_keep_last(depth: i32) -> QosPolicies {
Expand All @@ -21,6 +21,16 @@ pub fn qos_reliable_keep_last(depth: i32) -> QosPolicies {
.build()
}

pub fn qos_reliable_transient_local_keep_last(depth: i32) -> QosPolicies {
QosPolicyBuilder::new()
.durability(Durability::TransientLocal)
.reliability(Reliability::Reliable {
max_blocking_time: Duration::from_millis(100),
})
.history(History::KeepLast { depth })
.build()
}

pub fn qos_reliable_keep_all() -> QosPolicies {
QosPolicyBuilder::new()
.reliability(Reliability::Reliable {
Expand Down
Loading