Methods and devices are provided for robotic surgery, and in particular for measuring a rotational position of elongate shafts of surgical tools. For example, a surgical tool is provided with an elongate shaft having an end effector at a distal end thereof. The elongate shaft is rotatable about a longitudinal axis of the shaft, and the surgical tool is configured to measure a rotational position of the shaft about the longitudinal axis relative to an initial position.