garykac / amhs-robotics-4681

Repository for AMHS's FRC (FIRST Robotics Competition) team
3 stars 0 forks source link

AutoLift #40

Closed cmarley3-14 closed 5 years ago

cmarley3-14 commented 5 years ago

Before anything is committed and pushed from the robotics computers...

There's a few things we can do to improve the code for the automated lifter.

  1. Combine all the goTo____() functions in the Lifter class into one function. There is also code in here that helps with the lifter being too sensitive. If the old code is about the same as this, use it. Here's some example code that may work for our purposes though. It requires testing, of course.
boolean reached = false;
int offset = 5;
def gotoHeight(int targetHeight) {
    if m_height.getDistance() < (targetHeight + offset) && !reached {
        m_winch.Lift();
    } else {
        reached = true;
    }
    if m_height.getDistance() < (targetHeight - offset) && reached {
        reached = false;
    }
    if m_height.getDistance() > (targetHeight + 5) {
        m_winch.Lower()
  1. Move the autoLift switch statement out of Robot.java and into the Lifter class, and put it under a function. We can keep modeAdder in Robot.java. We may have to define a new function to fit the above example. Something along the lines of in Robot.java: m_lifter.gotoLevel(int ID) and in Lifter.java:
    def gotoLevel(int ID) {
    switch ID {
        // Put switch statement from auto lift in here.

I thing the relevant levels we need are Hatch: 1, 2, 3 and Cargo: floor, 1, cargoShip, and 2.

And then we can keep the LIDAR stuff in the LifterHeight class.