-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
104 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::lebai::kinematic; | ||
use crate::posture::{CartesianPose, JointPose}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct KinData { | ||
pub actual_joint_pose: JointPose, | ||
pub actual_joint_speed: JointPose, | ||
pub actual_joint_acc: JointPose, | ||
pub actual_joint_torque: JointPose, | ||
pub target_joint_pose: JointPose, | ||
pub target_joint_speed: JointPose, | ||
pub target_joint_acc: JointPose, | ||
pub target_joint_torque: JointPose, | ||
|
||
pub actual_tcp_pose: CartesianPose, | ||
pub target_tcp_pose: CartesianPose, | ||
|
||
pub actual_flange_pose: CartesianPose, | ||
} | ||
|
||
impl From<kinematic::KinData> for KinData { | ||
fn from(p: kinematic::KinData) -> Self { | ||
Self { | ||
actual_joint_pose: JointPose(p.actual_joint_pose), | ||
actual_joint_speed: JointPose(p.actual_joint_speed), | ||
actual_joint_acc: JointPose(p.actual_joint_acc), | ||
actual_joint_torque: JointPose(p.actual_joint_torque), | ||
target_joint_pose: JointPose(p.target_joint_pose), | ||
target_joint_speed: JointPose(p.target_joint_speed), | ||
target_joint_acc: JointPose(p.target_joint_acc), | ||
target_joint_torque: JointPose(p.target_joint_torque), | ||
|
||
actual_tcp_pose: p.actual_tcp_pose.unwrap_or_default().into(), | ||
target_tcp_pose: p.target_tcp_pose.unwrap_or_default().into(), | ||
|
||
actual_flange_pose: p.actual_flange_pose.unwrap_or_default().into(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod io; | ||
pub mod kinematic; | ||
pub mod led; | ||
pub mod modbus; | ||
pub mod posture; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use super::Robot; | ||
use cmod::Result; | ||
use proto::google::protobuf::Empty; | ||
use proto::kinematic::KinData; | ||
use proto::lebai::db::LoadRequest; | ||
use proto::lebai::kinematic::*; | ||
use proto::posture::CartesianPose; | ||
|
||
impl Robot { | ||
pub(crate) async fn load_tcp(&self, name: String, dir: Option<String>) -> Result<CartesianPose> { | ||
let req = LoadRequest { | ||
name, | ||
dir: dir.unwrap_or_default(), | ||
}; | ||
let resp = self.c.load_tcp(Some(req)).await.map_err(|e| e.to_string())?; | ||
Ok(resp.into()) | ||
} | ||
pub(crate) async fn set_tcp(&self, pose: CartesianPose) -> Result<()> { | ||
let _ = self.c.set_tcp(Some(pose.into())).await.map_err(|e| e.to_string())?; | ||
Ok(()) | ||
} | ||
pub(crate) async fn get_tcp(&self) -> Result<CartesianPose> { | ||
let resp = self.c.get_tcp(Some(Empty {})).await.map_err(|e| e.to_string())?; | ||
Ok(resp.into()) | ||
} | ||
pub(crate) async fn set_velocity_factor(&self, speed_factor: i32) -> Result<()> { | ||
let req = KinFactor { speed_factor }; | ||
let _ = self.c.set_kin_factor(Some(req)).await.map_err(|e| e.to_string())?; | ||
Ok(()) | ||
} | ||
pub(crate) async fn get_velocity_factor(&self) -> Result<i32> { | ||
let resp = self.c.get_kin_factor(Some(Empty {})).await.map_err(|e| e.to_string())?; | ||
Ok(resp.speed_factor) | ||
} | ||
pub(crate) async fn get_kin_data(&self) -> Result<KinData> { | ||
let resp = self.c.get_kin_data(Some(Empty {})).await.map_err(|e| e.to_string())?; | ||
Ok(resp.into()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
pub mod claw; | ||
pub mod dynamic; | ||
pub mod io; | ||
pub mod kinematic; | ||
pub mod led; | ||
pub mod modbus; | ||
pub mod motion; | ||
|