A robot control device that controls an angle of a joint of a robot driven by a motor, the robot control device comprising: a joint-angle command calculating unit configured to calculate and output a first angle command indicating an angle of the joint for causing the robot to perform a desired motion; an axial-force torque calculating unit configured to calculate, upon receipt of the first angle command, an axial force torque on the basis of a kinetic model of the robot, the axial force torque being generated on a joint axis of the robot operating in accordance with the received first angle command; an elastic deformation compensation unit configured to add the amount of deflection in the joint calculated from the axial force torque and a spring constant representing stiffness of the joint of the robot to the angle of the joint indicated by the first angle command received by the axial-force torque calculating unit, to calculate and output a motor command angle indicating a rotation angle of the motor; a stop position detecting unit configured to detect and output, as a motor detection angle, an angle of the motor when the robot contacts an external structure; and a command angle switching unit configured to output, when the stop position detecting unit outputs the angle of the motor, the angle of the motor detected by the stop position detecting unit as a second angle command indicating the angle of the joint, instead of the first angle command output from the joint-angle command calculating unit; an inverse elastic deformation compensation unit configured to subtract, from the motor detection angle, the amount of deflection in the joint calculated from the axial force torque output from the axial-force torque calculating unit and the spring constant representing stiffness of the joint to calculate a corrected motor detection angle, wherein the stop position detecting unit detects and outputs the corrected motor detection angle, instead of the motor detection angle. a joint-angle command calculating unit configured to calculate and output a first angle command indicating an angle of the joint for causing the robot to perform a desired motion; an axial-force torque calculating unit configured to calculate, upon receipt of the first angle command, an axial force torque on the basis of a kinetic model of the robot, the axial force torque being generated on a joint axis of the robot operating in accordance with the received first angle command; an elastic deformation compensation unit configured to add the amount of deflection in the joint calculated from the axial force torque and a spring constant representing stiffness of the joint of the robot to the angle of the joint indicated by the first angle command received by the axial-force torque calculating unit, to calculate and output a motor command angle indicating a rotation angle of the motor; a stop position detecting unit configured to detect and output, as a motor detection angle, an angle of the motor when the robot contacts an external structure; and a command angle switching unit configured to output, when the stop position detecting unit outputs the angle of the motor, the angle of the motor detected by the stop position detecting unit as a second angle command indicating the angle of the joint, instead of the first angle command output from the joint-angle command calculating unit; an inverse elastic deformation compensation unit configured to subtract, from the motor detection angle, the amount of deflection in the joint calculated from the axial force torque output from the axial-force torque calculating unit and the spring constant representing stiffness of the joint to calculate a corrected motor detection angle, wherein the stop position detecting unit detects and outputs the corrected motor detection angle, instead of the motor detection angle.