A robot comprising: a base; a flexible arm extending from the base and having a plurality of joints whereby the configuration of the arm can be altered, a plurality of drivers arranged to drive the joints to move, a plurality of sensors for sensing the position of each of the joints and an attachment structure for attaching a tool to the arm, the joints permitting the angular attitude of the attachment structure relative to the base to be varied; and a control unit configured to control the drivers and to receive inputs from the sensors, and operable in a calibration mode in which, whilst a tool is attached to the attachment structure and captive in a port, it: (i) controls the drivers so as to permit the arm to be reconfigured by the action of an external force applied to the arm; (ii) monitors the configuration of the arm under the presence of an external force applied to the arm and transmitted through the tool to the port so as to cause the attitude of the attachment structure to the base to alter; whereby the location of the port can be estimated.