A computer program product for controlling an optical phased array mounted on a substrate, the optical phased array having an antenna array including a plurality of antenna elements each emitting light supplied from a light source, the computer program product being stored on a non-transitory computer readable medium, and comprising instructions configured to, when executed by one or more processors, cause the one or more processors to:
- calculate an amount of positional deviation of each antenna element based on an amount of deformation of the substrate detected by a shape sensor mounted on the substrate;
- calculate an amount of phase deviation of the light emitted from each antenna element based on the amount of positional deviation calculated;
- correct the phase of the light emitted from each antenna element based on the amount of phase deviation calculated;
- and
- control the phase of each antenna element so that a direction of light emitted from the antenna array coincides with a target direction.