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


Groups > comp.lang.python > #98023

Re: GoPiGo script

From MRAB <python@mrabarnett.plus.com>
Newsgroups comp.lang.python
Subject Re: GoPiGo script
Date 2015-10-31 21:12 +0000
Message-ID <mailman.2.1446325950.4463.python-list@python.org> (permalink)
References <mailman.1.1446320553.4463.python-list@python.org> <hm9Zx.4$Zz.2@fe45.am1>

Show all headers | View raw


On 2015-10-31 20:18, input/ldompeling@casema.nl wrote:
>> It does not only print; it also calls enable_servo, servo and fwd
>> repeatedly.
>>
> Then I am misinformed, because someone told me in this group to use while True:
> Is there another function that I can use for to restart this script?
>
The lines that you want to repeat should be indented more than the
'while True' line.

In the code you posted, only the lines from:

     enable_servo()

to:

     print ("forward1x")

were indented more than the 'while True' line, so only those lines will
be repeated.

If you want the lines that follow them also to be repeated, then indent
then too.

>
> In reply to "MRAB" who wrote the following:
>
>> On 2015-10-31 18:59, input/ldompeling@casema.nl wrote:
>> > > The body of the 'while' loop extends from the line:
>> > >
>> > >      enable_servo()
>> > >
>> > > to the line:
>> > >
>> > >      print ("forward1x")
>> > >
>> > > Would that explain it?
>> >
>> > When i run this scipt its only print a lot off print1x.
>> > Do you mean that ?
>> >
>> It does not only print; it also calls enable_servo, servo and fwd
>> repeatedly.
>>
>> >
>> > In reply to "MRAB" who wrote the following:
>> >
>> > > On 2015-10-31 10:28, input/ldompeling@casema.nl wrote:
>> > > > I intended the rules under while True:
>> > > > The script is working now only the wheels go's only forward "(fwd)",so
>> > > > the
>> > > > sensor not detect any obstacles.(sensor=us_dist(15).
>> > > >
>> > > >
>> >
> ----------------------------------------------------------------------------
>> > > > ---
>> > > >
>> > > > from gopigo import *
>> > > > import time
>> > > >
>> > > >
>> > > > set_right_speed(150)
>> > > > set_left_speed(105)
>> > > >
>> > > The body of the 'while' loop extends from the line:
>> > >
>> > >      enable_servo()
>> > >
>> > > to the line:
>> > >
>> > >      print ("forward1x")
>> > >
>> > > Would that explain it?
>> > >
>> > > > while True:
>> > > > #def test():
>> > > >      enable_servo()
>> > > >      mindist = 80
>> > > >      servo(90)
>> > > >      fwd()
>> > > >      print ("forward1x")
>> > > > #time.sleep(5)
>> > > > #stop()
>> > > >
>> > > > if mindist > us_dist(15):
>> > > >       #enc_tgt(1,1,72)
>> > > >      bwd()
>> > > >      print ("backward1x",us_dist(15))
>> > > >      time.sleep(2)
>> > > >      left_rot()
>> > > >      print("left rot",us_dist(15))
>> > > >      time.sleep(3)
>> > > >      stop()
>> > > >
>> > > > if mindist < us_dist(15):
>> > > >     #enc_tgt(1,1,72)
>> > > >      fwd()
>> > > >      print("forward2x",us_dist(15))
>> > > >      time.sleep(2)
>> > > >      stop()
>> > > >
>> > > > for x in range(3):
>> > > >
>> > > >      if mindist > us_dist(15):
>> > > >           bwd()
>> > > >           print("backward2x",us_dist(15))
>> > > >
>
>
>
>

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


Thread

GoPiGo script input/ldompeling@casema.nl - 2015-10-30 16:58 +0000
  Re: GoPiGo script Peter Pearson <pkpearson@nowhere.invalid> - 2015-10-30 17:27 +0000
    Re: GoPiGo script input/ldompeling@casema.nl - 2015-11-02 13:29 +0000
      Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 05:45 -0800
        Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 05:49 -0800
          Re: GoPiGo script input/ldompeling@casema.nl - 2015-11-02 14:28 +0000
            Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 07:19 -0800
            Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-11-02 15:21 +0000
              Re: GoPiGo script hakugin.gin@gmail.com - 2015-11-02 07:30 -0800
      Re: GoPiGo script Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-11-02 09:10 -0500
        Re: GoPiGo script input/ldompeling@casema.nl - 2015-11-02 14:32 +0000
          Re: GoPiGo script Robin Koch <robin.koch@t-online.de> - 2015-11-02 20:31 +0100
            Re: GoPiGo script Larry Hudson <orgnut@yahoo.com> - 2015-11-02 13:06 -0800
              Re: GoPiGo script Robin Koch <robin.koch@t-online.de> - 2015-11-03 01:45 +0100
  Re: GoPiGo script hakugin.gin@gmail.com - 2015-10-30 10:32 -0700
    Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-30 18:18 +0000
      Re: GoPiGo script hakugin.gin@gmail.com - 2015-10-30 12:59 -0700
        Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-31 10:28 +0000
          Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-10-31 17:42 +0000
            Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-31 18:59 +0000
              Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-10-31 19:42 +0000
                Re: GoPiGo script input/ldompeling@casema.nl - 2015-10-31 20:18 +0000
                Re: GoPiGo script MRAB <python@mrabarnett.plus.com> - 2015-10-31 21:12 +0000

csiph-web