From 1987b38959660b92e488268f66f84b01f070a7ba Mon Sep 17 00:00:00 2001 From: rise0chen Date: Wed, 7 Jun 2023 07:21:41 +0000 Subject: [PATCH] feat: pose_add --- src/lib.rs | 4 ++-- src/rpc/posture.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cb9476f..12a2f17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,8 +93,8 @@ pub mod lebai_sdk { } #[classmethod] #[cmod::tags(args(pose, frame, delta), ret)] - pub async fn pose_add(&self, pose: Pose, frame: CartesianPose, delta: CartesianPose) -> Result { - self.0.pose_add(pose, frame, delta).await + pub async fn pose_add(&self, pose: Pose, delta: CartesianPose, frame: Option) -> Result { + self.0.pose_add(pose, delta, frame).await } #[classmethod] #[cmod::tags(args(p), ret)] diff --git a/src/rpc/posture.rs b/src/rpc/posture.rs index 9fe08cb..f907a1c 100644 --- a/src/rpc/posture.rs +++ b/src/rpc/posture.rs @@ -1,7 +1,7 @@ use super::Robot; use cmod::Result; use proto::lebai::db::*; -use proto::lebai::posture::*; +use proto::lebai::posture::{self, *}; use proto::posture::{CartesianPose, JointPose, Pose}; impl Robot { @@ -26,15 +26,15 @@ impl Robot { let pose = self.c.get_pose_trans(Some(req)).await.map_err(|e| e.to_string())?; Ok(pose.into()) } - pub async fn pose_add(&self, pose: Pose, frame: CartesianPose, delta: CartesianPose) -> Result { - let delta = Pose::Cart(delta).into(); - let mut req = GetPoseAddRequest { + pub async fn pose_add(&self, pose: Pose, delta: CartesianPose, frame: Option) -> Result { + let mut delta: posture::Pose = Pose::Cart(delta).into(); + if let Some(frame) = frame { + delta.cart_frame = Some(frame.into()); + } + let req = GetPoseAddRequest { pose: Some(pose.into()), delta: Some(delta), }; - if let Some(delta) = &mut req.delta { - delta.cart_frame = Some(frame.into()); - } let pose = self.c.get_pose_add(Some(req)).await.map_err(|e| e.to_string())?; Ok(pose.into()) }