KR3 simulation-first cell

Samarth Bankar · Ahmedabad University robotics lab · status of 9 November 2026 · source code, reports and sample data on GitHub

A ROS 2 (Humble) cell for a KUKA KR 3 R540 industrial arm and its KR C4 controller, built so that the same application code runs on four levels by changing one launch argument: a mock arm (L0), Gazebo physics (L1), a simulator of the controller's RSI real-time protocol (L2) and the real controller (L3). Every motion is gated by a safety supervisor, every run is recorded and filed with the commit that produced it. All code is C++ and C.

Gazebo (left) and RViz (right) side by side: the arm takes parts off a conveyor belt and stacks them on a pallet; RViz shows the supervisor mode MOVING.
Physics level (L1): Gazebo on the left, RViz on the right. The arm picks eight parts from a conveyor belt and stacks them 2×2×2 on a pallet; RViz shows the safety supervisor's mode above the cell.

Where it stands

LevelStatus
L0 mock armdone: pick-and-place, palletizing, conveyor picking, welding, dispensing, teleoperation
L1 Gazebo physicsdone: the same applications with parts as physical bodies; explicit servo model
L2 RSI protocoldone: own real-time protocol driver against a controller simulator, 4 ms cycle, fault handling
L3 real controllerrunning: the real controller in the loop, first motion, fault stops on the real arm, automatic-mode data campaigns behind the cell's safeguard
L4 real grippernext: gripper selection and integration

On the real arm (9 November 2026)

The real controller ran in the loop for the first time: first with the operator holding the enabling switch, then in automatic mode behind the cell's safety guard, with the arm driven only by small real-time corrections from the cell computer inside a limited range around its home position.

TestResult
robot model vs the controller's own position display, 20 poses0.009 mm, 0.008° (requirement 1 mm, 0.1°)
moves driven from the cell computerabout 760, every one within 0.0021° of its target
real-time packets exchanged (4 ms cycle)about 830 000, none missed
stop after an operator disarm, real arm34 ms at 0.05 rad/s, 56 ms at 0.2 rad/s
silent software detected and stopped, real arm0.10–0.12 s, every time
Bar chart per axis: tracking error while moving is about 0.16 degrees on the real arm, about 0.165 degrees for the corrected digital twin and about 0.02 degrees for the old twin.
The real arm follows every command about 31 ms late, the same on all six axes, speeds and loads. With that delay identified from the recordings, the digital twin tracks like the real arm: within 0.007° on sessions it was not fitted to, 15–35 times closer than before.
Bar chart: position and orientation error for 20 poses, all below 0.01 millimetres and 0.01 degrees.
The robot model against the controller on 20 poses spread over the whole base-axis range: every error is at the display's resolution.

Simulation found the problem that would have stopped the first real session: the 1 kHz control loop silently ran on a fixed 4 ms grid, and with a controller clock only 50 ppm off, the real-time link failed after 30 s. It was fixed and proven in simulation the night before.

Simulation results

Four simulation campaigns; the latest (C04) ran every application and two injected faults on all three simulated levels on one software version: 23 of 23 runs valid.

L0 mockL1 physicsL2 protocol
randomized picks50/5050/50 (+50/50)50/50
mean pick cycle12.61 s12.60 s12.62 s
pallet blocks, conveyor parts8/8, 8/88/8, 8/88/8, 8/8
weld path deviation (RMS)≤ 0.0021 mm≤ 0.0018 mm≤ 0.0020 mm
stop after an operator disarm (max)12 ms8 ms13 ms
silent driver detected after0.51 s0.51 s0.51 s
Bar chart: tracking error per joint at L1, about 0.95 degrees with Gazebo's default servo and 0.19 degrees with the explicit servo model.
The physics level first measured Gazebo, not the robot: a hidden 40 ms servo lag. An explicit 8 ms servo model cut the tracking error five-fold; the real arm's measured delay (above) now replaces it, step by step.
Line chart: conveyor cycle time per part; the old physics run grows from 10.7 to 16.1 s, the corrected runs stay at 12.5 to 13 s on all levels.
Physics time is not wall time: cycle times grew as the simulator slowed down while parts piled up. On simulated time all three levels agree within 0.03 s per part.
Bar chart: stop distance after an operator disarm while the base axis moves at 0.5 rad/s, at most 0.24 degrees on every level.
Operator disarm while the base axis turns at 0.5 rad/s: the arm stops within 0.24° on every level. On the real arm the same stop takes longer (the controller's own braking ramp): see the table above.