A robot system efficiently performing an operation of moving a robot to
close to and/or separate from a target point, such as teaching operation.
A camera of a visual sensor is mounted to the robot such that a distal
end of an end effector is seen within the field of view of the camera,
and the end effector's distal end and a target position on an object are
specified on a monitor screen. When an approach key is depressed, a
target position is detected on an image, and a difference from a position
of the end effector's distal end is calculated. Whether the difference is
within an allowable range is checked. Depending on the result, an amount
of robot motion is calculated, and the robot is operated. The processing
is repeated until the depressed approach key is released. When a retreat
key is depressed, the robot moves away from the object. The robot may be
caused to stop using a distance sensor.