-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Waterford Competition Changes #36
base: develop
Are you sure you want to change the base?
Conversation
These are correct as of Feburary 26th, 2018
These controls are much less complex and also way easier to test.
The robot now shifts into high gear when holding down the left bumper on the driver controller!
Xbox controllers have an inverted y-axis for some reason, which means that forwards and backwards will be reversed from normal unless we negate it. Also, update some comments
Grabber is now controlled by the operator sticks and the elevator is now controlled by the operator triggers.
…vision somebody finish this please im busy today
I should have tested before I committed oops
INCREASED DISTANCE FOR POST ROTATION
|
||
# Used when the robot starts in the center, no vision implemented at all | ||
def center_straight(grabber, elevator, drivetrain, gyro, vision_socket, switch_position): | ||
yield from Timed(ElevatorAutonomous(elevator, up_speed=0.10)).run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing duration, duration defaults to 0, this won't run. Remove it or set a duration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change duration=0
to duration
in the class, since it never makes sense to create a Timed(…, duration=0)
auto.
print("end elevator 1") | ||
yield from Timed(ArcadeAutonomous(drivetrain, forward=0.7, rotate=0), duration = 1.5).run() | ||
print("end drive 1") | ||
rotate = 0.7 if switch_position == Position.RIGHT else -0.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how well tested this is, but we should leave a note on here to raise the speed and lower the rotate time (or use the gyros)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave an @Todo
def __init__(self, drivetrain, gyro, vision_socket, forward): | ||
def __init__(self, drivetrain, gyro, vision_socket, forward, look_for): | ||
""" | ||
forward is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"forward is the forward speed for the robot to drive while doing vision"
correction = self.correction | ||
# print("self.Correction: ", self.correction) | ||
# print("Correction: ", correction) | ||
correction = math.copysign(self.correction, angle)/3.33 # 30% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm… this means that the PID is not able to suggest a decelerating rotation direction in anticipation of catching up, does this perhaps cause trouble for us?
if self.angle_goal > 0: | ||
self.drivetrain.arcade_drive(0, self.speed * correction_factor) | ||
else: | ||
self.drivetrain.arcade_drive(0, -self.speed * correction_factor) | ||
if angle_error > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! This is bad, this will make us get stuck in the loop if the error is small.
This should probably be something like
if angle_error < 1:
break
yield
@@ -79,18 +82,28 @@ def run(self): | |||
def _read_packet(self, data): | |||
parsed = json.loads(data.decode()) | |||
if parsed["sender"] == "vision": | |||
self.angle = parsed["angle"] | |||
key = parsed["object"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noting here, we need to catch more exceptions in the try/except
above, for instance, we need to catch JSONDecodeError
, which means maybe we should just have a catch-all Exception
case above so the network case doesn't fail.
Alternately, we should catch errors inside _read_packet
and re-throw a uniform error.
@@ -47,7 +50,7 @@ def __init__(self): | |||
except IOError as e: | |||
print("Could not bind: {}".format(e)) | |||
self.last_packet_time = time.time() | |||
self.angle = None | |||
self.vision_dict = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.vision_dict = {}
??
if max_staleness > time.time() - self.last_packet_time: | ||
return self.angle | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return self.vision_dict.get(key)
will do the same job as this try/except
and return None
if missing.
from subsystems.drivetrain import Drivetrain | ||
from subsystems.elevator import Elevator | ||
from subsystems.grabber import Grabber | ||
from subsystems.wings import Wings | ||
from wpilib import DoubleSolenoid, SmartDashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"wpilib.DoubleSolenoid
imported but unused"
self.timer += 1 | ||
|
||
def teleopInit(self): | ||
print("Teleop Init Begin!") | ||
|
||
def teleopPeriodic(self): | ||
# @Todo: Deadzone these | ||
forward = self.driver.getY(RIGHT) | ||
DEADZONE = 0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the @Todo
comment above, these look deadzoned to me.
This PR adds way too much, including
EncoderAutonomous
,GrabberAutonomous
andElevatorAutonomous
AddedVisionSocket
that can choose to look for specific objectsVisionAuto
that can choose to follow after specific objects