An arrangement is provided for attaching teat cups to teats of a
milking animal in a rotary
milking system having a
milking stall for housing the milking animal during milking. The arrangement comprises a three-dimensional camera configured to be directed towards the
udder of the milking animal in the milking stall and to repeatedly
record three-dimensional images of the
udder of the milking animal in real time. The three-dimensional camera is further configured to be directed towards the teat cups located in a
magazine and to repeatedly
record three-dimensional images of the teat cups in real time. The arrangement also includes an
image processing device configured to repeatedly detect the teats of the milking animal and determine the positions of the teats in three spatial dimensions based on said repeatedly recorded three-dimensional images of the teats. The
image processing device is also configured to repeatedly detect the plurality of teat cups and determine the positions of the teat cups in three spatial dimensions based on said repeatedly recorded three-dimensional images of the teat cups located in the
magazine. The arrangement also includes a control device configured to control a
robot arm, based on the determined positions of the teats of the milking animal and the determined positions of the teat cups, to automatically attach at least one teat cup to at least one teat of the milking animal in the milking stall.