2018-03-18 14:23:17 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2018-03-19 00:03:35 +01:00
|
|
|
import ev3dev.ev3 as ev3
|
2018-03-18 14:23:17 +01:00
|
|
|
from wheel import Wheel
|
|
|
|
from sensor import Sensor
|
|
|
|
|
|
|
|
|
|
|
|
class Move:
|
|
|
|
def __init__(self, planet):
|
2018-03-22 02:14:44 +01:00
|
|
|
try:
|
|
|
|
self._wheel_l = Wheel('outB')
|
|
|
|
self._wheel_r = Wheel('outC')
|
2018-03-22 04:36:37 +01:00
|
|
|
self._camera = Sensor()
|
2018-03-22 02:14:44 +01:00
|
|
|
self._bumper = ev3.TouchSensor()
|
2018-03-22 07:09:30 +01:00
|
|
|
except OSError:
|
2018-03-22 02:14:44 +01:00
|
|
|
print("ERROR: Cannot find Motor/Sensor")
|
2018-03-18 14:23:17 +01:00
|
|
|
|
2018-03-19 00:44:57 +01:00
|
|
|
'''
|
|
|
|
determine maximum and minimum brightness of lines/white space
|
|
|
|
depending on environment lighting
|
|
|
|
'''
|
2018-03-18 14:23:17 +01:00
|
|
|
def _calibrate(self):
|
|
|
|
pass
|
|
|
|
|
2018-03-19 00:44:57 +01:00
|
|
|
'''
|
|
|
|
Function to correct errors should the robot wander astray
|
|
|
|
'''
|
2018-03-21 14:54:24 +01:00
|
|
|
# Probably redundant because aligning can be done while scanning other paths
|
|
|
|
|
2018-03-18 14:23:17 +01:00
|
|
|
def _aligntoedge(self):
|
|
|
|
pass
|
2018-03-19 00:03:35 +01:00
|
|
|
|
2018-03-19 00:44:57 +01:00
|
|
|
'''
|
|
|
|
uses odometry and the planet object to map edges that are connected to
|
|
|
|
current node.
|
2018-03-19 02:46:25 +01:00
|
|
|
|
|
|
|
Use either relative motor pos or timed driving to center on node.
|
|
|
|
Next turn around and detect edges through drops in _sensor.getbrightness()
|
2018-03-19 00:44:57 +01:00
|
|
|
'''
|
2018-03-19 00:03:35 +01:00
|
|
|
def getstationedges(self):
|
2018-03-19 10:14:42 +01:00
|
|
|
self._wheel_l.turnbyamount(500, 250)
|
|
|
|
self._wheel_r.turnbyamount(-500, 250)
|
2018-03-19 00:03:35 +01:00
|
|
|
|
|
|
|
def traversetonextstation(self, isknownstation):
|
2018-03-19 10:14:42 +01:00
|
|
|
self._wheel_l.speed_set(24)
|
|
|
|
self._wheel_r.speed_set(24)
|
2018-03-19 00:03:35 +01:00
|
|
|
self._wheel_l.run()
|
|
|
|
self._wheel_r.run()
|
2018-03-22 07:09:30 +01:00
|
|
|
while (self._bumper.value() == False and self._camera.lastcolor == None):
|
|
|
|
self._camera.refresh()
|
2018-03-22 09:56:11 +01:00
|
|
|
self._wheel_l.speed_set((60 - (self._camera.getbrightness()/5))-4)
|
|
|
|
self._wheel_r.speed_set((self._camera.getbrightness()/5))
|
2018-03-22 04:36:37 +01:00
|
|
|
self._camera.getcolor()
|
2018-03-19 00:03:35 +01:00
|
|
|
if(isknownstation == False):
|
2018-03-22 04:36:37 +01:00
|
|
|
pass # run odometry stuff here
|
2018-03-21 14:54:24 +01:00
|
|
|
|
2018-03-19 00:03:35 +01:00
|
|
|
self._wheel_l.stop()
|
|
|
|
self._wheel_r.stop()
|