Why put capacitor between ground and chassis?
The sensor is a PNP output with 2x potentiometers, I presume as coarse and fine  with act as some optical comparator with a load resistor to 0V for measuring an optical gap.  In noisy environments a metallize film cap shunts Stray RF noise between 0Vdc and the metal body to improve SNR from injecting noise with your hand.

The hands can inject high impedance line noise picked up easily by the body. thus cap shunts this line noise to 0Vdc.

Film is often the best choice for very low ESR and big enough to reducing errors from handling.

Zc=1/2piCf