Modifications

Sauter à la navigation Sauter à la recherche
724 octets ajoutés ,  17 août 2016 à 19:18
Ligne 152 : Ligne 152 :  
r2.turn(Robot2Wheel.RIGHT_BEND, speed=40)
 
r2.turn(Robot2Wheel.RIGHT_BEND, speed=40)
 
print( 'distance = %i cm' % r2.distance() )
 
print( 'distance = %i cm' % r2.distance() )
 +
</syntaxhighlight>
 +
 +
=== Fonctionnalités avancées ===
 +
Vous pouvez utiliser directement l'objet {{fname|Ultrasonic}}, il est accessible par l'intermédiaire de la propriété {{fname|ultrason}}
 +
 +
<syntaxhighlight lang="python">
 +
>>> from r2wheel import Robot2Wheel
 +
>>> r2 = Robot2Wheel()
 +
>>> r2.ultrason                                                               
 +
<Ultrasonic object at 20005430>
 +
</syntaxhighlight>
 +
 +
Vous pouvez saisir le code suivant en REPL pour obtenir la distance en pouce:
 +
 +
<syntaxhighlight lang="python">
 +
from r2wheel import Robot2Wheel
 +
r2 = Robot2Wheel()
 +
dist = r2.ultrason.distance_in_inches()                                                               
 +
print( 'Distance = %i pouce' % dist )
 
</syntaxhighlight>
 
</syntaxhighlight>
  
29 861

modifications

Menu de navigation