Announcement

Collapse
No announcement yet.

Error Opmode (opmode name) is stuck in stop()

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

  • Error Opmode (opmode name) is stuck in stop()

    We are trying to run our autonomous but when we run it we get the error "Opmode (opmode name) is stuck in stop()". We aren't sure what is causing it.
    Also the motors continue running til the end of the 30 autonomous period sometimes after.

  • #2
    It would help if you provide the relevant parts of your code.
    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
      I am having the same problems. Here is my code
      Code:
      package org.firstinspires.ftc.teamcode;
      
      
      import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
      import com.qualcomm.robotcore.eventloop.opmode.OpMode;
      import com.qualcomm.robotcore.hardware.DcMotor;
      import com.qualcomm.robotcore.hardware.DcMotorSimple;
      
      
      import static java.lang.Thread.sleep;
      
      
      
      
      @com.qualcomm.robotcore.eventloop.opmode.Autonomous(name = "Autonomous", group = "Autonomous")
      public class Autonomous extends LinearOpMode{
         DcMotor motorRight = null;
         DcMotor motorLeft = null;
      
      
      
      
      
      
      
      
         public void waitForStart(){
             motorRight = hardwareMap.dcMotor.get("right");
             motorLeft = hardwareMap.dcMotor.get("left");
      
      
      
      
             motorLeft.setDirection(DcMotorSimple.Direction.REVERSE);
      
      
      
      
         }
      
      
      
      
         public void runOpMode() throws InterruptedException {
             DriveForward(1);
      
      
             Time(2000);
      
      
      
      
      
      
             TurnLeft(1);
      
      
             Time(600);
      
      
      
      
      
      
             TurnRight(1);
      
      
             Time(1200);
      
      
      
      
      
      
             DriveForward(1);
      
      
      
      
      
      
      
      
      
      
             Time(3000);
      
      
      
      
      
      
      
      
      
      
      
      
             Stop();
         }
      
      
      
      
         public void DriveForward(double power){
             motorLeft.setPower(power);
             motorRight.setPower(power);
         }
         public void TurnLeft(double power){
             motorLeft.setPower(-power);
             motorRight.setPower(power);
         }
         public void TurnRight(double power){
             motorLeft.setPower(power);
             motorRight.setPower(-power);
         }
         public void Stop(){
             DriveForward(0);
         }
         public void Time(long Time) throws InterruptedException {
      
      
      
      
       sleep(Time);
      
      
      
      
         }
      
      
      }
      It has some functions which is why it looks different. Do you have any idea what is causing this?

      Comment


      • #4
        Originally posted by patfanman101 View Post
        I am having the same problems. Here is my code
        Our kids were having this problem ("stuck in stop()") and when we compared their code to the Pushbot example we noticed that the "throws InterruptedException" after "public void runOpMode()" was not in the Pushbot code.

        However, they have not tried deleting the line just yet, but plan to do so today.
        FTC 4962 / 3638
        FLL 11 / 21 / 9293

        Comment


        • #5
          I cleaned up your code, and I think I fixed the issues. Please try this code:

          Code:
          package org.firstinspires.ftc.teamcode;
          
          import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
          import com.qualcomm.robotcore.hardware.DcMotor;
          import com.qualcomm.robotcore.hardware.DcMotorSimple;
          
          @com.qualcomm.robotcore.eventloop.opmode.Autonomous(name = "Autonomous", group = "Autonomous")
          public class Autonomous extends LinearOpMode
          {
              DcMotor motorRight;
              DcMotor motorLeft;
          
              public void runOpMode() throws InterruptedException
              {
                  /* Start init ---------------------------------------------*/
                  motorRight = hardwareMap.dcMotor.get("right");
                  motorLeft = hardwareMap.dcMotor.get("left");
          
                  motorLeft.setDirection(DcMotorSimple.Direction.REVERSE);
                  /* End init ------------------------------------------------*/
          
                  //Wait for the user to press start
                  waitForStart();
          
                  //The actual autonomous code
                  driveForward(1);
                  time(2000);
                  turnLeft(1);
                  time(600);
                  turnRight(1);
                  time(1200);
                  driveForward(1);
                  time(3000);
                  stopMotors();
              }
          
              public void driveForward(double power)
              {
                  motorLeft.setPower(power);
                  motorRight.setPower(power);
              }
          
              public void turnLeft(double power)
              {
                  motorLeft.setPower(-power);
                  motorRight.setPower(power);
              }
          
              public void turnRight(double power)
              {
                  motorLeft.setPower(power);
                  motorRight.setPower(-power);
              }
          
              public void stopMotors()
              {
                  driveForward(0);
              }
          
              public void time(long Time) throws InterruptedException
              {
                  sleep(Time);
              }
          }

          Comment


          • #6
            Thanks. I'll try it.

            Comment


            • #7
              Originally posted by BSV View Post
              Our kids were having this problem ("stuck in stop()") and when we compared their code to the Pushbot example we noticed that the "throws InterruptedException" after "public void runOpMode()" was not in the Pushbot code.
              It depends on what SDK version you are using. For anything 2.3 (10/5/2016) or later you do not use the "throws InterruptedException" or the "idle()" at the end of a loop controlled by opModeIsActive().

              If you are using an earlier SDK then you need both of these statements.

              Comment


              • #8
                I agree with FTC8767. However, if you do not have the highest SDK, you need to upgrade.

                Comment


                • #9
                  Originally posted by FTC8767 View Post
                  It depends on what SDK version you are using. For anything 2.3 (10/5/2016) or later you do not use the "throws InterruptedException" or the "idle()" at the end of a loop controlled by opModeIsActive().

                  If you are using an earlier SDK then you need both of these statements.
                  But I don't think that having them would hurt anything, right?

                  Comment


                  • #10
                    Originally posted by FTC8767 View Post
                    It depends on what SDK version you are using. For anything 2.3 (10/5/2016) or later you do not use the "throws InterruptedException" or the "idle()" at the end of a loop controlled by opModeIsActive().

                    If you are using an earlier SDK then you need both of these statements.
                    In our case, we are using 2.35 and it only happens when they push the stop button to interrupt autonomous.

                    The program normally runs to the end with no issues if the stop button is not pushed.
                    FTC 4962 / 3638
                    FLL 11 / 21 / 9293

                    Comment


                    • #11
                      I still have to use "throws InterruptedException" in my code since it gives exception errors but it's intended and my code runs fine. However, the "Stuck in Loop" error usually occurs for me when I don't stop or reset the motors at the end or even give enough time to let the initialization happen.

                      Comment


                      • #12
                        Originally posted by FTC8564 View Post
                        I still have to use "throws InterruptedException" in my code since it gives exception errors but it's intended and my code runs fine. However, the "Stuck in Loop" error usually occurs for me when I don't stop or reset the motors at the end or even give enough time to let the initialization happen.
                        They tried removing the "throws InterruptedException" and it made no difference.

                        Even if they push the stop button right after they push the init button it crashes with that error.

                        It runs fine if they never hit the stop button, otherwise the robot controller crashes.
                        FTC 4962 / 3638
                        FLL 11 / 21 / 9293

                        Comment


                        • #13
                          Originally posted by BSV View Post
                          .

                          It runs fine if they never hit the stop button, otherwise the robot controller crashes.
                          Well, during the actual autonomous period in the competition, you can't press stop so you shouldn't have an issue. Because no matter what, it is illegal to stop autonomous mode during the autonomous period.

                          Comment


                          • #14
                            Originally posted by BSV View Post
                            They tried removing the "throws InterruptedException" and it made no difference.

                            Even if they push the stop button right after they push the init button it crashes with that error.

                            It runs fine if they never hit the stop button, otherwise the robot controller crashes.
                            May I see your code?

                            Comment


                            • #15
                              Originally posted by 4634 Programmer View Post
                              But I don't think that having them would hurt anything, right?
                              No I don't think this should be causing your problem, just explaining why your code was different than the Pushbot code.

                              Comment

                              Working...
                              X