Teat cup / end effector Position estimate (Kalman) Unattached teat
⚠ Couldn't load the 3D engineThree.js failed to load from the CDN. Check your connection and reload.

Robotic Milking Arm: Teat-Tracking & Attachment

This simulator models the two algorithms behind a real automatic milking robot: teat localization and arm reach. A laser/ultrasonic scan model repeatedly samples each teat's position with Gaussian noise while the udder sways as the cow shifts its weight; a scalar recursive (Kalman) filter fuses those noisy scans into a shrinking-uncertainty position estimate. Once that estimate is confident enough, a 2-link robot arm — solved analytically with the law-of-cosines inverse-kinematics formulas used on real manipulators, not an iterative approximation — reaches for it and attempts to attach the cup. Because the true teat keeps drifting during the approach, attachment isn't guaranteed: tune sensor noise, cow movement and arm speed and watch the live uncertainty, per-teat outcomes and cumulative success rate respond.