Skip to content

Commit 7592c40

Browse files
authored
Fix camera, light and AI/Lui RPC clients (#6)
1 parent bc4bed8 commit 7592c40

29 files changed

Lines changed: 1295 additions & 378 deletions

Cargo.lock

Lines changed: 3 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["booster_sdk", "booster_sdk_py"]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.1.0-alpha.8"
6+
version = "0.1.0-alpha.10"
77
edition = "2024"
88
authors = ["Team whIRLwind"]
99
license = "MIT OR Apache-2.0"

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ pip install booster-sdk
5454

5555
### Python API Example
5656

57-
Note: Python bindings are experimental.
58-
5957
```python
60-
from booster_sdk.client.booster import BoosterClient
61-
from booster_sdk.types import GripperCommand, Hand, RobotMode
58+
from booster_sdk.client.booster import BoosterClient, GripperCommand, Hand, RobotMode
6259

6360
client = BoosterClient()
6461

booster_sdk/src/client/ai.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! AI and LUI high-level RPC clients.
22
3+
use std::time::Duration;
4+
35
use serde::{Deserialize, Serialize};
46

57
use crate::dds::{
@@ -113,6 +115,11 @@ impl AiClient {
113115
Self::with_options(RpcClientOptions::for_service(AI_API_TOPIC))
114116
}
115117

118+
/// Create an AI client with a custom startup wait before first RPC.
119+
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))
121+
}
122+
116123
/// Create an AI client with custom RPC options.
117124
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
118125
let rpc = RpcClient::for_topic(options, AI_API_TOPIC)?;
@@ -166,6 +173,11 @@ impl LuiClient {
166173
Self::with_options(RpcClientOptions::for_service(LUI_API_TOPIC))
167174
}
168175

176+
/// Create a LUI client with a custom startup wait before first RPC.
177+
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))
179+
}
180+
169181
/// Create a LUI client with custom RPC options.
170182
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
171183
let rpc = RpcClient::for_topic(options, LUI_API_TOPIC)?;

booster_sdk/src/client/light_control.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! LED light control RPC client.
22
3+
use std::time::Duration;
4+
35
use serde::{Deserialize, Serialize};
46

57
use crate::dds::{LIGHT_CONTROL_API_TOPIC, RpcClient, RpcClientOptions};
@@ -49,6 +51,13 @@ impl LightControlClient {
4951
Self::with_options(RpcClientOptions::for_service(LIGHT_CONTROL_API_TOPIC))
5052
}
5153

54+
/// Create a light control client with a custom startup wait before first RPC.
55+
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
56+
Self::with_options(
57+
RpcClientOptions::for_service(LIGHT_CONTROL_API_TOPIC).with_startup_wait(startup_wait),
58+
)
59+
}
60+
5261
/// Create a light control client with custom RPC options.
5362
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
5463
let rpc = RpcClient::for_topic(options, LIGHT_CONTROL_API_TOPIC)?;

booster_sdk/src/client/loco.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! High-level B1 locomotion client built on DDS RPC and topic I/O.
22
3+
use std::time::Duration;
4+
35
use crate::dds::{
46
BatteryState, BinaryData, ButtonEventMsg, DdsNode, DdsPublisher, DdsSubscription,
57
GripperControl, LightControlMsg, MotionState, RemoteControllerState, RobotProcessStateMsg,
@@ -21,7 +23,7 @@ use typed_builder::TypedBuilder;
2123
// The controller may send an intermediate pending status (-1) before the
2224
// final success response. Mode transitions (especially PREPARE) can take
2325
// several seconds.
24-
const CHANGE_MODE_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
26+
const CHANGE_MODE_TIMEOUT: Duration = Duration::from_secs(30);
2527

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

42+
/// Create a locomotion client with a custom startup wait before first RPC.
43+
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
44+
Self::with_options(RpcClientOptions::default().with_startup_wait(startup_wait))
45+
}
46+
4047
/// Create a locomotion client with custom RPC options.
4148
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
4249
let rpc = RpcClient::new(options)?;

booster_sdk/src/client/vision.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Vision service RPC client.
22
3+
use std::time::Duration;
4+
35
use serde::{Deserialize, Serialize};
46
use serde_json::Value;
57

@@ -59,6 +61,13 @@ impl VisionClient {
5961
Self::with_options(RpcClientOptions::for_service(VISION_API_TOPIC))
6062
}
6163

64+
/// Create a vision client with a custom startup wait before first RPC.
65+
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
66+
Self::with_options(
67+
RpcClientOptions::for_service(VISION_API_TOPIC).with_startup_wait(startup_wait),
68+
)
69+
}
70+
6271
/// Create a vision client with custom RPC options.
6372
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
6473
let rpc = RpcClient::for_topic(options, VISION_API_TOPIC)?;

booster_sdk/src/client/x5_camera.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! X5 camera control RPC client.
22
3+
use std::time::Duration;
4+
35
use serde::{Deserialize, Serialize};
46

57
use crate::dds::{RpcClient, RpcClientOptions, X5_CAMERA_CONTROL_API_TOPIC};
@@ -64,6 +66,14 @@ impl X5CameraClient {
6466
Self::with_options(RpcClientOptions::for_service(X5_CAMERA_CONTROL_API_TOPIC))
6567
}
6668

69+
/// Create an X5 camera client with a custom startup wait before first RPC.
70+
pub fn with_startup_wait(startup_wait: Duration) -> Result<Self> {
71+
Self::with_options(
72+
RpcClientOptions::for_service(X5_CAMERA_CONTROL_API_TOPIC)
73+
.with_startup_wait(startup_wait),
74+
)
75+
}
76+
6777
/// Create an X5 camera client with custom RPC options.
6878
pub fn with_options(options: RpcClientOptions) -> Result<Self> {
6979
let rpc = RpcClient::for_topic(options, X5_CAMERA_CONTROL_API_TOPIC)?;

booster_sdk/src/dds/qos.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use rustdds::{
44
Duration, QosPolicies, QosPolicyBuilder,
5-
policy::{History, Reliability},
5+
policy::{Durability, History, Reliability},
66
};
77

88
pub fn qos_best_effort_keep_last(depth: i32) -> QosPolicies {
@@ -21,6 +21,16 @@ pub fn qos_reliable_keep_last(depth: i32) -> QosPolicies {
2121
.build()
2222
}
2323

24+
pub fn qos_reliable_transient_local_keep_last(depth: i32) -> QosPolicies {
25+
QosPolicyBuilder::new()
26+
.durability(Durability::TransientLocal)
27+
.reliability(Reliability::Reliable {
28+
max_blocking_time: Duration::from_millis(100),
29+
})
30+
.history(History::KeepLast { depth })
31+
.build()
32+
}
33+
2434
pub fn qos_reliable_keep_all() -> QosPolicies {
2535
QosPolicyBuilder::new()
2636
.reliability(Reliability::Reliable {

0 commit comments

Comments
 (0)