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


Groups > comp.lang.python > #109982

Re: GoPiGo distence sensor

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From William Ray Wing <wrw@mac.com>
Newsgroups comp.lang.python
Subject Re: GoPiGo distence sensor
Date Wed, 15 Jun 2016 11:47:20 -0400
Lines 52
Message-ID <mailman.77.1466009262.2288.python-list@python.org> (permalink)
References <24fc1dae-5411-44fa-89e2-d2859d27594f@googlegroups.com> <CAPM-O+zBehWm5QpaL84Pr55N9p+sdE-L+CjLYnaQbvCg0OR0fA@mail.gmail.com> <0F618F06-727D-49CD-A1AB-10C0E83CAC58@mac.com>
Mime-Version 1.0 (Mac OS X Mail 9.3 \(3124\))
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de yl9qt5NCxj7eE+pUqVi0OAqIDvq79fBalb6HqnSvArOQ==
Return-Path <wrw@mac.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'mrab': 0.05; 'encoder': 0.07; 'api': 0.09; 'cc:addr:python-list': 0.09; 'blocked': 0.09; 'url:blog': 0.10; 'assume': 0.11; 'python.': 0.11; 'wed,': 0.15; '10:15': 0.16; '10:59': 0.16; '2016': 0.16; 'api,': 0.16; 'increment': 0.16; 'i\xe2\x80\x99m': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'write.': 0.16; 'wrote:': 0.16; 'received:10.0.1': 0.18; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'saying': 0.22; 'delay': 0.22; 'referring': 0.22; 'am,': 0.23; '(or': 0.23; 'seems': 0.23; 'second': 0.24; 'compare': 0.27; 'moved': 0.27; 'reaches': 0.27; 'received:17': 0.27; 'specify': 0.27; 'function': 0.28; 'this.': 0.28; 'unchanged': 0.29; 'allows': 0.30; 'url:mailman': 0.30; '15,': 0.30; 'seconds': 0.31; 'up.': 0.32; 'related': 0.32; 'returned': 0.32; 'url:python': 0.33; 'point,': 0.33; 'url:listinfo': 0.34; 'previous': 0.34; 'received:10.0': 0.34; 'so,': 0.35; 'clear': 0.35; 'but': 0.36; 'url:org': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; 'being': 0.37; 'say': 0.37; 'someone': 0.38; 'url:mail': 0.40; 'header:MIME-version:1': 0.60; 'your': 0.60; 'back': 0.62; 'distance': 0.63; 'more': 0.63; 'here:': 0.63; 'skip:\xe2 10': 0.70; 'url:info': 0.71; '8bit%:46': 0.76; 'header:In-reply-to:1': 0.84; 'presumably': 0.84; 'url:programming': 0.84; 'wakes': 0.84; 'wheels': 0.84; 'joel': 0.91; 'robot': 0.91
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:,, definitions=2016-06-15_09:,, signatures=0
X-Proofpoint-Spam-Details rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1606150170
In-reply-to <CAPM-O+zBehWm5QpaL84Pr55N9p+sdE-L+CjLYnaQbvCg0OR0fA@mail.gmail.com>
X-Mailer Apple Mail (2.3124)
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=4d515a; t=1466005642; bh=fogDxqiSalnAkqFzlqUFolCwnYTMKLstsYSEd6mmiWw=; h=Content-type:MIME-version:Subject:From:Date:Message-id:To; b=umzT+He1DBVQKYWuWnBTcCyShMIdP2mUa5wgJI8WleartlAoeqJxq95Hl1wME/lwX +IRsFa+CefxycnHhYVPzpMw6L8eN6gTYnHC/YYXolpHo0/a4/mXMpOwQQHVZ/Sz9fL Jgx1iI5wepCpwMw9kbZWmSf3X9IHAlW+1fRV/6OSqtiWCINJuaZRz1XmfJVa/VYYn/ ypl6iuzrEmLRz1Kjaiq4bINL4vc+bJcOAKh4yZ171E/dB/mrH8hgsziqe5QaewQX14 tw9vf9KgUSRohLNLcD6fbjchbQ4BiLbb6twMjOh+7blpHPb0JrwBFMP4+xPOCtLVEg JYNxyglv33DEA==
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <0F618F06-727D-49CD-A1AB-10C0E83CAC58@mac.com>
X-Mailman-Original-References <24fc1dae-5411-44fa-89e2-d2859d27594f@googlegroups.com> <CAPM-O+zBehWm5QpaL84Pr55N9p+sdE-L+CjLYnaQbvCg0OR0fA@mail.gmail.com>
Xref csiph.com comp.lang.python:109982

Show key headers only | View raw


> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web