Skip to content

Commit

Permalink
feat: pose refer
Browse files Browse the repository at this point in the history
  • Loading branch information
rise0chen committed Mar 21, 2024
1 parent b44322a commit 7f80a13
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
4 changes: 2 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 @@ -5,7 +5,7 @@ edition = "2021"
license-file = "LICENSE"
name = "lebai_sdk"
repository = "https://github.com/lebai-robotics/lebai-sdk.rs"
version = "0.2.13"
version = "0.2.14"

[workspace]
members = [
Expand Down
2 changes: 1 addition & 1 deletion proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords = ["protobuf"]
license = "MIT"
name = "lebai-proto"
repository = "https://github.com/lebai-robotics/lebai-sdk.rs"
version = "3.1.4"
version = "3.1.5"

[dependencies]
jsonrpsee = {version = "0.21", features = ["client-core", "macros"]}
Expand Down
2 changes: 1 addition & 1 deletion proto/lebai-proto
Submodule lebai-proto updated 2 files
+6 −3 plugin.proto
+1 −1 posture.proto
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ pub mod lebai_sdk {
self.0.pose_inverse(p).await
}
#[classmethod]
#[cmod::tags(args(pose))]
pub async fn save_pose(&self, name: String, pose: Option<Pose>, dir: Option<String>) -> Result<()> {
self.0.save_pose(name, pose, dir).await
#[cmod::tags(args(pose, refer))]
pub async fn save_pose(&self, name: String, pose: Option<Pose>, dir: Option<String>, refer: Option<JointPose>) -> Result<()> {
self.0.save_pose(name, pose, dir,refer).await
}
#[classmethod]
#[cmod::tags(ret)]
pub async fn load_pose(&self, name: String, dir: Option<String>) -> Result<Option<Pose>> {
pub async fn load_pose(&self, name: String, dir: Option<String>) -> Result<Option<JointPose>> {
self.0.load_pose(name, dir).await
}
#[classmethod]
Expand Down
22 changes: 14 additions & 8 deletions src/rpc/posture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,35 @@ impl Robot {
Ok(pose.into())
}

pub async fn save_pose(&self, name: String, pose: Option<Pose>, dir: Option<String>) -> Result<()> {
pub async fn save_pose(&self, name: String, pose: Option<Pose>, dir: Option<String>, refer: Option<JointPose>) -> Result<()> {
let pose = pose.map(|x| {
let mut x: posture::Pose = x.into();
x.joint = refer.map(Into::into);
x
});
let req = SavePoseRequest {
name,
dir: dir.unwrap_or_default(),
data: pose.map(Into::into),
data: pose,
};
self.c.save_pose(Some(req)).await.map_err(|e| e.to_string())?;
Ok(())
}
pub async fn load_pose(&self, name: String, dir: Option<String>) -> Result<Option<Pose>> {
pub async fn load_pose(&self, name: String, dir: Option<String>) -> Result<Option<JointPose>> {
let req = LoadRequest {
name,
dir: dir.unwrap_or_default(),
};
let pose = self.c.load_pose(Some(req)).await.map_err(|e| e.to_string())?;
let mut pose = self.c.load_pose(Some(req)).await.map_err(|e| e.to_string())?;
let pose = match pose.kind() {
pose::Kind::Unknown => None,
pose::Kind::Cartesian => {
let req = PoseRequest { pose: Some(pose) };
let pose = self.c.get_forward_kin(Some(req)).await.map_err(|e| e.to_string())?;
Some(Pose::Cart(pose.into()))
let refer = pose.joint.take();
let req = GetInverseKinRequest { pose: Some(pose), refer };
let pose = self.c.get_inverse_kin(Some(req)).await.map_err(|e| e.to_string())?;
Some(pose.into())
}
pose::Kind::Joint => Some(Pose::Joint(pose.joint.unwrap_or_default().into())),
pose::Kind::Joint => Some(pose.joint.unwrap_or_default().into()),
};
Ok(pose)
}
Expand Down

0 comments on commit 7f80a13

Please sign in to comment.