piper_protocol/
constants.rs1pub const GRIPPER_POSITION_SCALE: f64 = 100.0;
9
10pub const GRIPPER_FORCE_SCALE: f64 = 10.0;
14
15pub use crate::ids::{
17 ID_CONTROL_MODE, ID_EMERGENCY_STOP, ID_GRIPPER_CONTROL, ID_JOINT_CONTROL_12,
18 ID_JOINT_CONTROL_34, ID_JOINT_CONTROL_56, ID_MIT_CONTROL_BASE, ID_MOTOR_ENABLE,
19};
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn test_gripper_normalization() {
27 assert_eq!(GRIPPER_POSITION_SCALE, 100.0);
29 assert_eq!(GRIPPER_FORCE_SCALE, 10.0);
30
31 let travel_mm = 50.0;
33 let normalized = travel_mm / GRIPPER_POSITION_SCALE;
34 assert_eq!(normalized, 0.5);
35
36 let torque_nm = 5.0;
37 let normalized = torque_nm / GRIPPER_FORCE_SCALE;
38 assert_eq!(normalized, 0.5);
39 }
40
41 #[test]
42 fn test_can_id_constants() {
43 assert_eq!(ID_MOTOR_ENABLE, 0x471);
45 assert_eq!(ID_MIT_CONTROL_BASE, 0x15A);
46 assert_eq!(ID_JOINT_CONTROL_12, 0x155);
47 assert_eq!(ID_JOINT_CONTROL_34, 0x156);
48 assert_eq!(ID_JOINT_CONTROL_56, 0x157);
49 assert_eq!(ID_CONTROL_MODE, 0x151);
50 assert_eq!(ID_EMERGENCY_STOP, 0x150);
51 assert_eq!(ID_GRIPPER_CONTROL, 0x159);
52 }
53}