-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
1,629 additions
and
93 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "rs-opw-kinematics" | ||
version = "1.2.1" | ||
version = "1.3.0" | ||
edition = "2021" | ||
authors = ["Bourumir Wyngs <[email protected]>"] | ||
description = "Inverse and forward kinematics for 6 axis robots with a parallel base and spherical wrist." | ||
|
@@ -29,7 +29,7 @@ default = ["allow_filesystem"] | |
allow_filesystem = ["yaml-rust2", "sxd-document", "regex", "clap"] | ||
|
||
# To disable filesystem: | ||
#rs-opw-kinematics = { version = "1.2.1", default-features = false } | ||
#rs-opw-kinematics = { version = "1.3.0", default-features = false } | ||
|
||
[dev-dependencies] | ||
rand = "0.8.5" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use rs_opw_kinematics::kinematic_traits::{Joints, Kinematics, Pose, JOINTS_AT_ZERO}; | ||
use rs_opw_kinematics::kinematics_impl::OPWKinematics; | ||
use rs_opw_kinematics::parameters::opw_kinematics::Parameters; | ||
use rs_opw_kinematics::utils::{dump_joints, dump_solutions}; | ||
|
||
fn main() { | ||
let robot = OPWKinematics::new(Parameters::irb2400_10()); | ||
let joints: Joints = [0.0, 0.1, 0.2, 0.3, 0.0, 0.5]; // Joints are alias of [f64; 6] | ||
println!("Initial joints with singularity J5 = 0: "); | ||
dump_joints(&joints); | ||
|
||
println!("Solutions (original angle set is lacking due singularity there: "); | ||
let pose: Pose = robot.forward(&joints); // Pose is alias of nalgebra::Isometry3<f64> | ||
|
||
let solutions = robot.inverse(&pose); // Solutions is alias of Vec<Joints> | ||
dump_solutions(&solutions); | ||
|
||
println!("Solutions assuming we continue from somewhere close. The 'lost solution' returns"); | ||
let when_continuing_from: [f64; 6] = [0.0, 0.11, 0.22, 0.3, 0.1, 0.5]; | ||
let solutions = robot.inverse_continuing(&pose, &when_continuing_from); | ||
dump_solutions(&solutions); | ||
|
||
println!("Same pose, all J4+J6 rotation assumed to be previously concentrated on J4 only"); | ||
let when_continuing_from_j6_0: [f64; 6] = [0.0, 0.11, 0.22, 0.8, 0.1, 0.0]; | ||
let solutions = robot.inverse_continuing(&pose, &when_continuing_from_j6_0); | ||
dump_solutions(&solutions); | ||
|
||
println!("If we do not have the previous position, we can assume we want J4, J6 close to 0.0 \ | ||
The solution appears and the needed rotation is now equally distributed between J4 and J6."); | ||
let solutions = robot.inverse_continuing(&pose, &JOINTS_AT_ZERO); | ||
dump_solutions(&solutions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use std::f64::consts::PI; | ||
use rs_opw_kinematics::kinematic_traits::{Joints, Kinematics, Pose, CONSTRAINT_CENTERED}; | ||
use rs_opw_kinematics::kinematics_impl::OPWKinematics; | ||
use rs_opw_kinematics::parameters::opw_kinematics::Parameters; | ||
use rs_opw_kinematics::utils::{dump_solutions}; | ||
use rs_opw_kinematics::constraints::{BY_CONSTRAINS, BY_PREV, Constraints}; | ||
|
||
fn main() { | ||
let robot = OPWKinematics::new_with_constraints( | ||
Parameters::irb2400_10(), Constraints::new( | ||
[-0.1, 0.0, 0.0, 0.0, -PI, -PI], | ||
[PI, PI, 2.0 * PI, PI, PI, PI], | ||
BY_PREV, | ||
)); | ||
|
||
let joints: Joints = [0.0, 0.1, 0.2, 0.3, 0.0, 0.5]; // Joints are alias of [f64; 6] | ||
let when_continuing_from_j6_0: [f64; 6] = [0.0, 0.11, 0.22, 0.8, 0.1, 0.0]; | ||
|
||
let pose: Pose = robot.forward(&joints); // Pose is alias of nalgebra::Isometry3<f64> | ||
|
||
println!("If we do not have the previous pose yet, we can now ask to prever the pose \ | ||
closer to the center of constraints."); | ||
let solutions = robot.inverse_continuing(&pose, &CONSTRAINT_CENTERED); | ||
dump_solutions(&solutions); | ||
|
||
println!("With constraints, sorted by proximity to the previous pose"); | ||
let solutions = robot.inverse_continuing(&pose, &when_continuing_from_j6_0); | ||
dump_solutions(&solutions); | ||
|
||
let robot = OPWKinematics::new_with_constraints( | ||
Parameters::irb2400_10(), Constraints::new( | ||
[-0.1, 0.0, 0.0, 0.0, -PI, -PI], | ||
[PI, PI, 2.0 * PI, PI, PI, PI], | ||
BY_CONSTRAINS, | ||
)); | ||
println!("With constraints, sorted by proximity to the center of constraints"); | ||
let solutions = robot.inverse_continuing(&pose, &when_continuing_from_j6_0); | ||
dump_solutions(&solutions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use std::f64::consts::PI; | ||
use std::sync::Arc; | ||
use nalgebra::{Isometry3, Translation3, UnitQuaternion, Vector3}; | ||
use rs_opw_kinematics::kinematic_traits::{Joints, Kinematics, Pose}; | ||
use rs_opw_kinematics::kinematics_impl::OPWKinematics; | ||
use rs_opw_kinematics::parameters::opw_kinematics::Parameters; | ||
use rs_opw_kinematics::constraints::{BY_CONSTRAINS, Constraints}; | ||
|
||
fn main() { | ||
let robot = OPWKinematics::new_with_constraints( | ||
Parameters::irb2400_10(), Constraints::new( | ||
[-0.1, 0.0, 0.0, 0.0, -PI, -PI], | ||
[PI, PI, 2.0 * PI, PI, PI, PI], | ||
BY_CONSTRAINS, | ||
)); | ||
|
||
let joints: Joints = [0.0, 0.1, 0.2, 0.3, 0.0, 0.5]; // Joints are alias of [f64; 6] | ||
let jakobian = rs_opw_kinematics::jacobian::Jacobian::new(&robot, &joints, 1E-6); | ||
let desired_velocity_isometry = | ||
Isometry3::new(Vector3::new(0.0, 1.0, 0.0), | ||
Vector3::new(0.0, 0.0, 1.0)); | ||
let joint_velocities = jakobian.velocities(&desired_velocity_isometry); | ||
println!("Computed joint velocities: {:?}", joint_velocities.unwrap()); | ||
|
||
let desired_force_torque = | ||
Isometry3::new(Vector3::new(0.0, 0.0, 0.0), | ||
Vector3::new(0.0, 0.0, 1.234)); | ||
|
||
let joint_torques = jakobian.torques(&desired_force_torque); | ||
println!("Computed joint torques: {:?}", joint_torques); | ||
|
||
// Robot with the tool, standing on a base: | ||
let robot_alone = OPWKinematics::new(Parameters::staubli_tx2_160l()); | ||
|
||
// 1 meter high pedestal | ||
let pedestal = 0.5; | ||
let base_translation = Isometry3::from_parts( | ||
Translation3::new(0.0, 0.0, pedestal).into(), | ||
UnitQuaternion::identity(), | ||
); | ||
|
||
let robot_with_base = rs_opw_kinematics::tool::Base { | ||
robot: Arc::new(robot_alone), | ||
base: base_translation, | ||
}; | ||
|
||
// Tool extends 1 meter in the Z direction, envisioning something like sword | ||
let sword = 1.0; | ||
let tool_translation = Isometry3::from_parts( | ||
Translation3::new(0.0, 0.0, sword).into(), | ||
UnitQuaternion::identity(), | ||
); | ||
|
||
// Create the Tool instance with the transformation | ||
let robot_complete = rs_opw_kinematics::tool::Tool { | ||
robot: Arc::new(robot_with_base), | ||
tool: tool_translation, | ||
}; | ||
|
||
let tcp_pose: Pose = robot_complete.forward(&joints); | ||
println!("The sword tip is at: {:?}", tcp_pose); | ||
} |
Oops, something went wrong.