User Tools

Site Tools


quadricone-python-urbaines

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
quadricone-python-urbaines [2012/11/24 20:44]
85.218.109.130 created
quadricone-python-urbaines [2013/04/22 17:09] (current)
zoza old revision restored
Line 30: Line 30:
     def stop(self):     def stop(self):
         self.move(90)         self.move(90)
 +        print "​stop"​
  
     def down_slow(self):​     def down_slow(self):​
         self.move(100)         self.move(100)
 +        print "down slow"
  
     def down(self):     def down(self):
         self.move(120)         self.move(120)
 +        print "​down"​
  
     def up(self):     def up(self):
         self.move(80)         self.move(80)
-        ​+        ​print "​up"​ 
 ## initiate the morots and put them all in the STOP (90) position ## initiate the morots and put them all in the STOP (90) position
 ## alternative ## alternative
Line 47: Line 51:
     globals()[servo]=Servo(i+1)     globals()[servo]=Servo(i+1)
     globals()[servo].stop()     globals()[servo].stop()
-    ​+ 
 +random.shuffle(Servos) 
 + 
 +how_many_times = [0, 0, 0, 0] 
  
 ### the scanning part ----------------- ### the scanning part -----------------
Line 77: Line 85:
         results.append(datas[i])         results.append(datas[i])
     return results     return results
- 
  
 ### the main loop ---------------------- ### the main loop ----------------------
Line 83: Line 90:
 packet_list=lookup(csv_last) packet_list=lookup(csv_last)
 print '​packet_list',​ packet_list print '​packet_list',​ packet_list
-#​random.shuffle(servo_list) 
 #print '​servo_list',​ servo_list #print '​servo_list',​ servo_list
 time.sleep(3) time.sleep(3)
Line 98: Line 104:
         print '​packet_diff:',​ packet_diff         print '​packet_diff:',​ packet_diff
         if packet_diff==0:​         if packet_diff==0:​
-            print 'go back up' +            print 'packetdiff:'packet_diff'; go back up'
-            globals()[servo].up() +
-            time.sleep(1) +
-            globals()[servo].stop() +
-        elif packet_diff ​< 10: +
-            print 'up, little' +
-            globals()[servo].up() +
-            time.sleep(0.5)+
             globals()[servo].stop()             globals()[servo].stop()
-        elif packet_diff >= 10: +            ​time.sleep(0.3)
-            print 'down, little'​ +
-            globals()[servo].down_slow() +
-            ​time.sleep(1)+
             globals()[servo].stop()             globals()[servo].stop()
-        elif packet_diff >= 100+        elif 0 < packet_diff < 7: 
-            print 'go down, big'+            if how_many_times[i]<​=6:​ 
 +                print '​packetdiff:',​ packet_diff,​ '; up, little'​ 
 +                globals()[servo].down_slow() 
 +                time.sleep(0.5) 
 +                globals()[servo].stop() 
 +                how_many_times[i]+=0.5 
 +            else: 
 +                globals()[servo].stop() 
 +                time.sleep(0.3) 
 +                how_many_times[i]-=2 
 +        elif 40 > packet_diff >= 7
 +            ​if how_many_times[i]<​=6:​ 
 +                ​print 'packetdiff:',​ packet_diff,​ '; down, little'​ 
 +                globals()[servo].down() 
 +                time.sleep(0.5) 
 +                globals()[servo].stop() 
 +                how_many_times[i]+=0.5 
 +            else: 
 +                globals()[servo].stop() 
 +                time.sleep(0.3) 
 +                how_many_times[i]-=2 
 +        elif 90 > packet_diff >= 40: 
 +            if how_many_times[i]<​=6:​ 
 +                print '​packetdiff:',​ packet_diff,​ '; go down, 2' 
 +                globals()[servo].down() 
 +                time.sleep(1) 
 +                globals()[servo].stop() 
 +                how_many_times[i]+=1 
 +            else: 
 +                globals()[servo].stop() 
 +                time.sleep(0.3) 
 +                how_many_times[i]-=2 
 +        elif 130 > packet_diff >= 90: 
 +            if how_many_times[i]<​=6:​ 
 +                print '​packetdiff:',​ packet_diff,​ '; go down, 3' 
 +                globals()[servo].down() 
 +                time.sleep(1.5) 
 +                globals()[servo].stop() 
 +                how_many_times[i]+=1.5 
 +            else: 
 +                globals()[servo].stop() 
 +                time.sleep(0.3) 
 +                how_many_times[i]-=2 
 +        elif packet_diff >= 130: 
 +            print '​packetdiff:',​ packet_diff,​ '; ​go down, 4'
             globals()[servo].down()             globals()[servo].down()
             time.sleep(2)             time.sleep(2)
             globals()[servo].stop()             globals()[servo].stop()
 +            how_many_times[i]+=2
     packet_list=new_packet_list # update packet list     packet_list=new_packet_list # update packet list
-    time.sleep(15)+    ​print "how many times?",​ how_many_times 
 +    ​time.sleep(1)
  
 </​code>​ </​code>​
quadricone-python-urbaines.1353789875.txt.gz · Last modified: 2012/11/24 20:44 by 85.218.109.130