When either a command value or an actually measured value is appropriately
selected as an angular velocity used for the frictional torque
calculation, the frictional compensation can be made valid at all times
in both the case in which a robot is actively operated according to an
angular velocity command and the case in which the robot is passively
operated being pushed by an external force. In the case where a motor
rotating direction and a collision direction are reverse to each other
after a collision has been detected, the control mode is switched from
the positional control to the electric current control and a torque, the
direction of which is reverse to the direction of the motor rotation is
generated by the motor, so that the motor rotating speed can be reduced
and the collision energy can be alleviated. After that, when the motor
rotating speed is reduced to a value not more than the setting value, the
control mode is switched to the compliance control and the distortion
caused in a reduction gear is dissolved. On the other hand, in the case
where the motor rotating direction and the collision direction are the
same, the control mode is directly switched from the positional control
to the compliance control without passing through the electric current
control. When the robot is operated whole following a collision force,
the collision force can be alleviated.