Announcement

Collapse
No announcement yet.

Robot controller freezes on Init

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Robot controller freezes on Init

    Hello, I am Edrich from The Fifth Order team from South-Africa.
    Recently we tested our TeleOp and for no reason the RC and DS freezes after Init and at the top of the DS a "S" is is visible. I have rebooted the phones and formatted them, but the problem is still not fixed. We use ZTE Speed phones that is updated to android 4.4.4 KitKat. I would really appreciate it if anyone can please give us advice on how to fix our problem.

  • #2
    How long are they frozen for?

    Comment


    • #3
      Is init works fine and only freezes when you press play? If yes then paste your code of teleop

      Comment


      • #4
        Originally posted by 8129_Aidan View Post
        How long are they frozen for?
        It stays frozen and never stops

        Comment


        • #5
          Originally posted by FTC12676 View Post
          Is init works fine and only freezes when you press play? If yes then paste your code of teleop
          The robot freezes just after the last servo went to init position. The play button is then disabled.

          Our code:

          package org.firstinspires.ftc.teamcode.Main;
          import com.qualcomm.robotcore.eventloop.opmode.OpMode;
          import com.qualcomm.robotcore.hardware.DcMotor;
          import com.qualcomm.robotcore.hardware.DcMotorSimple;
          import com.qualcomm.robotcore.hardware.Servo;
          @com.qualcomm.robotcore.eventloop.opmode.TeleOp
          public class TeleOp extends OpMode {
          DcMotor DriveFrontLeft;
          DcMotor DriveFrontRight;
          DcMotor DriveBackLeft;
          DcMotor DriveBackRight;
          DcMotor Glyph;
          DcMotor Arm;
          DcMotor Extending;
          Servo Jewel;
          Servo Phone;
          Servo RightArm;
          Servo LeftArm;
          double SpeedControl = 1;
          double GlyphSpeed = 1;
          public void init() {
          DriveFrontRight = hardwareMap.dcMotor.get("DriveFrontRight");
          DriveFrontLeft = hardwareMap.dcMotor.get("DriveFrontLeft");
          DriveBackLeft = hardwareMap.dcMotor.get("DriveBackLeft");
          DriveBackRight = hardwareMap.dcMotor.get("DriveBackRight");
          Glyph = hardwareMap.dcMotor.get("Glyph");
          Arm = hardwareMap.dcMotor.get("Arm");
          Extending = hardwareMap.dcMotor.get("Extending");
          Jewel = hardwareMap.servo.get("ServoArm");
          Phone = hardwareMap.servo.get("Phone");
          RightArm = hardwareMap.servo.get("RightArm");
          LeftArm =hardwareMap.servo.get("LeftArm");
          Arm.setDirection(DcMotor.Direction.REVERSE);
          Glyph.setDirection(DcMotorSimple.Direction.REVERSE );
          DriveFrontRight.setDirection(DcMotor.Direction.REV ERSE);
          DriveBackRight.setDirection(DcMotor.Direction.REVE RSE);
          DriveFrontLeft.setPower(0);
          DriveFrontRight.setPower(0);
          DriveBackLeft.setPower(0);
          DriveBackRight.setPower(0);
          Glyph.setPower(0);
          Arm.setPower(0);
          Extending.setPower(0);
          Phone.setPosition(1);
          LeftArm.setPosition(0);
          RightArm.setPosition(1);
          Jewel.setPosition(0);
          }
          @Override
          public void loop() {
          if (gamepad1.back){
          SpeedControl = 0.5;
          }
          if (gamepad1.start){
          SpeedControl = 1;
          }
          if ((gamepad1.left_bumper && gamepad1.right_bumper) == false)
          {
          DriveFrontLeft.setPower(gamepad1.left_stick_y);
          DriveFrontRight.setPower(gamepad1.right_stick_y);
          DriveBackLeft.setPower(gamepad1.left_stick_y);
          DriveBackRight.setPower(gamepad1.right_stick_y);
          }
          while (gamepad1.right_bumper) {
          SpeedControl = gamepad1.right_stick_y;
          DriveFrontLeft.setPower(1 * SpeedControl);
          DriveFrontRight.setPower(-1 * SpeedControl);
          DriveBackLeft.setPower(-1 * SpeedControl);
          DriveBackRight.setPower(1 * SpeedControl);
          }
          while (gamepad1.left_bumper) {
          SpeedControl = gamepad1.right_stick_y;
          DriveFrontLeft.setPower(-1 * SpeedControl);
          DriveFrontRight.setPower(1 * SpeedControl);
          DriveBackLeft.setPower(1 * SpeedControl);
          DriveBackRight.setPower(-1 * SpeedControl);
          }
          while (gamepad2.dpad_up)
          {
          Glyph.setPower(1*GlyphSpeed);
          }
          while (gamepad2.dpad_down)
          {
          Glyph.setPower(-1*GlyphSpeed);
          }
          Glyph.setPower(0);
          if (gamepad2.dpad_left == true){
          RightArm.setPosition(0.9);
          LeftArm.setPosition(0.1);
          }
          if (gamepad2.dpad_right == true) {
          RightArm.setPosition(0.5);
          LeftArm.setPosition(0.5);
          }
          Extending.setPower(gamepad2.right_stick_y);
          Arm.setPower(gamepad2.left_stick_y*-0.1);
          }
          }

          Comment


          • #6
            I think your problem is that it actually freezes when you hit play. You can't have while loops in the iterative version of the OpMode. The inputs and outputs happen outside of the main loop(). So your bumper while loop runs forever, and since you never leave that loop you never update the gamepad inputs, and all inputs remain at zero and false.

            There's supposed to be a watch dog timer and after a couple of seconds the sdk is supposed to shutdown your opmode and give an error stuck in opmode shutting down.

            So I'd start with removing all while loops and put in a couple of telemetry statements to let you know where you're getting to. Still doesn't work keep taking out chunks of code until it works then inspect the last chunk of code.

            Comment


            • #7
              I just checked on my ZTE Speeds 4.4.4. I get the Stuck in opmode error after 4 or 5 seconds when I have iterative stuck in a while loop. If I'm right I don't know why you wouldn't get the error message. What version sdk?

              Comment


              • #8
                Originally posted by 3805Mentor View Post
                I just checked on my ZTE Speeds 4.4.4. I get the Stuck in opmode error after 4 or 5 seconds when I have iterative stuck in a while loop. If I'm right I don't know why you wouldn't get the error message. What version sdk?
                We use Android SDK platform 19 and it is up to date.

                Comment


                • #9
                  You definitely need to remove the while loops from your loop() method.
                  In your case, these can all be just changed to nested if's. eg:

                  Your code will cause the program to lock if you hit a button.

                  Code:
                  while (gamepad2.dpad_up)
                  {
                      Glyph.setPower(1*GlyphSpeed);
                  }
                  
                  while (gamepad2.dpad_down)
                  {
                      Glyph.setPower(-1*GlyphSpeed);
                  }
                  
                  Glyph.setPower(0);
                  Should be changed

                  Code:
                  if (gamepad2.dpad_up) 
                  {
                      Glyph.setPower(1*GlyphSpeed);
                  }
                  else if (gamepad2.dpad_down)
                  {
                      Glyph.setPower(-1*GlyphSpeed);
                  }
                  else
                  {
                      Glyph.setPower(0);
                  }
                  As for why the program locks up immediately... thats a tricky one. Have you turned of Instant Run in Android Studios.

                  Comment

                  Working...
                  X