Real-Time Inverse Kinematics
for 6-DOF Robot Arms

ROS2 Jazzy · Python · NumPy · RViz

A numerical IK solver designed to map Cartesian coordinate setpoints into joint positions. Operating directly as a ROS2 node which delivers smooth manipulator trajectories at a deterministic 50 Hz.

Node Capabilities

6-DOF CONTROLLER

Fully coordinates joint parameters for multi-revolute configurations, managing link transformations efficiently.

50 HZ LOOP

Executes at a deterministic update period to provide rapid trajectory convergence and steady state monitoring.

PSEUDO JACOBIAN^-1

Leverages robust numerical matrix inversion to resolve positional updates while minimizing total joint displacements.

ROS2 JAZZY NATIVE

Integrates directly with ROS2 communication frameworks, publishing to robot tf stacks without intermediate layers.

Feedback Control Loop & ROS2 Interfaces

The robot_controller node runs a closed-loop IK solve at 50 Hz and publishes live joint and marker state into the ROS2 graph for RViz.

ROS2 Node robot_controller

Timer-driven callback every 0.02 s — solve then publish

50 Hz
Solver

Closed-Loop IK

Middleware

ROS2 Publications

1

Forward Kinematics

Chain URDF link transforms from the base through each joint to recover the current end-effector pose in Cartesian space — the reference for both tracking error and the EE marker publish.

PUB
/marker visualization_msgs/Marker

Blue arrow — EE pose from forward kinematics

2

Tracking Error & Setpoint Gate

Subtract the EE pose from the Cartesian setpoint. If inside the deadband, the node samples a new target; outside it, the residual drives the Jacobian solve.

PUB
/setpoint visualization_msgs/Marker

Red arrow — Cartesian setpoint goal

3

Numerical Jacobian

Nudge each joint slightly and re-run FK to measure how the EE moves, assembling a 3×6 sensitivity matrix without analytical interpretations.

4

Pseudo-Inverse Solve

Project the Cartesian error through the Moore-Penrose inverse of the Jacobian Matrix so the joint update reduces tracking error while preferring small displacements.

5

Safety Governor

Apply gain scaling and per-joint clamps before committing the new configuration, preventing overshoot and velocity spikes near singularities.

PUB
/joint_states sensor_msgs/JointState

Six joint angles after the safety-governed update

RViz
3D render stack

Subscribes to /setpoint, /marker and /joint_states for live visualization

Explore the Code Blocks

Select an algorithm step below to inspect its functional Python code from the active solver node.

robot_controller.py
# Click a tab on the left to inspect the implementation
Loading section details...

Libraries & Technologies

⚙️
ROS2 Jazzy
Provides the pub/sub middleware architecture
🐍
Python + rclpy
Client library executing the controller node
🧮
NumPy
Handles vector arithmetic and matrix inversion
👁️
RViz
Visualizes target marker transforms and joint links

Technical Deep-Dive

Mathematical structures and parameters of the numerical Inverse Kinematics solver.

Forward Kinematics

Determining the current spatial position of the manipulator requires chaining coordinate frame mappings from the base mount to the end-effector. This homogeneous transformation matrix is resolved using the configuration vector:

\[ T_{fk}(\vec{\theta}) = T_1(\theta_1) \cdot T_2(\theta_2) \cdot \dots \cdot T_6(\theta_6) \cdot T_{ee} \]

This chaining function uses dimensions extracted from the robot geometry parameters file (URDF file) to convert joint rotations into a single 4x4 matrix defining Cartesian frame coordinate properties.

Jacobian Mapping & Pseudo-Inverse

The Jacobian matrix maps velocities between joints' rotation space and Cartesian movement space:

\[ \vec{v} = J(\vec{\theta}) \cdot \vec{\omega} \]

Because the controller node needs to translate a desired movement vector into state updates for the manipulator joints, this relationship was solved using the Moore-Penrose pseudo-inverse representation:

\[ \Delta \vec{\theta} = J^T \cdot (JJ^T)^{-1} \cdot \vec{d}_{error} \]

This mathematical mapping identifies the joints' state updates that satisfy positional setpoints while minimizing displacement magnitude, helping resolve redundant joint paths.

Numerical Perturbation Solver

To ensure that this controller node can run on multiple designs without manual configuration, the columns of the Jacobian are evaluated numerically. The joint configurations are perturbed by a small interval $\epsilon = 0.01$:

\[ J_{row,j} = \frac{T_{fk}(\vec{\theta} + \epsilon \cdot \hat{e}_j) - T_{fk}(\vec{\theta})}{\epsilon} \]

This numerical approximation extracts directional sensitivities using only the Forward Kinematics function, making the solver compatible with arbitrary joint structure modifications.

Controller Safety Governor

Control loops operating near singular physical limits can generate excessive joint velocity updates. The node incorporates stability scaling and bounding rules to maintain controlled motion:

Control Parameter Operational Setting Functional Purpose
Fixed-Gain Scaling 0.01 factor Reduces step magnitude to prevent target overshoot
Output Clamping ±0.125 rad limit Prevents angular speed spikes near singularities
Convergence Threshold 0.01m deadband Settles solver updates once target proximity is reached