diff --git a/src/tests/data/fanuc/fanuc_m16ib20_5dof.yaml b/src/tests/data/fanuc/fanuc_m16ib20_5dof.yaml new file mode 100644 index 0000000..327e830 --- /dev/null +++ b/src/tests/data/fanuc/fanuc_m16ib20_5dof.yaml @@ -0,0 +1,15 @@ +# +# Artificicial test data set, derived from Fanuc m16ib20 +# +opw_kinematics_geometric_parameters: + a1: 0.15 + a2: -0.10 + b: 0.0 + c1: 0.525 + c2: 0.77 + c3: 0.74 + c4: 0.10 + dof: 5 # 5 DOF robot +opw_kinematics_joint_offsets: [0, 0, deg(-90), 0, 0, deg(180)] +opw_kinematics_joint_sign_corrections: [1, 1, -1, -1, -1] # 5 members ok + diff --git a/src/tests/mod.rs b/src/tests/mod.rs index d1e2626..8ad4e61 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -4,3 +4,4 @@ mod constraint_test_various; mod urdf_extractor; mod tool_base_test; mod test_utils; +mod test_from_yaml; diff --git a/src/tests/test_from_yaml.rs b/src/tests/test_from_yaml.rs new file mode 100644 index 0000000..bca800f --- /dev/null +++ b/src/tests/test_from_yaml.rs @@ -0,0 +1,70 @@ + +#[cfg(test)] +mod tests { + use crate::parameters::opw_kinematics::Parameters; + + const READ_ERROR: &'static str = "Failed to load parameters from file"; + + #[test] + fn test_parameters_from_yaml() { + let filename = "src/tests/data/fanuc/fanuc_m16ib20.yaml"; + let loaded = + Parameters::from_yaml_file(filename).expect(READ_ERROR); + + let expected = Parameters { + a1: 0.15, + a2: -0.10, + b: 0.0, + c1: 0.525, + c2: 0.77, + c3: 0.74, + c4: 0.10, + offsets: [0.0, 0.0, -90.0_f64.to_radians(), 0.0, 0.0, 180.0_f64.to_radians()], + sign_corrections: [1, 1, -1, -1, -1, -1], + dof: 6, + }; + + + assert_eq!(expected.a1, loaded.a1); + assert_eq!(expected.a2, loaded.a2); + assert_eq!(expected.b, loaded.b); + assert_eq!(expected.c1, loaded.c1); + assert_eq!(expected.c2, loaded.c2); + assert_eq!(expected.c3, loaded.c3); + assert_eq!(expected.c4, loaded.c4); + assert_eq!(expected.offsets, loaded.offsets); + assert_eq!(expected.sign_corrections, loaded.sign_corrections); + } + + #[test] + fn test_parameters_from_yaml_5dof() { + let filename = "src/tests/data/fanuc/fanuc_m16ib20_5dof.yaml"; + let loaded = + Parameters::from_yaml_file(filename).expect(READ_ERROR); + + let expected = Parameters { + a1: 0.15, + a2: -0.10, + b: 0.0, + c1: 0.525, + c2: 0.77, + c3: 0.74, + c4: 0.10, + offsets: [0.0, 0.0, -90.0_f64.to_radians(), 0.0, 0.0, 180.0_f64.to_radians()], + sign_corrections: [1, 1, -1, -1, -1, 0], // Sign corrections last member 0 + dof: 5, // Degrees of freedom 5 + }; + + + assert_eq!(expected.a1, loaded.a1); + assert_eq!(expected.a2, loaded.a2); + assert_eq!(expected.b, loaded.b); + assert_eq!(expected.c1, loaded.c1); + assert_eq!(expected.c2, loaded.c2); + assert_eq!(expected.c3, loaded.c3); + assert_eq!(expected.c4, loaded.c4); + assert_eq!(expected.offsets, loaded.offsets); + assert_eq!(expected.sign_corrections, loaded.sign_corrections); + assert_eq!(expected.dof, loaded.dof); + } +} \ No newline at end of file diff --git a/src/tests/testcases.rs b/src/tests/testcases.rs index a68f236..b51ad28 100644 --- a/src/tests/testcases.rs +++ b/src/tests/testcases.rs @@ -285,34 +285,4 @@ mod tests { } } - #[test] - fn test_parameters_from_yaml() { - let filename = "src/tests/data/fanuc/fanuc_m16ib20.yaml"; - let loaded = - Parameters::from_yaml_file(filename).expect("Failed to load parameters from file"); - - let expected = Parameters { - a1: 0.15, - a2: -0.10, - b: 0.0, - c1: 0.525, - c2: 0.77, - c3: 0.74, - c4: 0.10, - offsets: [0.0, 0.0, -90.0_f64.to_radians(), 0.0, 0.0, 180.0_f64.to_radians()], - sign_corrections: [1, 1, -1, -1, -1, -1], - dof: 6, - }; - - - assert_eq!(expected.a1, loaded.a1); - assert_eq!(expected.a2, loaded.a2); - assert_eq!(expected.b, loaded.b); - assert_eq!(expected.c1, loaded.c1); - assert_eq!(expected.c2, loaded.c2); - assert_eq!(expected.c3, loaded.c3); - assert_eq!(expected.c4, loaded.c4); - assert_eq!(expected.offsets, loaded.offsets); - assert_eq!(expected.sign_corrections, loaded.sign_corrections); - } }