Announcement

Collapse
No announcement yet.

Coding Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Coding Error

    When checking over my code, it always says that "Method 'init()' is never used. The at '@Override' text above 'public void init()' is always underlined in red like it has a spelling error. Does anyone know why this is. Any code that has 'public void init()' it always does that.

    When I implement methods, it has 'start()' 'loop()' and 'stop()' it doesn't have 'init()'

    Code:
    package com.qualcomm.ftcrobotcontroller.opmodes;
    
    import com.qualcomm.robotcore.eventloop.opmode.OpMode;
    import com.qualcomm.robotcore.hardware.DcMotor;
    import com.qualcomm.robotcore.hardware.Servo;
    
    /**
     * Created by joshuanuti on 9/23/15.
     */
    public class testClass extends OpMode {
    
        DcMotor motor1;
        Servo servo1;
    
        @Override
        public void init() {
            //References Robot Configuration to variable leftMotor
            motor1 = hardwareMap.dcMotor.get("motor1");
            servo1 = hardwareMap.servo.get("servo1");
        }
    
        @Override
        public void loop() {
            //Sets Gamepad1.leftY to control motor 1
            float leftY = -gamepad1.left_stick_y;
            motor1.setPower(leftY);
    
            //if gamepad1.a is pressed then servoposition(1)
            //if not then servoposition(0)
            if(gamepad1.a){
                servo1.setPosition(1.0);
            }else{
                servo1.setPosition(0.0);
            }
        }
    
        @Override
        public void stop() {
            //Motor set to 0 power
            //Servo set to position1
            motor1.setPower(0);
            servo1.setPosition(1.0);
        }
    
    }
    Kryptonian Eagles
    Team #7400
    keagles7400.webs.com
    @keagles7400

  • #2
    The method has undergone a few renames as time passed, and might be called start() if you have an older ftc_app version.
    FTC6460 mentor (software+computer vision+electronics), FPGA enthusiast. In favor of allowing custom electronics on FTC bots.
    Co-founder of ##ftc live chat for FTC programming--currently you may need to join and wait some time for help--volunteer basis only.

    Comment


    • #3
      Are you using the same name for your java class. In your case, it has to be testClass.
      public class testClass extends OpMode {

      -Nano Ninjas

      Comment

      Working...
      X