The tokamak in-vessel robot is a 10-DOF flexible in-vessel inspection robot designed for carrying out scanning and maintenance of a tokamak in a complicated environment. Due to the large size of the TIR, the flexible deformation of the TIR is significant, which leads to a low end positioning accuracy and trajectory accuracy. This paper analyzes the factors leading to the deformation of the TIR and establishes a model of the pose error caused by these factors. Based on the model, an error compensation method is proposed based on an optimization method. According to the the principle of visual servo, the end position deviation is calculated by using the image obtained by the visual unit. The detected deviation is used to control the end position of the TIR and optimize and reduce the deviation. Experiments are carried out on a 1:1 model of a tokamak vessel, and the results show that the proposed method can effectively improve the end positioning accuracy.