A robot system comprising: a robot arm which performs work on a target; a shape measurement device which is disposed on the robot arm and measures a shape of the target and is provided in the distal end portion of the robot arm; and a controller which controls the robot arm based on a result measured by the shape measurement device, wherein the shape measurement device includes a projection device which projects striped pattern light onto the target, an image capturing device which captures the images of the pattern light projected onto the target and comprises image capturing element, and a circuit unit which is electrically connected to each of the projection device and the image capturing device, and wherein the projection device includes a light source device which emits linear laser and an optical scanner which generates the pattern light by reflecting the laser emitted from the light source device and by scanning the target and which includes a movable mirror, a pair of shaft portions which support the movable mirror for swinging movement, and a distortion sensor provided in one of the shaft portions, and wherein the circuit unit comprises a scanner driver which outputs a driving signal to drive the optical scanner non-resonantly, a light source driver which drives the light source device, a failure determination unit which is electrically connected to the distortion sensor for determining whether or not the optical scanner fails, and a processor which calculates the shape of the target within the measurement range based on a signal from the image capturing element,the robot system thereby comprising a failure detection sensor being configured by said distortion sensor and said failure determination unit and which stops driving the light source device if it detects a failure of the optical scanner. a robot arm which performs work on a target; a shape measurement device which is disposed on the robot arm and measures a shape of the target and is provided in the distal end portion of the robot arm; and a controller which controls the robot arm based on a result measured by the shape measurement device, wherein the shape measurement device includes a projection device which projects striped pattern light onto the target, an image capturing device which captures the images of the pattern light projected onto the target and comprises image capturing element, and a circuit unit which is electrically connected to each of the projection device and the image capturing device, and wherein the projection device includes a light source device which emits linear laser and an optical scanner which generates the pattern light by reflecting the laser emitted from the light source device and by scanning the target and which includes a movable mirror, a pair of shaft portions which support the movable mirror for swinging movement, and a distortion sensor provided in one of the shaft portions, and wherein the circuit unit comprises a scanner driver which outputs a driving signal to drive the optical scanner non-resonantly, a light source driver which drives the light source device, a failure determination unit which is electrically connected to the distortion sensor for determining whether or not the optical scanner fails, and a processor which calculates the shape of the target within the measurement range based on a signal from the image capturing element,the robot system thereby comprising a failure detection sensor being configured by said distortion sensor and said failure determination unit and which stops driving the light source device if it detects a failure of the optical scanner.