Skip to content

Commit

Permalink
GoalCurrentのモデルによるUnit変更を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
kaede committed Nov 24, 2023
1 parent cdf1859 commit 0f4c1ca
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/control_table.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#[cfg(any(feature = "xm430", feature = "xc330",))]
pub enum DynamixelModel{
XM430_W350,
XC330_T181,
}

#[allow(dead_code)]
pub enum ControlTable {
ModelNumber,
Expand Down Expand Up @@ -297,7 +301,7 @@ impl ControlTable {
}
}

pub fn to_unit(&self) -> f32 {
pub fn to_unit(&self, model: &DynamixelModel) -> f32 {
match self {
ControlTable::ModelNumber => 1.0,
ControlTable::ModelInformation => 1.0,
Expand Down Expand Up @@ -345,7 +349,12 @@ impl ControlTable {
ControlTable::Moving => 1.0,
ControlTable::MovingStatus => 1.0,
ControlTable::PresentPWM => 0.113,
ControlTable::PresentCurrent => 1.0,
ControlTable::PresentCurrent => {
match model{
DynamixelModel::XM430_W350 => 2.69,
DynamixelModel::XC330_T181 => 1.0,
}
},
ControlTable::PresentVelocity => 0.229,
ControlTable::PresentPosition => 1.0,
ControlTable::VelocityTrajectory => 0.229,
Expand Down Expand Up @@ -417,6 +426,6 @@ mod tests {
fn to_unit_xc330() {
let name = ControlTable::ModelNumber;
assert_eq!(name.to_unit(), 1.0);
assert_eq!(ControlTable::PresentPWM.to_unit(), 0.113);
assert_eq!(ControlTable::PresentPWM.to_unit(DynamixelModel::XC330_T181), 0.113);
}
}

0 comments on commit 0f4c1ca

Please sign in to comment.