Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109970 > unrolled thread

GoPiGo distence sensor

Started byldompeling@casema.nl
First post2016-06-15 07:15 -0700
Last post2016-06-15 11:47 -0400
Articles 5 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  GoPiGo distence sensor ldompeling@casema.nl - 2016-06-15 07:15 -0700
    Re: GoPiGo distence sensor Joel Goldstick <joel.goldstick@gmail.com> - 2016-06-15 10:59 -0400
    Re: GoPiGo distence sensor MRAB <python@mrabarnett.plus.com> - 2016-06-15 16:00 +0100
    Re: GoPiGo distence sensor Joel Goldstick <joel.goldstick@gmail.com> - 2016-06-15 11:13 -0400
    Re: GoPiGo distence sensor William Ray Wing <wrw@mac.com> - 2016-06-15 11:47 -0400

#109970 — GoPiGo distence sensor

Fromldompeling@casema.nl
Date2016-06-15 07:15 -0700
SubjectGoPiGo distence sensor
Message-ID<24fc1dae-5411-44fa-89e2-d2859d27594f@googlegroups.com>
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.

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.

[toc] | [next] | [standalone]


#109976

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2016-06-15 10:59 -0400
Message-ID<mailman.73.1466002791.2288.python-list@python.org>
In reply to#109970
On Wed, Jun 15, 2016 at 10:15 AM,  <ldompeling@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.
>
> 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

[toc] | [prev] | [next] | [standalone]


#109977

FromMRAB <python@mrabarnett.plus.com>
Date2016-06-15 16:00 +0100
Message-ID<mailman.74.1466002814.2288.python-list@python.org>
In reply to#109970
On 2016-06-15 15:15, ldompeling@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.
>
> 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.
>
Check the distance at regular intervals, like the ticks of a clock.

At each tick, check the distance.

If the distance is the same as the previous measurement, increment a 
counter, else reset the counter.

If the counter reaches a certain value, it means that the robot has been 
at that distance for that many ticks. (If it checks every second and the 
counter reaches 5, then it has been at that distance for 5 seconds ... 
approximately ...)

[toc] | [prev] | [next] | [standalone]


#109978

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2016-06-15 11:13 -0400
Message-ID<mailman.75.1466003902.2288.python-list@python.org>
In reply to#109970
On Wed, Jun 15, 2016 at 11:00 AM, MRAB <python@mrabarnett.plus.com> wrote:
> On 2016-06-15 15:15, ldompeling@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.
>>
>> 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.
>>
> Check the distance at regular intervals, like the ticks of a clock.
>
> At each tick, check the distance.
>
> If the distance is the same as the previous measurement, increment a
> counter, else reset the counter.
>
> If the counter reaches a certain value, it means that the robot has been at
> that distance for that many ticks. (If it checks every second and the
> counter reaches 5, then it has been at that distance for 5 seconds ...
> approximately ...)
>
> --
> https://mail.python.org/mailman/listinfo/python-list

This reminds me of a toy called 'Big Trak' made by Milton Bradley in
the 1980s https://en.wikipedia.org/wiki/Big_Trak

-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays

[toc] | [prev] | [next] | [standalone]


#109982

FromWilliam Ray Wing <wrw@mac.com>
Date2016-06-15 11:47 -0400
Message-ID<mailman.77.1466009262.2288.python-list@python.org>
In reply to#109970
> On Jun 15, 2016, at 10:59 AM, Joel Goldstick <joel.goldstick@gmail.com> wrote:
> 
> On Wed, Jun 15, 2016 at 10:15 AM,  <ldompeling@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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web