In [1]:
import time
from pyluos import Robot
In [2]:
robot = Robot('wifi_phenix.local')
In [3]:
robot.modules
Out[3]:
In [4]:
commande = Robot('wifi_canard.local')
In [5]:
commande.modules
Out[5]:
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)
In [12]:
robot.dist_soleil.distance
Out[12]:
In [15]:
move(0, 0)
In [ ]:
In [ ]: