NASA and the astronomy community hope to soon launch a new space-based telescope to detect and characterize extrasolar planets. Detecting extrasolar planets with angular separations and contrast levels similar to Earth requires not only a large space-based observatory but also advanced starlight suppression techniques. One promising approach is coronagraphy via shaped pupils. Shaped pupil coronagraphs are binary pupil functions that modify the point spread function of a telescope to produce regions of high contrast. Unfortunately, the contrast performance of coronagraphs is highly sensitive to optical errors, thus necessitating wavefront control to retrieve the necessary contrast levels. Using two MEMS deformable mirrors in series with the coronagraph allows us to control both the phase and amplitude aberrations over a finite wavelength range. Given an estimate of the wavefront we have developed an optimal controller that minimizes actuator strokes on the deformable mirrors subject to a constraint that it achieve a targeted contrast level in a defined region of the image. To provide an estimate for the controller that is accurate enough to converge to a solution that achieves the required ten orders of magnitude, the electric field must be estimated using the science camera to avoid any non-common path errors. The estimate is found by either using a batch process or Kalman filter technique which uses multiple image pairs with conjugated deformable mirror settings to estimate the field prior to evaluating the control shape. This paper outlines the algorithms used and presents our laboratory results.