Commented out prototype functions.
This commit is contained in:
parent
23ddc2c24a
commit
74e78cf2ee
1 changed files with 54 additions and 2 deletions
54
src/move.py
54
src/move.py
|
@ -3,6 +3,7 @@
|
||||||
import ev3dev.ev3 as ev3
|
import ev3dev.ev3 as ev3
|
||||||
from wheel import Wheel
|
from wheel import Wheel
|
||||||
from sensor import Sensor
|
from sensor import Sensor
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
class Move:
|
class Move:
|
||||||
|
@ -25,9 +26,56 @@ class Move:
|
||||||
'''
|
'''
|
||||||
Function to correct errors should the robot wander astray
|
Function to correct errors should the robot wander astray
|
||||||
'''
|
'''
|
||||||
|
# Probably redundant because aligning can be done while scanning other paths
|
||||||
|
|
||||||
def _aligntoedge(self):
|
def _aligntoedge(self):
|
||||||
|
'''
|
||||||
|
isonedge = False
|
||||||
|
alternatingvalue = 2 # value used to switch turning directions using mod 2 hence theres only two possible values when you keep increasing the value
|
||||||
|
if(self._sensor.getbrightness() < 24):
|
||||||
|
while (not (self._sensor.getbrightness() == 24)):
|
||||||
|
self._wheel_l.speed_set(5)
|
||||||
|
self._wheel_r.speed_set(-5)
|
||||||
|
elif(self._sensor.getbrightness() > 24):
|
||||||
|
while (not isonedge):
|
||||||
|
if alternatingvalue % 2 == 0:
|
||||||
|
isonedge = self._findedgeonrightside(alternatingvalue)
|
||||||
|
self._wheel_l.stop()
|
||||||
|
self._wheel_r.stop()
|
||||||
|
if alternatingvalue % 2 == 1:
|
||||||
|
isonedge = self._findedgeonleftside(alternatingvalue)
|
||||||
|
self._wheel_l.stop()
|
||||||
|
self._wheel_r.stop()
|
||||||
|
alternatingvalue = alternatingvalue + 1
|
||||||
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
'''
|
||||||
|
def _findedgeonleftside(self, alternatingvalue):
|
||||||
|
i = 0
|
||||||
|
while i < alternatingvalue:
|
||||||
|
self._wheel_r.speed_set(5)
|
||||||
|
self._wheel_l.speed_set(-5)
|
||||||
|
if (self._sensor.getbrightness() == 24):
|
||||||
|
return True
|
||||||
|
i = i + 1
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _findedgeonrightside(self, alternatingvalue):
|
||||||
|
i = 0
|
||||||
|
while i < alternatingvalue:
|
||||||
|
self._wheel_l.speed_set(5)
|
||||||
|
self._wheel_r.speed_set(-5)
|
||||||
|
if (self._sensor.getbrightness() == 24):
|
||||||
|
time.sleep(0.05)
|
||||||
|
while(not (self._sensor.getbrightness() == 24)):
|
||||||
|
self._wheel_l.speed_set(5)
|
||||||
|
self._wheel_r.speed_set(-5)
|
||||||
|
return True
|
||||||
|
i = i + 1
|
||||||
|
return False
|
||||||
|
'''
|
||||||
|
|
||||||
'''
|
'''
|
||||||
uses odometry and the planet object to map edges that are connected to
|
uses odometry and the planet object to map edges that are connected to
|
||||||
current node.
|
current node.
|
||||||
|
@ -44,12 +92,16 @@ class Move:
|
||||||
self._wheel_r.speed_set(24)
|
self._wheel_r.speed_set(24)
|
||||||
self._wheel_l.run()
|
self._wheel_l.run()
|
||||||
self._wheel_r.run()
|
self._wheel_r.run()
|
||||||
|
<<<<<<< HEAD
|
||||||
while (not (self._bumper.value() or self._sensor.isRed() or self._sensor.isBlue())):
|
while (not (self._bumper.value() or self._sensor.isRed() or self._sensor.isBlue())):
|
||||||
self._wheel_l.speed_set(48 - self._sensor.getbrightness())
|
self._wheel_l.speed_set(48 - self._sensor.getbrightness())
|
||||||
self._wheel_r.speed_set(self._sensor.getbrightness())
|
self._wheel_r.speed_set(self._sensor.getbrightness())
|
||||||
if(isknownstation == False):
|
if(isknownstation == False):
|
||||||
pass #run odometry stuff here
|
pass #run odometry stuff here
|
||||||
|
|
||||||
|
if (not self._bumper.value()):
|
||||||
|
time.sleep(1)
|
||||||
|
# self._aligntoedge()
|
||||||
|
|
||||||
self._wheel_l.stop()
|
self._wheel_l.stop()
|
||||||
self._wheel_r.stop()
|
self._wheel_r.stop()
|
||||||
|
|
Loading…
Reference in a new issue