Dokumentasi komprehensif matematika kinematika robot: transformasi koordinat, forward kinematics,
Jacobian, dan — dengan detail penuh — Inverse Kinematics menggunakan metode analitik dan numerik.
Dirancang untuk sistem robot industri, manipulator, dan penelitian lanjutan.
Kinematika robot adalah ilmu yang mempelajari gerak robot tanpa mempertimbangkan gaya atau torsi yang menyebabkan gerak tersebut. Kinematika berfokus pada hubungan geometrik antara konfigurasi joint dan posisi/orientasi end-effector di ruang Cartesian.
⚙️
Forward Kinematics (FK)
Diberikan sudut/posisi joint → tentukan posisi dan orientasi end-effector di dunia nyata.
🎯
Inverse Kinematics (IK)
Diberikan posisi/orientasi target → tentukan sudut joint yang harus dicapai robot.
📐
Velocity Kinematics
Hubungan antara kecepatan joint (joint velocity) dengan kecepatan end-effector via Jacobian.
🔗
Kinematic Chain
Serial linkage: serangkaian rigid link yang dihubungkan oleh revolute atau prismatic joint.
1.1 Derajat Kebebasan (DOF)
DOF (Degrees of Freedom) adalah jumlah variabel independen yang diperlukan untuk mendeskripsikan konfigurasi sistem.
Catatan penting: Robot dengan 6 DOF memiliki kemampuan untuk menempatkan end-effector di posisi (x,y,z) dan orientasi (roll,pitch,yaw) mana pun di dalam workspace-nya. Robot redundan memiliki DOF > 6.
1.2 Sistem Koordinat
Konvensi yang digunakan adalah sistem koordinat kanan (right-handed) sesuai standar ISO 9283:
FIG-01 ▸ Sistem Koordinat Kanan (Right-Handed Coordinate System)
02
Transformasi Koordinat & Rotasi
2.1 Matriks Rotasi 3D
Rotasi murni di ruang 3D direpresentasikan oleh matriks ortogonal 3×3 dengan determinan = +1. Tiga rotasi dasar:
J = ⎡ -L₁sin θ₁ - L₂sin(θ₁+θ₂) -L₂sin(θ₁+θ₂) ⎤
⎣ L₁cos θ₁ + L₂cos(θ₁+θ₂) L₂cos(θ₁+θ₂) ⎦
det(J) = L₁·L₂·sin θ₂Singularitas terjadi saat θ₂ = 0° atau 180° (arm fully extended/folded)
4.2 Singularitas
⚠️
Singularitas terjadi ketika rank(J) < 6 — Jacobian kehilangan rank. Robot kehilangan kemampuan bergerak dalam satu atau lebih arah. det(J) = 0 adalah kondisi singularitas. Harus dihindari dalam kontrol robot real-time.
Deteksi SingularitasCek: det(J) ≈ 0 → singularitas
Tiga jenis pada robot 6-DOF:
1. Wrist singularity : θ₅ = 0 (sumbu z₄ ∥ z₆)
2. Shoulder singularity: wrist center di atas/bawah joint 1
3. Elbow singularity : arm sepenuhnya ter-extend (θ₃ = 0/π)
Kondisi Number (manipulability):
μ = √(det(J·Jᵀ)) → besar = jauh dari singularitas
05
Inverse Kinematics ★ DETAIL LENGKAP
🎯 Apa itu Inverse Kinematics?
Inverse Kinematics (IK) adalah operasi kebalikan dari FK: diberikan pose end-effector yang diinginkan (posisi + orientasi), cari nilai joint angle q = [θ₁, θ₂, ..., θₙ] yang mencapai pose tersebut.
IK jauh lebih sulit dari FK karena: (1) solusi bisa tidak ada, (2) solusi bisa tidak unik (multiple solutions), (3) persamaan bersifat nonlinear dan transcendental, dan (4) tidak selalu ada bentuk closed-form.
5.1 Konsep, Tantangan, dan Klasifikasi
📊
Tidak Ada Solusi
Target berada di luar workspace robot, atau target memerlukan orientasi yang tidak bisa dicapai.
🔀
Multiple Solutions
Robot 6-DOF umumnya memiliki hingga 16 solusi berbeda untuk satu target pose.
∞
Infinite Solutions
Robot redundan (DOF > 6) memiliki infinitely many solutions — space null-space.
⚡
Real-time Constraint
Kontrol robot memerlukan IK dalam hitungan milidetik (<1ms untuk servo loop 1kHz).
Metode analitik menghasilkan persamaan eksplisit untuk setiap joint angle. Lebih cepat dari numerik tapi hanya tersedia untuk struktur robot tertentu.
✅
Pieper's Theorem: Closed-form IK selalu ada untuk robot 6-DOF jika: (1) 3 joint terakhir berpotongan di satu titik (spherical wrist), ATAU (2) 3 joint berurutan adalah prismatic. Sebagian besar robot industri mengikuti kondisi ini.
5.3 IK Analitik 2-DOF Planar — Langkah Demi Langkah
1
Setup Problem — Definisikan Target
Diberikan posisi target end-effector (px, py) dan panjang link L₁, L₂. Tujuan: cari θ₁ dan θ₂.
px² + py²
= (L₁cos θ₁ + L₂cos(θ₁+θ₂))² + (L₁sin θ₁ + L₂sin(θ₁+θ₂))²
Setelah ekspansi dan penyederhanaan identitas trigonometri:
px² + py² = L₁² + L₂² + 2·L₁·L₂·cos θ₂
Isolasi cos θ₂:
cos θ₂ = (px² + py² - L₁² - L₂²) / (2·L₁·L₂)
Definisikan: D = (px² + py² - L₁² - L₂²) / (2·L₁·L₂)
Kondisi solusi: |D| ≤ 1 → target dapat dicapai
|D| > 1 → target di luar workspace (NO SOLUTION)
Hitung θ₂:
θ₂ = atan2(±√(1 - D²), D)
+ → "elbow up" (konfigurasi siku di atas)
- → "elbow down" (konfigurasi siku di bawah)
3
Cari θ₁ — Decompose Angle
Dengan θ₂ sudah diketahui, gunakan persamaan (1) dan (2):
Definisikan:
k₁ = L₁ + L₂·cos θ₂
k₂ = L₂·sin θ₂
Persamaan (1) dan (2) menjadi:
px = k₁·cos θ₁ - k₂·sin θ₁ ... (1')
py = k₁·sin θ₁ + k₂·cos θ₁ ... (2')
Ini adalah sistem linear dalam cos θ₁ dan sin θ₁.
Selesaikan dengan rotasi sudut:
θ₁ = atan2(py, px) - atan2(k₂, k₁)atan2 diperlukan untuk mendapatkan sudut di quadrant yang tepat
Jangan gunakan atan biasa — kehilangan informasi tanda!
4
Dua Solusi Valid
Setiap target memiliki dua solusi (jika ada solusi):
Untuk robot 3-DOF planar, kita juga perlu mengontrol orientasi φ = θ₁ + θ₂ + θ₃:
1
Hitung Posisi "Wrist" (Joint 3)
Target: (px, py, φ_desired)
Link lengths: L₁, L₂, L₃
Hitung posisi sebelum link L₃ (wrist point):
pwx = px - L₃·cos(φ)
pwy = py - L₃·sin(φ)
Masalah kini tereduksi ke 2-DOF IK ke (pwx, pwy)!
Metode numerik mengiterasi dari konfigurasi awal menuju solusi. Lebih general dari analitik — berlaku untuk robot dengan struktur apa pun termasuk redundan.
Metode
Kecepatan
Akurasi
Singularitas
Use Case
Newton-Raphson
Cepat
Tinggi
Gagal
Far from singularity
Jacobian Pseudoinverse
Sedang
Tinggi
Degraded
Redundant robots
Damped Least Squares
Sedang
Baik
Robust
General purpose
CCD
Cepat
Sedang
OK
Real-time, games
FABRIK
Sangat Cepat
Baik
OK
Character animation
5.7 Newton-Raphson IK
Metode iteratif menggunakan linearisasi Jacobian untuk memperbaiki estimasi joint angle:
1
Definisikan Error Function
e(q) = x_desired - FK(q)
Dimana x_desired = [px, py, pz, ωx, ωy, ωz]ᵀ (6D task space)
Dan FK(q) = posisi + orientasi saat ini
Untuk orientasi, gunakan axis-angle error:
e_orient = R_desired ⊗ R_current⁻¹ → konversi ke axis-angle vector
2
Update Rule
Δq = J⁻¹ · e(q) (untuk n=6 robot square)
Iterasi:
q_{k+1} = q_k + α · Δq_k
α = step size (biasanya 0.1 - 1.0)
Lebih kecil α → lebih stabil, lebih lambat konvergen
3
Kondisi Berhenti
Stop jika:
‖e(q)‖ < ε_pos (misal: 0.001 meter)
AND
‖e_orient‖ < ε_rot (misal: 0.01 radian)
atau max_iterations tercapai (misal: 100 iter)
atau ‖Δq‖ < ε_joint (perubahan sangat kecil)
⚙ ALGORITMA — Newton-Raphson IK
function NewtonRaphsonIK(T_desired, q_init, max_iter, eps):
q ← q_init
for k = 1 to max_iter:
T_curr ← ForwardKinematics(q)
e_pos ← T_desired[0:3,3] - T_curr[0:3,3]
e_rot ← AxisAngleError(T_desired[0:3,0:3], T_curr[0:3,0:3])
e ← [e_pos; e_rot]
if norm(e) < eps:
return q, SUCCESS
J ← ComputeJacobian(q)
Δq ← inv(J) · e ← WARNING: J singular = fail
q ← q + α·Δq
q ← ClampToJointLimits(q)
return q, FAILED_MAX_ITER
5.8 Jacobian Pseudoinverse
Untuk robot non-square (DOF ≠ 6) atau robot redundan, gunakan Moore-Penrose pseudoinverse:
Pseudoinverse (J⁺)Kasus over-determined (m > n): lebih banyak equations dari unknowns
J⁺ = Jᵀ(JJᵀ)⁻¹ → minimum norm solution
Kasus under-determined (m < n): robot redundan, DOF > task dim
J⁺ = (JᵀJ)⁻¹Jᵀ → least squares solution
Update rule:
Δq = J⁺ · e + (I - J⁺J) · z
(I - J⁺J) = null-space projector
z = arbitrary vector → digunakan untuk secondary objectives:
- joint limit avoidance
- singularity avoidance
- manipulability maximization
5.9 Damped Least Squares (DLS) — Levenberg-Marquardt
Metode paling robust untuk IK numerik. Menambahkan damping factor λ untuk regularisasi di dekat singularitas:
1
Persamaan DLS
DLS Solution:
Δq = Jᵀ · (J·Jᵀ + λ²·I)⁻¹ · e
Equivalent to minimizing:
min ‖J·Δq - e‖² + λ²·‖Δq‖²
λ kecil → seperti pseudoinverse (akurat, tidak stabil di singularitas)
λ besar → pergerakan kecil, sangat stabil, konvergen lambatVariable damping (adaptive λ):
λ² = λ_max² · (1 - (μ/μ_max)²)
μ = manipulability = √det(JJᵀ)
Jauh dari singularitas: μ besar → λ kecil (akurat)
Dekat singularitas: μ kecil → λ besar (stabil)
2
Tuning Parameter λ
Pilih: λ_max ∈ [0.01, 0.1] (tergantung skala robot)
μ_max ≈ nilai manipulability arm fully extended
Rule of thumb untuk robot industri:
λ² = 0 jika μ > 0.1·μ_max
λ² = λ_max² · exp(-μ/0.05) otherwise
⚙ ALGORITMA — Damped Least Squares IK
function DLS_IK(T_desired, q_init, λ_max, max_iter, eps):
q ← q_init
for k = 1 to max_iter:
T_curr ← ForwardKinematics(q)
e ← TaskSpaceError(T_desired, T_curr)
if norm(e) < eps: return q, SUCCESS
J ← ComputeJacobian(q)
μ ← sqrt(det(J @ Jᵀ)) ← manipulability
λ² ← ComputeDamping(μ, λ_max)
Δq ← Jᵀ @ inv(J @ Jᵀ + λ²·I) @ e
q ← ClampJointLimits(q + α·Δq)
return q, NOT_CONVERGED
5.10 Cyclic Coordinate Descent (CCD)
Metode iteratif yang mengoptimasi satu joint pada satu waktu, berulang dari end-effector ke base:
1
Ide Dasar CCD
Untuk setiap joint i (dari ujung ke base), rotasikan joint i sehingga end-effector sedekat mungkin ke target:
Vektor dari joint i ke EE: v₁ = EE_pos - joint_i_pos
Vektor dari joint i ke target: v₂ = target_pos - joint_i_pos
Sudut rotasi optimal:
Δθᵢ = atan2(cross(v₁, v₂), dot(v₁, v₂))
Untuk 3D dengan sumbu rotasi:
axis = normalize(v₁ × v₂)
angle = acos(dot(v₁, v₂) / (‖v₁‖·‖v₂‖))
Δθᵢ diprojeksi ke sumbu joint
2
Loop CCD
CCD LOOP
for iter = 1 to max_iter:
for i = n-1 downto 0: ← dari joint terakhir ke base
v1 ← EE_pos(q) - joint_pos(i, q)
v2 ← target_pos - joint_pos(i, q)
Δθ ← signed_angle(v1, v2, joint_axis(i))
Δθ ← clamp(Δθ, -Δθ_max, Δθ_max) ← joint velocity limit
q[i] ← clamp(q[i] + Δθ, q_min[i], q_max[i])
if dist(EE_pos(q), target) < eps: break
⚠️
Limitasi CCD: Tidak menjamin konvergensi global. Bisa terjebak di local minimum. Untuk orientasi end-effector, perlu modifikasi khusus. CCD hanya optimal untuk position-only IK.
5.11 FABRIK (Forward and Backward Reaching IK)
Algoritma FABRIK sangat cepat, intuitif, dan menghasilkan hasil yang natural. Ideal untuk real-time animation dan soft robotics:
1
Forward Reaching Pass
Gerakkan end-effector ke target, tarik seluruh chain:
p[n] ← target_pos ← pindahkan EE ke targetfor i = n-1 downto 0:
d ← ‖p[i+1] - p[i]‖
λ ← link_length[i] / d
p[i] ← (1-λ)·p[i+1] + λ·p[i] ← interpolasi ke arah lama
2
Backward Reaching Pass
Kembalikan base ke posisi aslinya, propagate ke depan:
p[0] ← base_pos ← kembalikan base ke posisi fixedfor i = 0 to n-1:
d ← ‖p[i+1] - p[i]‖
λ ← link_length[i] / d
p[i+1] ← (1-λ)·p[i] + λ·p[i+1] ← ikatan link length
3
Iterasi Hingga Konvergen
while dist(p[n], target) > eps AND iter < max_iter:
ForwardPass(p)
BackwardPass(p)
iter++
Konversi posisi ke joint angles:
θᵢ = atan2(p[i+1].y - p[i].y, p[i+1].x - p[i].x) - θ_parent
FABRIK konvergen dalam 5-10 iterasi untuk sebagian besar kasus!
5.12 Perbandingan Lengkap Semua Metode IK
Aspek
Analitik
Newton-Raphson
DLS
CCD
FABRIK
Kecepatan
★★★★★
★★★★
★★★
★★★★
★★★★★
Akurasi
Eksak
Sangat tinggi
Tinggi
Sedang
Tinggi
Generalitas
Terbatas
Medium
Tinggi
Tinggi
Tinggi
Near singularity
✓ (OK)
✗ (gagal)
✓ (robust)
✓ (OK)
✓ (OK)
Joint limits
Manual
Post-clamp
Post-clamp
Built-in
Partial
Redundant robots
✗
Partial
✓ (null-space)
✓
✓
Implementasi
Kompleks
Sedang
Sedang
Mudah
Sangat mudah
Rekomendasi
Robot industri 6-DOF
Non-singular paths
General purpose
Game/Realtime
Animation/Soft
06
Workspace Analysis
Workspace adalah himpunan semua pose yang dapat dicapai end-effector. Penting untuk memverifikasi feasibility sebelum menjalankan IK.
6.1 Jenis Workspace
🌐
Reachable Workspace
Himpunan semua posisi (x,y,z) yang bisa dicapai end-effector dalam orientasi apa pun.
🎯
Dexterous Workspace
Subset dari reachable workspace dimana end-effector dapat dicapai dalam orientasi apa pun.
6.2 Cek Feasibility Sebelum IK
Pengecekan Workspace 2-DOFr = √(px² + py²) ← jarak target dari base
Kondisi reachable:
|L₁ - L₂| ≤ r ≤ L₁ + L₂
r < |L₁ - L₂| → target terlalu dekat (inside inner workspace)
r > L₁ + L₂ → target terlalu jauh (outside outer workspace)
Pengecekan umum:
D = (px² + py² - L₁² - L₂²) / (2·L₁·L₂)
Feasible ⟺ -1 ≤ D ≤ 1
07
Implementasi Python
7.1 Kelas Robot Kinematics Lengkap
import numpy as np
from numpy.linalg import norm, inv, det, pinv
classRobotKinematics:
"""Robot Kinematics — Blue Dragon Security Research
Mendukung: FK, IK (Analitik 2DOF, DLS Numerik)
"""def__init__(self, dh_params, joint_limits):
# dh_params: list of (theta_offset, d, a, alpha)
self.dh = dh_params
self.n = len(dh_params)
self.q_min = np.array([lim[0] for lim in joint_limits])
self.q_max = np.array([lim[1] for lim in joint_limits])
defdh_matrix(self, theta, d, a, alpha):
"""Single D-H transformation matrix."""
ct, st = np.cos(theta), np.sin(theta)
ca, sa = np.cos(alpha), np.sin(alpha)
return np.array([
[ct, -st*ca, st*sa, a*ct],
[st, ct*ca, -ct*sa, a*st],
[ 0, sa, ca, d],
[ 0, 0, 0, 1]
])
defforward_kinematics(self, q):
"""FK: joint angles → end-effector pose T (4x4)."""
T = np.eye(4)
for i, (th_off, d, a, alpha) in enumerate(self.dh):
T = T @ self.dh_matrix(q[i] + th_off, d, a, alpha)
return T
defjacobian(self, q, delta=1e-6):
"""Numerical Jacobian via finite differences."""
T0 = self.forward_kinematics(q)
p0 = T0[:3, 3]
J = np.zeros((6, self.n))
for i in range(self.n):
q2 = q.copy(); q2[i] += delta
T2 = self.forward_kinematics(q2)
# Linear velocity
J[:3, i] = (T2[:3,3] - p0) / delta
# Angular velocity (from skew-symmetric)
dR = (T2[:3,:3] - T0[:3,:3]) / delta @ T0[:3,:3].T
J[3, i] = dR[2,1]
J[4, i] = dR[0,2]
J[5, i] = dR[1,0]
return J
defik_dls(self, T_des, q_init, lam=0.05,
max_iter=200, eps_pos=1e-4, eps_rot=1e-3):
"""Damped Least Squares Inverse Kinematics."""
q = q_init.copy()
for _ in range(max_iter):
T = self.forward_kinematics(q)
# Position error
e_pos = T_des[:3,3] - T[:3,3]
# Orientation error (axis-angle)
R_err = T_des[:3,:3] @ T[:3,:3].T
angle = np.arccos(np.clip((np.trace(R_err)-1)/2, -1, 1))
if abs(angle) < 1e-9:
e_rot = np.zeros(3)
else:
e_rot = angle/(2*np.sin(angle)) * np.array(
[R_err[2,1]-R_err[1,2],
R_err[0,2]-R_err[2,0],
R_err[1,0]-R_err[0,1]])
e = np.concatenate([e_pos, e_rot])
if norm(e_pos) < eps_pos and norm(e_rot) < eps_rot:
return q, True
J = self.jacobian(q)
lam2 = lam**2
dq = J.T @ np.linalg.solve(J @ J.T + lam2*np.eye(6), e)
q = np.clip(q + dq, self.q_min, self.q_max)
return q, False # max iter reached########## Contoh Penggunaan ##########if __name__ == "__main__":
# Robot 2-DOF sederhana
L1, L2 = 0.5, 0.4
dh = [(0, 0, L1, 0), # joint 1
(0, 0, L2, 0)] # joint 2
limits = [(-np.pi, np.pi)] * 2
robot = RobotKinematics(dh, limits)
# FK test
q_test = [np.pi/4, np.pi/3]
T = robot.forward_kinematics(q_test)
print(f"FK pos: {T[:3,3]}")
# IK test
T_target = T.copy()
q_init = np.zeros(2)
q_sol, ok = robot.ik_dls(T_target, q_init)
print(f"IK solution: {np.degrees(q_sol)} deg, converged={ok}")
7.2 IK Analitik 2-DOF (Fast Path)
defik_analytic_2dof(px, py, L1, L2):
"""Closed-form IK untuk robot 2-DOF planar.
Returns: list of (theta1, theta2) solutions, atau [] jika unreachable
"""
D = (px**2 + py**2 - L1**2 - L2**2) / (2*L1*L2)
if abs(D) > 1.0:
return [] # Tidak ada solusi
solutions = []
for sign in [+1, -1]:
theta2 = np.arctan2(sign * np.sqrt(1 - D**2), D)
k1 = L1 + L2 * np.cos(theta2)
k2 = L2 * np.sin(theta2)
theta1 = np.arctan2(py, px) - np.arctan2(k2, k1)
solutions.append((theta1, theta2))
return solutions # [(elbow_up), (elbow_down)]# Test
sols = ik_analytic_2dof(0.6, 0.3, 0.5, 0.4)
for i, (t1, t2) in enumerate(sols):
print(f"Sol {i+1}: θ₁={np.degrees(t1):.2f}°, θ₂={np.degrees(t2):.2f}°")