A flexible inverse kinematics solver that supports any number of servo motors in series
Project description
InfIK
A 3D inverse kinematics solver for robotic systems with any number of linked servo motors
Features
- Any number of joints are supported
- Each joint can be uniquely constrained in cartesian coordinate space along any axis
- The number of constraints equals the number of joints
- Each servo motor's axis can be aligned in any direction relative to the previous joint
- The solver can also predict the absolute location of any joint in the system if the position of each servo is known
Joints
All joints in a system can be modeled by the Joint object, which contains 5 fields (These fields are defined in the local space of the current joint, meaning they are independent of the other joints in the system):
alpha(const): The angle the rotation axis makes with the x-axis when projected onto the xy plane.beta(const): The angle the rotation axis makes with the xy plane.length(const): The length of this joint's lever arm, which is perpandicular to the rotation axis (the next joint orbits this joint)height(const): The distance along the rotation axis from the last joint (how much the rotation point should be offset along the axis)theta: The position of the servo, or the angular position around the rotation axisRed: The rotation axisBlue: The path traced by the next joint (end of arm) as it moves through a full rotationGreen: The armOrange: The local space of the next joint with the unit vectorsi,j, andkcorresponding to thex,y, andz-axis respectively
Local Joint Space
As mentioned, a joint is purely defined in its local space:
- The x-axis is collinear with the line connecting this joint with the previous one (along the length of the previous joint's lever arm)
- The z-axis is parallel to the rotation axis
- The y-axis is the cross product of the x and z axes, and will always face "forward" such that increasing the previous joint's position will move the current joint in the direction of the y-axis
Note that theta is relative to the xy plane, meaning if alpha,beta, and theta are 0, the arm will lie along the y-axis. Increasing alpha will rotate the arm counterclockwise around the z-axis, while beta will have no effect if theta is 0. Increasing theta will rotate the arm counterclockwise around its rotation axis.
Constraints
Constraints are simple and have 3 fields:
joint_index: The index of the joint to place this constraint onaxis: The cartesian axis to constrain (x:0,y:1,z:2)value: The constraint value; what value should the joint's global position have alongaxis? As mentioned, for the system to be solvable, the number of constraints must equal the number of joints
How to Use
- Import
IK_3D.pyand create anIKSystemobject to model the systemjoints: List of the joints in the system in the order they are connectedconstraints: Unordered list of constraints to be placed on the systemallowed_error(optional): The maximum allowed difference between two consecutive guesses (Default:1e-3)max_iterations(optional): The maximum number of iterations allowed before the solver concludes that it failed to converge (Default:100)- If this number is reached, the success flag returned from the
Solver.solve()method will beFalse
- If this number is reached, the success flag returned from the
- Solve the system by calling
Solver.solve(IKSystem)on anyIKSystemobject, which will return a list of servo positions in the same order as the joints in the system- These positions can also be accessed directly from
jointsin theIKSystemobject (Joint.theta)
- These positions can also be accessed directly from
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file infik-1.1.tar.gz.
File metadata
- Download URL: infik-1.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99b2914a006a06bfd6fa6bb26738268905fb04a751b10d5a766390e103962298
|
|
| MD5 |
819288e4aba1fc92934c3f3df97c62fe
|
|
| BLAKE2b-256 |
56811fcb0c740fecb0b7b50586498804354878ba9fd5def086e2e3543211f239
|
File details
Details for the file InfIK-1.1-py3-none-any.whl.
File metadata
- Download URL: InfIK-1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89c8fdf2a2269565690561024014e7f47008b08fa992a05e4dd84a21d3b09908
|
|
| MD5 |
ccde2ec1b8f28768fbb1ccd329dfc853
|
|
| BLAKE2b-256 |
57a94f5c1ec58ed48ad584f102697b5a34720e5e45290f4961b5b9df63d1dbe5
|