|
|
||
|
This interactive simulation visualizes Forward Kinematics (FK) and Inverse Kinematics (IK) for a planar 2-link robot arm. You can drive the arm by angles (FK) or by dragging the end-effector target (IK), and see the underlying math update in real time.
Math behind the Simulation1. Two-link planar arm The arm has two links: length L1 (shoulder–elbow) and L2 (elbow–end-effector). Joint angles are θ1 (base) and θ2 (elbow, relative to link 1). The end-effector position (in a math frame with x right, y up) is:
x = L1 cos(θ1) + L2 cos(θ1 + θ2) 2. Forward kinematics (FK) Given θ1, θ2, L1, L2, we compute x, y directly from the equations above. The elbow is at (L1 cos θ1, L1 sin θ1). 3. Inverse kinematics (IK) Given a target (x, y), we solve for θ1, θ2. Let d = √(x2 + y2). If d > L1 + L2 we clamp to max reach; if d < |L1 − L2| we clamp to min reach. Using the Law of Cosines:
cos θ2 = (d2 − L12 − L22) / (2 L1 L2), so θ2 = ±acos(...). 4. Workspace and singularities The reachable set is an annulus (donut): outer radius L1 + L2, inner radius |L1 − L2|. Singularities occur when the arm is fully extended or fully folded (θ2 = 0 or ±π): the Jacobian becomes singular and small Cartesian motions require large joint motions. 5. Jacobian and manipulability ellipsoid Definition. The Jacobian J is the matrix of partial derivatives of end-effector position (x, y) with respect to joint angles (θ1, θ2): J = ∂[x; y]/∂[θ1; θ2]. The entries are j11 = ∂x/∂θ1, j12 = ∂x/∂θ2, j21 = ∂y/∂θ1, j22 = ∂y/∂θ2, which you can derive from the FK expressions above. Velocity mapping. J maps joint velocities to end-effector velocity: [ẋ; ẏ] = J [θ̇1; θ̇2], i.e. ẋ = j11θ̇1 + j12θ̇2 and ẏ = j21θ̇1 + j22θ̇2. Use in this simulation. We compute J from the current (θ1, θ2, L1, L2) and show its entries live in the Jacobian J panel. The manipulability ellipsoid (cyan ellipse at the end-effector) is derived from JJT: its axes indicate directions of higher velocity capability for unit joint velocity. The ẋ, ẏ from J panel compares end-effector velocity from J·[θ̇1; θ̇2] with measured velocities (from finite differences), and the velocity subplots show θ̇1, θ̇2 and ẋ, ẏ over time. 2D Kinematics
45.0°
30.0°
0
0
FK (live): x = 150·cos(45) + 120·cos(45+30) = 0
y = 150·sin(45) + 120·sin(45+30) = 0
Joint velocityθ̇₁ = — rad/s θ̇₂ = — rad/s Jacobian JDefinition: J = ∂[x; y]/∂[θ₁; θ₂]. J maps [θ̇₁, θ̇₂]ᵀ → [ẋ, ẏ]ᵀ. Use here: Live J from FK; manipulability ellipse from JJᵀ; ẋ, ẏ from J·[θ̇₁; θ̇₂] vs measured. j₁₁ = ∂x/∂θ₁ = −L₁ sin θ₁ − L₂ sin(θ₁+θ₂) = — j₁₂ = ∂x/∂θ₂ = −L₂ sin(θ₁+θ₂) = — j₂₁ = ∂y/∂θ₁ = L₁ cos θ₁ + L₂ cos(θ₁+θ₂) = — j₂₂ = ∂y/∂θ₂ = L₂ cos(θ₁+θ₂) = — ẋ, ẏ from J[ẋ; ẏ] = J [θ̇₁; θ̇₂] ẋ = j₁₁·θ̇₁ + j₁₂·θ̇₂ = — ẏ = j₂₁·θ̇₁ + j₂₂·θ̇₂ = — Measured: ẋ = —, ẏ = — px/s
UsageFollow these steps to explore 2D robot arm kinematics:
Tips: Switch to IK and drag the target outside the annulus to see it clamp to max/min reach. Use Elbow Up/Down to compare both IK solutions. Check Trace and Run to see the path sweeps. Parameters
|
||