An industrial robot comprising: - a robot arm with a redundant number of joints and provided with a tool interface movable in a plurality of degrees of freedom, and a tool centre point defined in relation to the tool interface, and - a control unit adapted to receive movement instructions and based thereon control the movements of the robot arm, and to check whether any of the joints of the robot arm is close to its joint limit and if this is the case to use the redundant number of joints to avoid the joint limit with the tool centre point unchanged, wherein the control unit includes a motion planner adapted to determine how the robot arm should move by carrying out an interpolation of the instructed movement, including a plurality of interpolation steps, and for each interpolation step calculate joint angles for the robot arm for an increment of the instructed movement, characterized in that - the robot comprises a user operated control device for manually controlling the movements of the tool centre point and adapted to send information on user instructed movements for the tool centre point to the control unit, - the control unit is adapted to switch between a teach mode and a run-time mode, and to control the movements of the robot arm based on movement instructions from the user operated control device during the teach mode, and to control the movements of the robot arm in accordance with movement instructions from a control program during the run-time mode, - the control unit includes an optimizing module which is adapted to search in the null space of the redundant robot arm for a new joint configuration that increases the distance to the joint limit with the tool centre point unchanged, and - the motion planner is adapted to check whether any of the joints of the robot arm is close to its joint limit, and if this is the case to run said optimizing module and replace calculated joint angles for the increment with joint angles of the new joint configuration when the control unit is in the teach mode, and to omit the optimizing module when the control unit is in run-time mode. - a robot arm with a redundant number of joints and provided with a tool interface movable in a plurality of degrees of freedom, and a tool centre point defined in relation to the tool interface, and - a control unit adapted to receive movement instructions and based thereon control the movements of the robot arm, and to check whether any of the joints of the robot arm is close to its joint limit and if this is the case to use the redundant number of joints to avoid the joint limit with the tool centre point unchanged, wherein the control unit includes a motion planner adapted to determine how the robot arm should move by carrying out an interpolation of the instructed movement, including a plurality of interpolation steps, and for each interpolation step calculate joint angles for the robot arm for an increment of the instructed movement, characterized in that - the robot comprises a user operated control device for manually controlling the movements of the tool centre point and adapted to send information on user instructed movements for the tool centre point to the control unit, - the control unit is adapted to switch between a teach mode and a run-time mode, and to control the movements of the robot arm based on movement instructions from the user operated control device during the teach mode, and to control the movements of the robot arm in accordance with movement instructions from a control program during the run-time mode, - the control unit includes an optimizing module which is adapted to search in the null space of the redundant robot arm for a new joint configuration that increases the distance to the joint limit with the tool centre point unchanged, and - the motion planner is adapted to check whether any of the joints of the robot arm is close to its joint limit, and if this is the case to run said optimizing module and replace calculated joint angles for the increment with joint angles of the new joint configuration when the control unit is in the teach mode, and to omit the optimizing module when the control unit is in run-time mode.