Precision Motion Sensing And Control Through Constrained Optimization