diff --git a/Cargo.lock b/Cargo.lock index aebfa39..6c96df6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -705,7 +705,7 @@ dependencies = [ [[package]] name = "lebai-proto" -version = "3.1.4" +version = "3.1.5" dependencies = [ "jsonrpsee", "pbjson", @@ -720,7 +720,7 @@ dependencies = [ [[package]] name = "lebai_sdk" -version = "0.2.13" +version = "0.2.14" dependencies = [ "async-lock", "cmod", diff --git a/Cargo.toml b/Cargo.toml index fd5bb02..e8ee8ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = [ diff --git a/proto/Cargo.toml b/proto/Cargo.toml index a1830f7..5f54529 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -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"]} diff --git a/proto/lebai-proto b/proto/lebai-proto index 20ef8db..f10a596 160000 --- a/proto/lebai-proto +++ b/proto/lebai-proto @@ -1 +1 @@ -Subproject commit 20ef8db48754df9488ac36b19a2c481b9c04bc34 +Subproject commit f10a596a99350ac550af64a52056545d76b9244a diff --git a/src/lib.rs b/src/lib.rs index 248bf81..9229c5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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, dir: Option) -> Result<()> { - self.0.save_pose(name, pose, dir).await + #[cmod::tags(args(pose, refer))] + pub async fn save_pose(&self, name: String, pose: Option, dir: Option, refer: Option) -> Result<()> { + self.0.save_pose(name, pose, dir,refer).await } #[classmethod] #[cmod::tags(ret)] - pub async fn load_pose(&self, name: String, dir: Option) -> Result> { + pub async fn load_pose(&self, name: String, dir: Option) -> Result> { self.0.load_pose(name, dir).await } #[classmethod] diff --git a/src/rpc/posture.rs b/src/rpc/posture.rs index 618f2df..2565614 100644 --- a/src/rpc/posture.rs +++ b/src/rpc/posture.rs @@ -44,29 +44,35 @@ impl Robot { Ok(pose.into()) } - pub async fn save_pose(&self, name: String, pose: Option, dir: Option) -> Result<()> { + pub async fn save_pose(&self, name: String, pose: Option, dir: Option, refer: Option) -> 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) -> Result> { + pub async fn load_pose(&self, name: String, dir: Option) -> Result> { 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) }