In [1]:
import time
from pyluos import Robot

In [2]:
robot = Robot('wifi_phenix.local')

In [3]:
robot.modules


Out[3]:
[<Motor alias="motor_1" id=2 state=90>,
 <Motor alias="motor_2" id=3 state=90>,
 <Distance alias="dist_soleil" id=4 state=22>]

In [4]:
commande = Robot('wifi_canard.local')

In [5]:
commande.modules


Out[5]:
[<Button alias="button_chouffe" id=2 state=OFF>,
 <Potard alias="potard_banane" id=3 state=56>]

In [6]:
def move(speed, direction):
    drive_lag = max(1.0 - abs(2.0 * direction), -1)
    if direction > 0:
        drive_m1 = 1.0
        drive_m2 = drive_lag
    else:
        drive_m1 = drive_lag
        drive_m2 = 1.0
    robot.motor_1.position = 90 - (speed * drive_m1) * 10
    robot.motor_2.position = 90 + (speed * drive_m2) * 10

In [ ]:
while True:
    drive = commande.potard_banane.position / 50.0 - 1.0
    if commande.button_chouffe.state == 'ON':
        move(1.0, drive)
    else:
        move(0, drive)

In [13]:
while True:
    if robot.dist_soleil.distance < 30 and commande.button_chouffe.state == 'ON':
        drive = commande.potard_banane.position / 50.0 - 1.0
        move(0.5, drive)
    else:
        move(0, 0)


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-13-1e624220a252> in <module>()
      4         move(0.5, drive)
      5     else:
----> 6         move(0, 0)

<ipython-input-8-143e96049f6a> in move(speed, direction)
      8         drive_m2 = 1.0
      9     robot.motor_1.position = 90 - (speed * drive_m1) * 10
---> 10     robot.motor_2.position = 90 + (speed * drive_m2) * 10

/Users/jgrizou/Dropbox/projects/pollen/pyrobus/robus/modules/motor.py in position(self, new_pos)
     11         return self._value
     12 
---> 13     @position.setter
     14     def position(self, new_pos):
     15         if new_pos != self._value:

KeyboardInterrupt: 

In [12]:
robot.dist_soleil.distance


Out[12]:
60

In [15]:
move(0, 0)

In [ ]:


In [ ]: