Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: William Ray Wing Newsgroups: comp.lang.python Subject: Re: GoPiGo distence sensor Date: Wed, 15 Jun 2016 11:47:20 -0400 Lines: 52 Message-ID: References: <24fc1dae-5411-44fa-89e2-d2859d27594f@googlegroups.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: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <0F618F06-727D-49CD-A1AB-10C0E83CAC58@mac.com> X-Mailman-Original-References: <24fc1dae-5411-44fa-89e2-d2859d27594f@googlegroups.com> Xref: csiph.com comp.lang.python:109982 > On Jun 15, 2016, at 10:59 AM, Joel Goldstick = wrote: >=20 > On Wed, Jun 15, 2016 at 10:15 AM, 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. >>=20 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 =E2=80=9Cus_dist=E2=80=9D function = that seems to read the proximity to an object from an ultrasonic sensor. = I=E2=80=99m 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.=20 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/ >>=20 >> Can someone help me with this. >>=20 >> -- >> https://mail.python.org/mailman/listinfo/python-list >=20 > You can start here: https://www.python.org/about/gettingstarted/ >=20 >=20 > --=20 > Joel Goldstick > http://joelgoldstick.com/blog > http://cc-baseballstats.info/stats/birthdays > --=20 > https://mail.python.org/mailman/listinfo/python-list