Skip to content

Commit

Permalink
Additional 5DOF tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bourumir-wyngs committed Oct 6, 2024
1 parent 0071432 commit 92173e7
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 30 deletions.
15 changes: 15 additions & 0 deletions src/tests/data/fanuc/fanuc_m16ib20_5dof.yaml
Original file line number Diff line number Diff line change
@@ -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

1 change: 1 addition & 0 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ mod constraint_test_various;
mod urdf_extractor;
mod tool_base_test;
mod test_utils;
mod test_from_yaml;
70 changes: 70 additions & 0 deletions src/tests/test_from_yaml.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
30 changes: 0 additions & 30 deletions src/tests/testcases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 92173e7

Please sign in to comment.