There are 2 mostly used kinematics in robotic field, they are : forward kinematics and inverse kinematics. Forward kinematics is frequently used to calculate the position of end effector when we know the degree value of each joint, meanwhile inverse kinematics is used to compute the degree of each joint when we know the position of the end effector.
To calculate forward kinematic, we can use simple trigonometry or denavit hartenberg parameter or screw theory . In this example we are going to use simple trigonometry to calculate 2d forward kinematics for 1 DOF and 3d forward kinematics for 3 DOF robotic arm.
Calculating 2D Forward Kinematics for 1 DOF robot arm
image.jpeg failed to upload
For example here we have 1 dof robotic arm. link length is 10 cm. θ is 45°. The position of end effector on our cartesian coordinate (x, y) can be calculated easily using simple trigonometry.
image.gif failed to upload
image.jpeg failed to upload
cos θ = x / l
x = cos θ * l = cos 45° * 10 cm
sin θ = y / l
y = sin θ * l = sin 45° * 10 cm
Here is python 2d 1 dof forward kinematic solver:
[code language="python"]
#!/usr/bin/env python3
'''
robotic forward kinematics solver
coded by Antonius Ringlayer
'''
import math
def solve_1dof_fk(_link, _degree):
try:
x = 0
y = 0
x = math.cos(math.radians(_degree)) * _link
y = math.sin(math.radians(_degree)) * _link
return x, y
except:
raise
x, y = solve_1dof_fk(10, 45)
print ("x=" + str(x) + " y=" + str(y))
[/code]
Result:
$ ./2d_1dof_forward_kinematic_solver.py
x=7.0710678118654755 y=7.071067811865475
Position of end effector = p(7.07 cm, 7.07 cm)
Calculating 3D Forward Kinematics for 3 DOF robot arm
Calculating the position of the end effector on 3 dimensional space using trigonometry is not so hard.
For example here we have 3 dof robot arm :
Side view of robot arm :
image.jpeg failed to upload
Where : d2 is the height of second dof towards the floor, z is another dimension that we add to our cartesian geometry (the height of end effector from the floor), l1 = length of link 1, l2 = length of link 2, θ2 is d2 joint value, θ3 is d3 joint value.