The measurement of the dipole anisotropy of protons and helium cosmic rays with the PAMELA experiment