Skip to main content

No project description provided

Project description

Python Industrial Robots

This is an experimental set of python bindings for the also-experimental Industrial Robots library written in Rust.

This is a proof-of-concept for some simple tools related to generating and predicting motion and planning for industrial robots. Currently, it is only wrapping a forward and inverse kinematics solver for the Fanuc LR Mate 200iD, a small, prolific industrial robot arm. The solver itself uses the K library for kinematics, with the robot model painstakingly verified against the R30iB controller's handling of joints and the J2/J3 interaction so that values put into the model matching the controller will produce the same pose and format that the actual controller will report.

In the longer term, if the underlying Rust library proves to be useful, I will likely expand it to perform some amount of motion planning and collision detection and leave it open for others to add robots, and will update these bindings to match as many features as possible.

Simple Use

import numpy
from py_industrial_robots import fanuc_fk, fanuc_ik

# Forward Kinematics
# =============================================

# Specify the joint angles in degrees exactly as they would go into the R30iB
poses = fanuc_fk([0.0, 0.0, 0.0, 0.0, 0.0, 0.0])

The result is a list of six poses, one for each joint. The poses themselves are in the form of lists 16 elements long, representing a 4x4 matrix in row-major order. The last pose is the pose of the robot flange and will match what the controller reports when set to an empty tool frame. The other poses will have origins which lie on the X-Z plane on the axis of the joint, but the orientation of the poses will match the world coordinate system when the robot is at its zero position.

Physical distance units are in millimeters, as that's what the robot itself uses.

Poses can be converted to numpy matrices as follows:

for i, pose in enumerate(poses):
    mat = numpy.matrix(pose).reshape(4, 4)
    print(f"Joint {i} pose:\n{mat}\n")

Inverse kinematics can be performed by passing a pose (in the same list-based, row-major format as they are received) and a list of initial joint angles to the fanuc_ik function. The underlying solver uses a Jacobian based approach. The function will throw an exception if the solver does not find a result. The result will be a list of six joint values in degrees as they would be sent to the R30iB controller.

current_joints = [20.0, 30.0, -10.0, 15.0, 90.0, 12.0]
poses = fanuc_fk(current_joints)

# Get the pose of the robot flange and turn it into a numpy matrix
end_pose = numpy.matrix(poses[-1]).reshape(4, 4)

# Build a transform that moves the current position by x=10, y=20, z=30
transform = numpy.identity(4)
transform[:3, 3] = [10.0, 20.0, 30.0]

# Generate a new desired target pose
target_pose = transform * end_pose

# Convert into the list-based, row-major format
target = list(target_pose.flat)

# Run the IK solver
new_joints = fanuc_ik(target, current_joints)

Note: I currently use lists to move numbers back and forth across the boundary of Python and the compiled Rust binaries because I have yet to figure out how to use the Rust numpy package to create native numpy arrays.

Building

The goal is to be able to cross compile libraries for x86_64 Windows and Linux in a Linux based build environment. I've managed to do that locally with the following.

Prerequisites

  • The Rust toolchain must be installed first
  • MinGW-w64 must be installed. On Debian based systems this is the mingw-w64 package.
  • llvm must be installed, on Debian based systems this is the llvm package.
  • The Windows target must be added to the Rust toolchain. This can be done with rustup target add x86_64-pc-windows-msvc. There is a -gnu version as well, but the default Python Windows binaries are built with MSVC.
  • Python must be installed and maturin must be installed into the Python environment. This can be done with pip install maturin.

Example on Debian/Ubuntu build environment:

sudo apt-get install mingw-w64 llvm curl python3 python3-pip 
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add x86_64-pc-windows-msvc

# Install maturin into the Python environment, if you're not in a container you 
probably want to do this in a virtualenv 
pip3 install maturin

Building

# Build for Linux
maturin build --release --strip

# Build for Windows
maturin build --release --strip --target x86_64-pc-windows-msvc

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

industrial_robots-0.2.2.tar.gz (574.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

industrial_robots-0.2.2-cp38-abi3-win_amd64.whl (888.8 kB view details)

Uploaded CPython 3.8+Windows x86-64

industrial_robots-0.2.2-cp38-abi3-manylinux_2_38_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.38+ x86-64

industrial_robots-0.2.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (887.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

industrial_robots-0.2.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (879.5 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

industrial_robots-0.2.2-cp38-abi3-macosx_11_0_arm64.whl (851.9 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

industrial_robots-0.2.2-cp38-abi3-macosx_10_12_x86_64.whl (858.2 kB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file industrial_robots-0.2.2.tar.gz.

File metadata

  • Download URL: industrial_robots-0.2.2.tar.gz
  • Upload date:
  • Size: 574.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.3

File hashes

Hashes for industrial_robots-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0def7547cf363b46da74d8ee0e055258d9be0cda42ba5035dc2b55403f8ddccd
MD5 0708a899eae8372096e49a1bd5f5514c
BLAKE2b-256 3d46456f349e6643ce632093d7b3bfbe1817efd40138302ffda992abf44b1ab2

See more details on using hashes here.

File details

Details for the file industrial_robots-0.2.2-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for industrial_robots-0.2.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f4554bee88ad94949bb22f879db637f9e9a84f84d9ee5cf75d2ab9ad31400350
MD5 2584ed1a012a494355c072e3dd226159
BLAKE2b-256 c147e3207239d5ce63d87a468ac4f16a591a2b7f952cf462457a15fa780c36e7

See more details on using hashes here.

File details

Details for the file industrial_robots-0.2.2-cp38-abi3-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for industrial_robots-0.2.2-cp38-abi3-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 cbc8645658b533c61c93c1510fcd2173bef28a5a1305bb42b5d7f3befed1f035
MD5 f5930703bbb2762df0ea9009d056ba84
BLAKE2b-256 77895ced62bb306028c408ef0c35ad29c007a83f17c096b506d0941c116cae44

See more details on using hashes here.

File details

Details for the file industrial_robots-0.2.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for industrial_robots-0.2.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d3c7be4f0b78564c833247ce90d70677a932bc8c7982a0ed6566a2fe5b23e260
MD5 2d1d3d37839aa0014d37b92aadf828aa
BLAKE2b-256 4cdb3b1757d22739263b297e5ee4b9a4e157afc9a6ac75bce72ab6e69b97ddbd

See more details on using hashes here.

File details

Details for the file industrial_robots-0.2.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for industrial_robots-0.2.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e6652fa56eadaceeaff4b150b528627af35d37e183db4040d625bf8fbdce4811
MD5 77f670e86ebfcd623d336e90472a692b
BLAKE2b-256 f5712752a451431bfe843f8d4ead3ba7ab51b1e1f866688a19d96ae04846a034

See more details on using hashes here.

File details

Details for the file industrial_robots-0.2.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for industrial_robots-0.2.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c07ac5f4ff51d120601b2ba738ffa5f6926293c79dc246f4efc9d1e41e8ac64a
MD5 6eec75dfc2c4c4c9394976d62022bf59
BLAKE2b-256 b08037e8d8f7d184a2d7f83c30eeb6d5a942bb3eec4973c56fc07b8c9cf24392

See more details on using hashes here.

File details

Details for the file industrial_robots-0.2.2-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for industrial_robots-0.2.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1026608b62a3bd1face29364528191189b159ef10fb701cf77b0e75606d7200d
MD5 e4cd71d218db894184be69d099214332
BLAKE2b-256 01ee018856296a0a13b7b9610bc74ead7cad7b69c1ceb2dc021b0d01c31dc7a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page