Current medical technologies are converging to minimally invasive diagnosis and therapy. The effort to reduce patient discomfort in gastrointestinal (GI) tract diagnoses resulted in the development of wireless capsule endoscopes (WCEs). In the form of a pill, a camera carrying WCE travels through the GI tract by natural peristalsis while it collects images of the internal wall of the GI tract. The operation might be entirely painless. However, their inability to have active locomotion and control limit detailed diagnoses, therapeutic functions, and minimization of the operation time. Actively controlled WCEs would resolve those challenges. This thesis provides methods for the active control of WCEs using magnetic interactions, and applies those methods to a robotic biopsy capsule endoscope. First, a localization method for meso-scale magnetic robots is developed. The method utilizes a magnetic sensor array where a magnetically actuated capsule endoscope (MACE) does not require a special device for localization but a single magnet. The method is beneficial to reduce the size and the battery consumption of the MACE. The method focuses on decoupling the magnetic field of the MACE from the magnetic field of the actuator, and developing a real-time localization algorithm. Second, an automatic calibration method for magnetic actuation and sensing systems is presented. The method calibrates a number of nonlinear magnetic sensors and a number of electromagnets. The method is capable of calibrating 1.8k parameters in an exemplary system in a reasonable time without human labor. In this work, Bundle Adjustment framework from Computer Vision is modified and adapted to magnetic robot sensing and actuation systems. This work would be useful for a magnetic system which requires frequent reconfiguration or sensor/actuator gain updates. Third, control methods for a meso-scale magnetic robots on a surface with non-uniform magnetic field actuations are presented. The control methods utilize magnetic energy wells to cope with a low actuation bandwidth compared to the fast dynamics of the capsule endoscope. Additionally, we present a teleoperation system to mitigate the orientation coordination difficulty when a person uses the system. Fourth, all of the above three methods are integrated and applied to a magnetically actuated soft capsule endoscope for the biopsy functionality (B-MASCE). We designed a biopsy capsule endoscope with a high diagnostic accuracy by adopting a clinically well established biopsy method called fine-needle capillary biopsy. Ex vivo experiments in a fresh porcine stomach show promising results. In summary, this thesis presents localization, calibration, control methods and their application in a biopsy capsule robot, which are useful for the automation of robotic capsule endoscopes. We envision that, in future, patients have painless GI tract endoscopy and treatment with highly