Robot Implementation

Link to our github here with full source code.

Defence

For this phase we want to put distraction balls on the arena so that the other robots score our fake balls instead of the ones that would earn them points. We then throw the real balls out of the way. Finally we go back and forth to try to use the flag to prevent others from scoring.

    
             
                // FAKE BALL RELEASE
                rotate(25)                   // rotates until the value of the gyroscope is 25° (pointing at the middle right ball)
                release()                    // releases fake balls

                // GO TO RIGHT BALL
                rotate(-90)                  // rotates to 90° (parallel to the green line)
                while (robot.TOUCH == 0) {   // goes backwards until the touch sensor hits the wall 
                    backward()
                }
                rotate(0)                    // rotates so that it faces the balls

                // GRAB~TROW RIGHT BALL
                while (robot.COLOUR != "GREEN") { // goes forward until the colour sensor detects the green line
                    forward()
                }
                grab()                       // rotates the grabbing arm 360°
                rotate(-60)                  // aims at the middle left ball
                trow()                       // rotates the trowing arm at max speed (hopefully moving the ball)

                //(GO TO ~ GRAB ~ TROW) LEFT BALL
                rotate(-30)                  // positions itself parallel to green line facing the left
                while (robot.TOUCH == 0) {   // goes backwards until the touch sensor hits the wall 
                    backward()               
                }
                forward(90)                  // goes forward 90 cm (so that the ball is under the grabbing arm)
                grab()                       
                trow()                       // throws the ball out of the arena
                
                // BACK AND FORTH
                while (robot.TOUCH == 0) {   // goes backwards until the touch sensor hits the wall 
                    backward()               
                }
                forward(90)                  // goes forward to protect all goals

            
        

Attack

Our strategy for attacking involves primarily relying on our handle_touch sensor. To execute this, we rapidly accelerate to release the ball. Then, we retreat and reorient ourselves against the wall near the desired ball, before rotating to grasp it. Upon securing the ball, we reorient once more and advance while rotating, driving into the common area to shoot. The same methodology is applied to the ball on the opposing side.

            
                // BALL ONBOARD
                forward(110)                 // gets in position to shoot the first ball
                throw()                      // throws the ball with max speed
                backward(80)                 // goes back 80 cm 

                // GRAB LEFT BALL
                rotate(90)                   // parallel to the attacker's line
                while (robot.TOUCH == 0) {   // goes backwards until the touch sensor hits the left wall 
                    backward()               
                }
                rotate(0)                    // faces the ball
                while (robot.COLOUR != "BLACK") { // goes forward until the colour sensor detects the black line
                    forward()
                }
                grab()

                // TROW BALL
                rotate(90)                   // parallel to the attacker's line
                while (robot.TOUCH == 0) {   // goes backwards until the touch sensor hits the left wall 
                    backward()               
                }
                forward(15)                  // positions itself in front of the left basket
                rotate(0)                    //
                forward(80)                  //
                throw()
                backward(80)

                // GRAB RIGHT BALL
                rotate(-90)
                while (robot.TOUCH == 0) {   // goes backwards until the touch sensor hits the right wall 
                    backward()               
                }
                rotate(0)                    //
                while (robot.COLOUR != "BLACK") { // goes forward until the colour sensor detects the black line
                    forward()
                }
                grab()

                // TROW BALL
                rotate(-90)                   // parallel to the attacker's line
                while (robot.TOUCH == 0) {   // goes backwards until the touch sensor hits the right wall 
                    backward()               
                }
                forward(15)                  // positions itself in front of the right basket
                rotate(0)                    //
                forward(80)                  //
                throw()
                backward(80)