Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindlewis23 committed Jul 11, 2024
1 parent d753403 commit d81a137
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 66 deletions.
48 changes: 24 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ik_geo"
name = "ik-geo"
version = "1.0.2"
edition = "2021"

Expand Down
28 changes: 18 additions & 10 deletions ik_geo.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ from typing import List, Tuple, Annotated, Literal
import numpy as np
from numpy.typing import NDArray


class Robot:
"""
Representation of the robot for inverse kinematics
Representation of the robot for inverse kinematics.
Must construct with factory methods, default constructor raises NotImplementedError.
"""
def __init__(self) -> None:
"""
Invalid constructor, will raise a NotImplementedError
Use the factory methods instead.
"""
raise NotImplementedError("Initialize with factory methods")

def get_ik(
self,
Expand Down Expand Up @@ -96,7 +105,7 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...
pass

@classmethod
def spherical_two_parallel(
Expand All @@ -110,7 +119,7 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...
pass

@classmethod
def spherical(
Expand All @@ -124,7 +133,7 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...
pass

@classmethod
def three_parallel_two_intersecting(
Expand All @@ -138,7 +147,7 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...
pass

@classmethod
def three_parallel(
Expand All @@ -152,7 +161,7 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...
pass

@classmethod
def two_parallel(
Expand All @@ -166,7 +175,7 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...
pass

@classmethod
def two_intersecting(
Expand All @@ -180,7 +189,7 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...
pass

@classmethod
def gen_six_dof(
Expand All @@ -194,5 +203,4 @@ class Robot:
| Annotated[List[List[float]], [7, 3]]
),
) -> "Robot":
...

pass
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["maturin>=1.5,<2.0"]
build-backend = "maturin"

[project]
name = "ik_geo"
name = "ik-geo"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Rust",
Expand Down
38 changes: 8 additions & 30 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn pack_kinematics(h: [[f64; 3]; 6], p: [[f64; 3]; 7]) -> (Matrix3x6<f64>, Matri
}

// Create a class for the robot
#[pyclass()]
#[pyclass]
struct Robot {
robot: IKGeoRobot,
}
Expand All @@ -56,6 +56,13 @@ struct Robot {
// Implement the Robot class
#[pymethods]
impl Robot {
// No constructor, raise not implemented error
#[new]
fn new() -> PyResult<Self> {
Err(PyErr::new::<pyo3::exceptions::PyNotImplementedError, _>(
"No constructor for Robot class, use static factory methods instead",
))
}
// Get the inverse kinematics for the robot
// 2d array for the rotation matrix (row major), 3 values for translation vector
pub fn get_ik(
Expand Down Expand Up @@ -217,35 +224,6 @@ impl Robot {
}
}

// fn dummy_solver_hardcoded(_: &Matrix3<f64>, _: &Vector3<f64>) -> (Vec<Vector6<f64>>, Vec<bool>) {
// panic!("This function should never be called");
// }

// fn dummy_solver_general(
// _: &Matrix3<f64>,
// _: &Vector3<f64>,
// _: &Kinematics<6, 7>,
// ) -> (Vec<Vector6<f64>>, Vec<bool>) {
// panic!("This function should never be called");
// }

// // Unexposed method to call the correct ik solver
// fn call_ik_solver(
// robot: &mut Robot,
// rot_matrix: Matrix3<f64>,
// trans_vec: Vector3<f64>,
// ) -> (Vec<Vector6<f64>>, Vec<bool>) {
// if robot.is_hardcoded {
// (robot.hardcoded_solver)(&rot_matrix, &trans_vec)
// } else {
// // Make sure kinematics are set before calling the general solver
// if !robot.kin_set {
// panic!("Kinematics must be set before calling the general solver");
// }
// (robot.general_solver)(&rot_matrix, &trans_vec, &robot.kin)
// }
// }

/// A Python module implemented in Rust.
#[pymodule]
fn ik_geo(_py: Python, m: &PyModule) -> PyResult<()> {
Expand Down

0 comments on commit d81a137

Please sign in to comment.