From d81a1378180186b01410ca9de63c717890a02bd4 Mon Sep 17 00:00:00 2001 From: Kevin Lewis Date: Thu, 11 Jul 2024 12:27:32 -0400 Subject: [PATCH] Minor tweaks --- Cargo.lock | 48 ++++++++++++++++++++++++------------------------ Cargo.toml | 2 +- ik_geo.pyi | 28 ++++++++++++++++++---------- pyproject.toml | 2 +- src/lib.rs | 38 ++++++++------------------------------ 5 files changed, 52 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6d579a2..f5d1faf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bytemuck" @@ -77,10 +77,10 @@ dependencies = [ ] [[package]] -name = "ik_geo" +name = "ik-geo" version = "1.0.2" dependencies = [ - "ik-geo", + "ik-geo 0.1.2", "pyo3", ] @@ -337,9 +337,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags", ] @@ -436,9 +436,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -452,48 +452,48 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/Cargo.toml b/Cargo.toml index 7c6bbee..917d881 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ik_geo" +name = "ik-geo" version = "1.0.2" edition = "2021" diff --git a/ik_geo.pyi b/ik_geo.pyi index 22fb8a3..0aecd76 100644 --- a/ik_geo.pyi +++ b/ik_geo.pyi @@ -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, @@ -96,7 +105,7 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... + pass @classmethod def spherical_two_parallel( @@ -110,7 +119,7 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... + pass @classmethod def spherical( @@ -124,7 +133,7 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... + pass @classmethod def three_parallel_two_intersecting( @@ -138,7 +147,7 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... + pass @classmethod def three_parallel( @@ -152,7 +161,7 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... + pass @classmethod def two_parallel( @@ -166,7 +175,7 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... + pass @classmethod def two_intersecting( @@ -180,7 +189,7 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... + pass @classmethod def gen_six_dof( @@ -194,5 +203,4 @@ class Robot: | Annotated[List[List[float]], [7, 3]] ), ) -> "Robot": - ... - + pass diff --git a/pyproject.toml b/pyproject.toml index 8f8c50a..19a5842 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/src/lib.rs b/src/lib.rs index 619e2c9..c7e91cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ fn pack_kinematics(h: [[f64; 3]; 6], p: [[f64; 3]; 7]) -> (Matrix3x6, Matri } // Create a class for the robot -#[pyclass()] +#[pyclass] struct Robot { robot: IKGeoRobot, } @@ -56,6 +56,13 @@ struct Robot { // Implement the Robot class #[pymethods] impl Robot { + // No constructor, raise not implemented error + #[new] + fn new() -> PyResult { + Err(PyErr::new::( + "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( @@ -217,35 +224,6 @@ impl Robot { } } -// fn dummy_solver_hardcoded(_: &Matrix3, _: &Vector3) -> (Vec>, Vec) { -// panic!("This function should never be called"); -// } - -// fn dummy_solver_general( -// _: &Matrix3, -// _: &Vector3, -// _: &Kinematics<6, 7>, -// ) -> (Vec>, Vec) { -// 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, -// trans_vec: Vector3, -// ) -> (Vec>, Vec) { -// 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<()> {