Skip to content

Commit

Permalink
add 00
Browse files Browse the repository at this point in the history
  • Loading branch information
WT-MM committed Oct 29, 2024
1 parent a808bc2 commit 02913fc
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
29 changes: 17 additions & 12 deletions actuator/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,23 @@ impl PartialEq for PyRobstrideMotorType {
#[pymethods]
impl PyRobstrideMotorType {
#[classattr]
const TYPE01: Self = PyRobstrideMotorType { value: 0 };
const TYPE00: Self = PyRobstrideMotorType { value: 0 };
#[classattr]
const TYPE02: Self = PyRobstrideMotorType { value: 1 };
const TYPE01: Self = PyRobstrideMotorType { value: 1 };
#[classattr]
const TYPE03: Self = PyRobstrideMotorType { value: 2 };
const TYPE02: Self = PyRobstrideMotorType { value: 2 };
#[classattr]
const TYPE04: Self = PyRobstrideMotorType { value: 3 };
const TYPE03: Self = PyRobstrideMotorType { value: 3 };
#[classattr]
const TYPE04: Self = PyRobstrideMotorType { value: 4 };

fn __repr__(&self) -> PyResult<String> {
let type_name = match self.value {
0 => "TYPE01",
1 => "TYPE02",
2 => "TYPE03",
3 => "TYPE04",
0 => "TYPE00",
1 => "TYPE01",
2 => "TYPE02",
3 => "TYPE03",
4 => "TYPE04",
_ => "Unknown",
};
Ok(format!("PyRobstrideMotorType::{}", type_name))
Expand Down Expand Up @@ -515,6 +518,7 @@ impl PyRobstrideMotorType {
impl From<RobstrideMotorType> for PyRobstrideMotorType {
fn from(motor_type: RobstrideMotorType) -> Self {
match motor_type {
RobstrideMotorType::Type00 => PyRobstrideMotorType::TYPE00,
RobstrideMotorType::Type01 => PyRobstrideMotorType::TYPE01,
RobstrideMotorType::Type02 => PyRobstrideMotorType::TYPE02,
RobstrideMotorType::Type03 => PyRobstrideMotorType::TYPE03,
Expand All @@ -526,10 +530,11 @@ impl From<RobstrideMotorType> for PyRobstrideMotorType {
impl From<PyRobstrideMotorType> for RobstrideMotorType {
fn from(py_motor_type: PyRobstrideMotorType) -> Self {
match py_motor_type.value {
0 => RobstrideMotorType::Type01,
1 => RobstrideMotorType::Type02,
2 => RobstrideMotorType::Type03,
3 => RobstrideMotorType::Type04,
0 => RobstrideMotorType::Type00,
1 => RobstrideMotorType::Type01,
2 => RobstrideMotorType::Type02,
3 => RobstrideMotorType::Type03,
4 => RobstrideMotorType::Type04,
_ => RobstrideMotorType::Type04,
}
}
Expand Down
25 changes: 22 additions & 3 deletions actuator/robstride/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ pub struct MotorConfig {
lazy_static! {
pub static ref ROBSTRIDE_CONFIGS: HashMap<MotorType, MotorConfig> = {
let mut m = HashMap::new();
m.insert(
MotorType::Type00,
MotorConfig {
p_min: -12.5,
p_max: 12.5,
v_min: -33.0,
v_max: 33.0,
kp_min: 0.0,
kp_max: 500.0,
kd_min: 0.0,
kd_max: 5.0,
t_min: -14.0,
t_max: 14.0,
zero_on_init: false,
can_timeout_command: 0x200b, // Unchecked
can_timeout_factor: 12000.0, // Unchecked
},
);
m.insert(
MotorType::Type01,
MotorConfig {
Expand All @@ -64,7 +82,6 @@ lazy_static! {
can_timeout_factor: 12000.0,
},
);
// This is probably not correct, the Type02 is not released yet.
m.insert(
MotorType::Type02,
MotorConfig {
Expand All @@ -79,8 +96,8 @@ lazy_static! {
t_min: -12.0,
t_max: 12.0,
zero_on_init: false,
can_timeout_command: 0x200b,
can_timeout_factor: 12000.0,
can_timeout_command: 0x200b, // Unchecked
can_timeout_factor: 12000.0, // Unchecked
},
);
m.insert(
Expand Down Expand Up @@ -387,6 +404,7 @@ fn unpack_raw_feedback(pack: &CanPack) -> MotorFeedbackRaw {

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MotorType {
Type00,
Type01,
Type02,
Type03,
Expand All @@ -408,6 +426,7 @@ pub fn motor_mode_from_str(s: &str) -> Result<MotorMode, std::io::Error> {

pub fn motor_type_from_str(s: &str) -> Result<MotorType, std::io::Error> {
match s {
"00" => Ok(MotorType::Type00),
"01" => Ok(MotorType::Type01),
"02" => Ok(MotorType::Type02),
"03" => Ok(MotorType::Type03),
Expand Down

0 comments on commit 02913fc

Please sign in to comment.