garykac / amhs-robotics-4681

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

Climbing Steps- Timing #24

Closed cmarley3-14 closed 5 years ago

cmarley3-14 commented 5 years ago

https://github.com/garykac/amhs-robotics-4681/blob/072f45f54e591a2339f70c3f1e5b8542d68057d7/workspace/2019%20DeepSpace/src/main/java/frc/robot/Robot.java#L119 https://github.com/garykac/amhs-robotics-4681/blob/072f45f54e591a2339f70c3f1e5b8542d68057d7/workspace/2019%20DeepSpace/src/main/java/frc/robot/Robot.java#L120

The problem is that Java will not wait until a function is carried out before moving on to the next line of code.

// This is the code from the Walker class
    public void Climb() {
        if (completed == false){
            if (progress == 0) {
                RaiseRobot();
            } else if (progress == 1) {
                Walk();
            } else if (progress == 2) {
                RetractFrontLegs();
            } else if (progress == 3) {
                RetractBackLegs();
            }
        }
    }

All those steps will be executed in rapid succession. The walker won't wait until RaiseRobot() is completed to return progress == 1. Secondly, line 119 only tests when the button is pressed, and not if it is held down. That means, Climb() will only execute for some 20 milliseconds before being cut off. It may be that all the steps of climbing have to be implemented directly into Robot.java, but this is what I think is going to happen, based off last year's coding experience.

RyanDecker123 commented 5 years ago

when i tested this code it worked

RyanDecker123 commented 5 years ago

unless thats not what i coded and someone wrote over it

RyanDecker123 commented 5 years ago

anyways i will just reverse the order of checking so that it can not just go on to the next step

RyanDecker123 commented 5 years ago

i changed it to this if (completed == false){ if (progress == 3) { RetractBackLegs(); } else if (progress == 2) { RetractFrontLegs(); } else if (progress == 1) { Walk(); } else if (progress == 0) { RaiseRobot(); }
}

RyanDecker123 commented 5 years ago

also this should all be apart of "Error handling for Walker state machine"

cmarley3-14 commented 5 years ago

What I meant to say is that the process of extending the pistons takes time, but the code won't take that into account. My mistake, it will execute the entire Climb() function, but each step will happen super quickly (I think, we'll just test that out (if I can come)).

cmarley3-14 commented 5 years ago

As in, the pneumatics system will say that the pistons are extended, even though they aren't finished extending. That's why if you look at the 2018 Power Up code, Andrew had to do a sort of timer in the code. So that each step could be completed, with plenty of time in between.

Finally, I think the robot walks backwards.