Skip to main content

Robotic Tools

Robotic tools is a library made to make some calculations easier, like robots forward kinematic's and dynamics. There is also an numerical implementation of inverse velocity kinematic's.

You can use this lib for any robot, since you have the Denavit Hartenberg parameters.

Forward Kinematics

in order to use the forward kinematics, you gonna need the robot DH parameters. Then u can create a 'Link' object representation for each link, using the parameters.

import sympy as sp
from lib.link import Link

q1, q2, q3 = sp.symbols('q_1 q_2 q_3')

j0 = Link([q1, 450, 150, sp.pi / 2])
j1 = Link([q2, 0, 590, 0])
j2 = Link([q3, 0, 130, sp.pi / 2])

Finally create an instance of the ForwardKinematic class, and pass a list with all links in the constructor. You can also pass an offset with the angles of home position.

from lib.forward_kinematics import ForwardKinematic

fk = ForwardKinematic([j0, j1, j2], offset=np.array([.0, .0, .0]))

The ForwardKinematic class contains the symbolic matrices of transformations, like transformations from the reference frame to the i-th frame, the end-effector transformation matrix, the jacobian matrix, and other things.

Inverse Kinematics

To use the inverse kinematics u need first to have the ForwardKinematic of the robot

Inverse Kinematics of Position

The inverse kinematics of position uses the Gradient Descent method to find an optimal solution for the end-effector position.

To use it, as said before, u need the ForwardKinematic. Then, just import the ik_position method from lib.inverse_kinematics package

import numpy as np
from lib.inverse_kinematics import ik_position

# PX, Py, Pz
desired_position = np.array([.1, .4, .0])

thetas, _, success = ik_position(
  desired_position=desired_position,
  fk=fk,
  initial_guess=np.array([.2, .7, -.1]),
  f_tolerance=1e-5,
  max_iterations=1000,
  lmbd=.1,
  verbose=True
)

Output example of the inverse kinematics of position: position ik

Inverse Kinematics of Position and Orientation

The inverse kinematics of position and orientation uses the jacobian matrix and end-effector velocities necessary to achive an wanted transformation. This method is also called inverse velocity kinematics. The end-effector velocities mentioned before are calculated using the methods explained in Modern Robotics Book (http://hades.mech.northwestern.edu/index.php/Modern_Robotics).

import numpy as np
from lib.inverse_kinematics import ik

# Px, Py, Pz, Rx, Ry, Rz
desired_transformation = np.array([.1, .4, .0, 0, np.pi / 4, 0])

thetas, _, success = ik(
  desired_transformation=desired_transformation,
  fk=fk,
  initial_guess=np.array([.2, .7, -.1]),
  epsilon_wb=1e-5,
  epsilon_vb=1e-5,
  max_iterations=1000,
  lmbd=.1,
  verbose=True,
  only_position=False,
  normalize=False
)

Output example for the inverse kinematics of position and orientation position ik

Forward Dynamics

In order to compute the ForwardDynamics u first need the ForwardKinematic of the robot. When u instantiate the ForwardDynamic class, it will start to calculate the equations of motion (resulting torque's) in each link, so it can take a long time if you use the simplify method of sympy library.

The joint variables (thetas) need to be functions of time.

from lib.symbols import t
import sympy as sp

from lib.forward_kinematics import ForwardKinematic
from lib.forward_dynamics import ForwardDynamics
from lib.link import Link

# To use the forward dynamics, the q's need to be functions of time

q1 = sp.Function('q_1')(t)
q2 = sp.Function('q_2')(t)
a1, a2 = sp.symbols('a_1 a_2')

j0 = Link([q1, 0, a1, 0])
j1 = Link([q2, 0, a2, 0])

rr_fk = ForwardKinematic([j0, j1])

fd = ForwardDynamics(rr_fk)
for eq in fd.equations:
  print(' ')
  sp.print_latex(sp.simplify(eq))
  print(' ')

Example of forward dynamic equations of an RR planar robot tau 1 tau 2

Metadata

Release files for rtb-toolbox 0.1.67

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rtb-toolbox 0.1.67
File Size Uploaded
rtb_toolbox-0.1.67.tar.gz 529.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rtb-toolbox 0.1.67
File Interpreter ABI Platform
rtb_toolbox-0.1.67-py3-none-any.whl Python 3 none any Details

Total release size: 1.0 MB

Release files / rtb_toolbox-0.1.67.tar.gz

Download URL rtb_toolbox-0.1.67.tar.gz
Size 529.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5e0850ec4e2280dda025557d3c7ffbcb6c2533eb82659ef4566a602ce44c5884
BLAKE2b-256 checksum
How to use checksums
e0f6711b401e23f640603062f0eb23eeea31c6e2c3c44771686a3b26b7a273da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.2.6-76060206-generic

Release files / rtb_toolbox-0.1.67-py3-none-any.whl

Download URL rtb_toolbox-0.1.67-py3-none-any.whl
Size 520.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fb825b829b9fecf2afe55b0dfe1a7fc9b390f74d9baf23f10a3468caa86ad18
BLAKE2b-256 checksum
How to use checksums
b943f350c59d1408134d31be6e27148bb3e87e5c5cad17c37ae687f631fb3c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.2.6-76060206-generic

Release history Release notifications | RSS feed

This release

0.1.67 This release

2 release files

0.1.66

2 release files

0.1.65

2 release files

0.1.64

2 release files

0.1.63

2 release files

0.1.62

2 release files

0.1.61

2 release files

0.1.59

2 release files

0.1.58

2 release files

0.1.57

2 release files

0.1.56

2 release files

0.1.55

2 release files

0.1.54

2 release files

0.1.53

2 release files

0.1.52

2 release files

0.1.51

2 release files

0.1.49

2 release files

0.1.48

2 release files

0.1.47

2 release files

0.1.46

2 release files

0.1.45

2 release files

0.1.44

2 release files

0.1.43

2 release files

0.1.42

2 release files

0.1.41

2 release files

0.1.40

2 release files

0.1.39

2 release files

0.1.38

2 release files

0.1.37

2 release files

0.1.36

2 release files

0.1.35

2 release files

0.1.34

2 release files

0.1.32

2 release files

0.1.31

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page