A discrete-time localization method for capsule endoscopy based on on-board magnetic sensing