The wavefront control strategy for the proposed Gemini Planet Imager, an extreme adaptive optics coronagraph for planet detection, is presented. Two key parts of this strategy are experimentally verified in a testbed at the Laboratory for Adaptive Optics, which features a 32 × 32 MEMS device. Detailed analytic models and algorithms for Shack-Hartmann wavefront sensor alignment and calibration are presented. It is demonstrated that with these procedures, the spatially filtered WFS and the Fourier Transform reconstructor can be used to flatten to the MEMS to 1 nm RMS in the controllable band. Performance is further improved using the technique of modifying the reference slopes using a measurement of the static wavefront error in the science leg.