Funcion de giro funciona

parent 3fe3741a
Showing with 16 additions and 0 deletions
...@@ -17,3 +17,19 @@ right_motor = Motor(Port.D) ...@@ -17,3 +17,19 @@ right_motor = Motor(Port.D)
giroSensor = GyroSensor(Port.S1) giroSensor = GyroSensor(Port.S1)
robot = DriveBase(left_motor, right_motor, wheel_diameter=55.5, axle_track=124) robot = DriveBase(left_motor, right_motor, wheel_diameter=55.5, axle_track=124)
#Metodo para el giro
def giro(grados):
robot.reset()
giroSensor.reset_angle(0)
robot.turn(grados)
while(giroSensor.angle() != grados):
diferencia = giroSensor.angle() - grados
ajuste = diferencia * -1
for i in range(abs(ajuste)):
if(ajuste > 0):
robot.turn(1)
else:
if (ajuste < 0):
robot.turn(-1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment