Project 02 / control

Pendularm

A planar 2- or 3-link arm simulation where numerical integration and PID tuning become visible, interactive behavior.

C++Lagrangian dynamicsPIDEuler · Midpoint · Verlet · RK4

Overview

Pendularm derives the mass matrix, Coriolis/centrifugal forces, and gravity load for a serial manipulator. A live servo loop uses the same runtime protocol as Project 1, with /joint_states and /joint_trajectory driving an external UI.

Use ARM_SIM_LINKS=2 or 3 to change the robot.

How the control loop works

  1. Read the current state and held target.
  2. Compute error and a clamped integral.
  3. Apply τ = Kp·e + Ki·∫e + Kd·ė.
  4. Evaluate dynamics and advance with the selected integrator.

Why four integrators?

Euler is simple but can drift. Midpoint and Verlet improve stability differently; RK4 samples the derivative several times for higher accuracy. Changing method and timestep makes numerical error visible in the arm's motion.

state → PID effort → M(q)q̈ = τ − C(q,q̇) − G(q) · integrator → next state

Video demo

← Back to portfolio