Funca giro y avance con contador de negros en la entrada, logica invertida y…

Funca giro y avance con contador de negros en la entrada, logica invertida y alguna cosa mas al anterior commit
parent 2a69bc65
Showing with 7 additions and 5 deletions
...@@ -12,9 +12,10 @@ robot = Robot() ...@@ -12,9 +12,10 @@ robot = Robot()
robot.sigueLineaHastaNegro() robot.sigueLineaHastaNegro()
robot.sigueLineaHastaNegro() robot.sigueLineaHastaNegro()
robot.sigueLineaHastaNegro()
#robot.sigueLineaHastaNegro() #robot.sigueLineaHastaNegro()
#robot.giro(90)
#robot.sigueLineaHastaNegro() #robot.sigueLineaHastaNegro()
robot.giro2(90)
robot.sigueLineaHastaNegro()
robot.giro2(-90)
#robot.calibraSensorColor() #robot.calibraSensorColor()
...@@ -74,6 +74,7 @@ class Robot: ...@@ -74,6 +74,7 @@ class Robot:
self.robot.turn(-1) self.robot.turn(-1)
def giro2(self,grados): def giro2(self,grados):
self.robot.straight(60)
self.giroSensor.reset_angle(0) self.giroSensor.reset_angle(0)
self.robot.turn(grados) self.robot.turn(grados)
while (self.giroSensor.angle() != grados): while (self.giroSensor.angle() != grados):
...@@ -97,7 +98,7 @@ class Robot: ...@@ -97,7 +98,7 @@ class Robot:
contNegroAnterior = self.contadorNegros contNegroAnterior = self.contadorNegros
if self.is_black(rgb): if self.is_black(rgb):
self.negroFlag = True self.negroFlag = True
while (((self.queNegroEs(contNegroAnterior) == 0) and (self.queNegroEs(self.contadorNegros) == 1)) == False) or self.contadorNegros == 1: while (((self.queNegroEs(contNegroAnterior) == 1) and (self.queNegroEs(self.contadorNegros) == 0)) == False) or self.contadorNegros == 0:
#Fase de lectura #Fase de lectura
rgb = self.colorSensor.rgb() rgb = self.colorSensor.rgb()
if self.is_green(rgb): if self.is_green(rgb):
...@@ -118,8 +119,8 @@ class Robot: ...@@ -118,8 +119,8 @@ class Robot:
self.velocidad = 50 self.velocidad = 50
#Fase de ejecución #Fase de ejecución
#Incremento negro al salir #Incremento negro al entrar
if negroAnteriorFlag and not self.negroFlag: if not negroAnteriorFlag and self.negroFlag:
contNegroAnterior = self.contadorNegros contNegroAnterior = self.contadorNegros
self.incrementaContNegros() self.incrementaContNegros()
......
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