A surgical robot comprising a flexible arm extending from a 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, 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, the control unit being operable in: a compliant mode in which the control unit controls the drivers such that the robot arm maintains a position in which it is placed by means of a force applied directly to the arm so as to permit an operator to locate a tool attached to the attachment structure into a port; subsequently, operate in a calibration mode in which the control unit is configured to estimate the location of the port by monitoring 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 he attitude of the attachment structure to the base to alter; and subsequently, operate in a driven mode in which the configuration of the robot arm is driven in dependence on inputs received from a three-dimensional controller and the estimated port location.