This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because I'am an ignorant ahole, I just wrote a small generator idea t…
…est based off of my idea of commands to see how it will work. Testing it tonight, but I am still sticking to magic bot.
- Loading branch information
Krypton Cougars
committed
Jan 30, 2020
1 parent
f9a4026
commit 13befd3
Showing
7 changed files
with
96 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from components.colorsensor.colorwheel import ColorWheel | ||
|
||
from generator import Generator | ||
|
||
import robot | ||
|
||
class AutoSpinWheel(Generator): | ||
def __init__(self): | ||
super(AutoSpinWheel, self).__init__() | ||
|
||
def initialize(self): | ||
robot.mockcommand.getColor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Generator: | ||
|
||
def __init__(self): | ||
self.initialize() | ||
while not self.isFinished(): | ||
self.execute() | ||
yield | ||
self.end() | ||
|
||
def initialize(self): | ||
print('No i ran') | ||
pass | ||
|
||
def execute(self): | ||
pass | ||
|
||
def isFinished(self): | ||
return True # change as needed | ||
|
||
def interrupted(self): | ||
pass # probably will never use | ||
|
||
def end(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from magicbot import StateMachine, state | ||
|
||
from components.colorsensor.colorwheel import ColorWheel | ||
|
||
class AutoSetColor(StateMachine): | ||
wheelactions: ColorWheel | ||
|
||
def __init__(self): | ||
self.colors = ['y', 'r', 'g', 'b'] | ||
self.direction = True | ||
self.colorDistance = 37.56 # 11.8", 37.56 rotations (30:1 + 3" diameter) | ||
|
||
def autoSetColor(self): | ||
self.engage() | ||
|
||
@state(first=True) | ||
def getColorAndNeeded(self): | ||
self.myColor = self.wheelactions.getColor() # Make sure this provides the correct value, not an assumption | ||
self.desiredColor = 'r' # Make this come from FMS later. NOTE: If not a string, simply use a dictionary instead. | ||
|
||
# Forward? | ||
if self.colors[self.myColor] < self.colors[self.desiredColor]: | ||
self.direction = True | ||
elif self.colors[self.myColor] > self.colors[self.desiredColor]: | ||
self.direction = False | ||
else: | ||
self.direction = None | ||
|
||
self.next_state_now(spinWheel) | ||
|
||
def spinWheel(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Probably won't need this, just do it in the component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters