Skip to content
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

Open
wants to merge 93 commits into
base: develop
Choose a base branch
from
Open

Waterford Competition Changes #36

wants to merge 93 commits into from

Conversation

a2aaron
Copy link
Contributor

@a2aaron a2aaron commented Mar 20, 2018

This PR adds way too much, including

  1. New (working?) autonomous routines
  2. EncoderAutonomous, GrabberAutonomous and ElevatorAutonomous Added
  3. Deadzones added to controls (mainly operator trigger and stick)
  4. Improved VisionSocket that can choose to look for specific objects
  5. Improved VisionAuto that can choose to follow after specific objects
  6. Update a ton of PID and autonomous constants
  7. Take measurements of the field

a2aaron and others added 30 commits February 26, 2018 20:54
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.
a2aaron and others added 29 commits March 10, 2018 16:19
…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()
Copy link
Member

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.

Copy link
Member

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
Copy link
Member

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)

Copy link
Member

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
Copy link
Member

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%
Copy link
Member

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:
Copy link
Member

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"]
Copy link
Member

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()
Copy link
Member

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:
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants