Inconsistent results using enc_tgt()


I’m using a simple test from the online documentation with the enc_tgt() function to make the GoPiGo move forward just 1 full wheel rotation and then stop. Here is what I’m using:

from gopigo import *

Sometimes this works and sometimes it doesn’t. For example, as a test, I ran the script 10 times in a row and these were the results:

  1. Never stops moving forward
  2. Reaches target and stops (expected behavior)
  3. Reaches target and stops
  4. Nothing
  5. Reaches target and stops
  6. Never stops moving forward
  7. Reaches target and stops
  8. Never stops moving forward
  9. Never stops moving forward
  10. Reaches target and stops

The next 10 attempts yielded different results again. This is consistent after reboots and seems to occur on both usb power and battery power. Should I be doing something differently to make this work or am I misunderstanding how this is supposed to function? Thanks.


Thanks a lot for all the testing that you had done. I tried running the encoder targeting functions and it did show the glitches that you had mentioned.

I then tried running it with a small delay after running the encoder targeting function and it does seem to work much well and it is now working well. I am attaching a test script here. Can you try it out and let us know if it works for you.



It does seem to work better with the delay. Thanks for your help!


I am getting a similar issue from the tutorial (RPi 3, Jessie FULL)

My GoPiGo does not stop when it reaches the desired target. The code in your does the same. I would like to get it functioning correctly so I can get multiple GoPiGos to display and transmit their relative position from each other.

Please disregard, was missing one optical encoder wheel!