An arrangement provided for determining positions of the teats of a milking animal in a milking system comprising a milking stall for housing the milking animal during milking, a movable robot arm for automatically attaching teat cups to the teats of the milking animal in the milking stall, and a control device for controlling the movement of said robot arm based on determined positions of the teats of the milking animal, wherein said arrangement comprises: - a three-dimensional camera directable towards the udder of the milking animal in the milking stall, wherein the three-dimensional camera is provided to repeatedly record three-dimensional images of the udder of the milking animal in real time; and - image processing means provided for repeatedly detecting the teats of the milking animal and determining their positions in all three spatial dimensions based on said repeatedly recorded three-dimensional images, and - said arrangement is provided for determining positions of the teats of the milking animal in a rotary milking system; characterized in that - said three-dimensional camera is directable towards teat cups located in a magazine, wherein the three-dimensional camera is provided to repeatedly record three-dimensional images of the teat cups in real time; and - the image processing means is provided for repeatedly detecting the teats cups and determining their positions in all three spatial dimensions based on said repeatedly recorded three-dimensional images of the teat cups located in the magazine; and wherein the arrangement comprises: - a control device for holding or receiving information of the position of each of the teats of the milking animal relative the other teats of the milking animal and for controlling said robot arm to move to an obscured teat of the milking animal based on said information of the position of each of the teats of the milking animal relative the other teats of the milking animal and on the determined position of a repeatedly detected teat of the milking animal, which is not obscured. - a three-dimensional camera directable towards the udder of the milking animal in the milking stall, wherein the three-dimensional camera is provided to repeatedly record three-dimensional images of the udder of the milking animal in real time; and - image processing means provided for repeatedly detecting the teats of the milking animal and determining their positions in all three spatial dimensions based on said repeatedly recorded three-dimensional images, and - said arrangement is provided for determining positions of the teats of the milking animal in a rotary milking system; characterized in that - said three-dimensional camera is directable towards teat cups located in a magazine, wherein the three-dimensional camera is provided to repeatedly record three-dimensional images of the teat cups in real time; and - the image processing means is provided for repeatedly detecting the teats cups and determining their positions in all three spatial dimensions based on said repeatedly recorded three-dimensional images of the teat cups located in the magazine; and wherein the arrangement comprises: - a control device for holding or receiving information of the position of each of the teats of the milking animal relative the other teats of the milking animal and for controlling said robot arm to move to an obscured teat of the milking animal based on said information of the position of each of the teats of the milking animal relative the other teats of the milking animal and on the determined position of a repeatedly detected teat of the milking animal, which is not obscured. - a control device for holding or receiving information of the position of each of the teats of the milking animal relative the other teats of the milking animal and for controlling said robot arm to move to an obscured teat of the milking animal based on said information of the position of each of the teats of the milking animal relative the other teats of the milking animal and on the determined position of a repeatedly detected teat of the milking animal, which is not obscured.