> On Jun 15, 2016, at 10:59 AM, Joel Goldstick <joel.goldst...@gmail.com> wrote:
> 
> On Wed, Jun 15, 2016 at 10:15 AM,  <ldompel...@casema.nl> wrote:
>> I have a small robot on wheels named the GoPiGo.
>> What I want is if the distence sensor read the same distence for let say 5 
>> seconds then the GoPiGo go's backward.
>> 

When I look at the API, I see two functions related to distance traveled.  An 
encoder target function that presumably reads the numbers from an angular 
encoder on the drive shaft and allows you to specify a number for the encoder 
to seek, and a “us_dist” function that seems to read the proximity to an object 
from an ultrasonic sensor.  I’m going to assume you are referring to the 
numbers from this ultrasonic distance sensor.  So, I think what you are saying 
is that if the numbers from the distance sensor are unchanged for 5 seconds (as 
would be the case if the GoPiGo were being blocked by something) then you want 
it to back up. 

As MRAB has commented, what you need to do is set up a delay loop that wakes up 
every second (or more frequently if you want more time resolution) and reads 
the number returned by the us_dist function.  Compare it to the previous 
reading and if unchanged increment a counter.  If it has changed, the robot has 
moved so clear the counter.  If the counter reaches your five second trigger 
point, call a go_back function you write.

-Bill


>> But I don't now how to program this in python.
>> The Api functions for the GoPiGo are here: 
>> http://www.dexterindustries.com/GoPiGo/programming/python-programming-for-the-raspberry-pi-gopigo/
>> 
>> Can someone help me with this.
>> 
>> --
>> https://mail.python.org/mailman/listinfo/python-list
> 
> You can start here: https://www.python.org/about/gettingstarted/
> 
> 
> -- 
> Joel Goldstick
> http://joelgoldstick.com/blog
> http://cc-baseballstats.info/stats/birthdays
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to