Example 7 cmpc and gmpc ======================= Simulation ----------- .. image:: ../tutorial/code7.gif :alt: not found :align: center Real Life --------- .. image:: ../tutorial/code7real.gif :alt: not found :align: center What does the code do? ---------------------- This code sets the robot position to 0 (using cmpc) then goes forward until robot position = 5000 (using gmpc) Functions Used -------------- cmpc( clear_motor_position_counter) gmpc ( get_motor_position_counter) mav( motor port, velocity) Function Implementation *********************** .. code-block:: python :linenos: #!/usr/bin/python3 import os, sys sys.path.append("/usr/lib") from kipr import* def main(): cmpc(0) while gmpc(0) < 5000: mav(0, 750) mav(3, 750) if __name__ == "__main__": main() Rookie Tip ---------- By using gmpc, you can know what position your motor needs to be at, so you can further improve your code.