Programming

Using Threading to Stall the Mineral Gate While

Allowing Other Robot Parts to Move

 

If (a is pressed on the first gamepad) {

        Create a new GateMovement object

        Call the method specified in the thread class on          the GateMovement object

}

 

//Threading is a process that allows a program to run two methods simultaneously; i.e. the

program does not have to run linearly or wait for one process to finish before starting

another

 

Class GateMovement extends Thread {

        Public void run () {

                Set the position of the gate to open

                Sleep the gate for 5 seconds

                Set the position of the gate to closed

}

}

 

Autonomously Hanging at the End of TeleOp:

 

Public void autoHang (Hardware myrobot) {

        Turn to be parallel with the lander, as determined by the gyroscope

        Make a timer object

        Reset timer

        While (timer is less than 2.1 seconds) {

        Power the arm up

        }

 

        Power the arm off

 

        Drive forward for 2 seconds

        Drive to the right for 2 seconds

        Reset timer

        While(timer is less than 3.8 seconds) {

        Power the arm downward

        }

        Latch the first latch into place

        Latch the second latch into place

       Power the arm off

}

 

       If (the x button and the start button are pressed simultaneously on           controller two) {

       autoHang(myrobot);

}

 

Programming in English

This site was designed with the
.com
website builder. Create your website today.
Start Now