Announcement

Collapse
No announcement yet.

Slow to load teleop

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

  • Slow to load teleop

    We are running our programs using the Moto G4 play phones. After pressing the init button on screen it takes 5-10 seconds for the play button to appear.
    Here is the simple teleop we are trying to run.

    Code:
     
     package org.firstinspires.ftc.teamcode;  import com.qualcomm.robotcore.eventloop.opmode.OpMode; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.util.ElapsedTime;  import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;  @TeleOp(name="TeleOp", group="Iterative Opmode") //@Disabled public class TeleOp extends OpMode {     // Declare OpMode members.     private ElapsedTime runtime = new ElapsedTime();     Hardware robot       = new Hardware();         @Override     public void init()     {         robot.init(hardwareMap);         telemetry.addData("Status", "Initialized");      }      @Override     public void init_loop() {}      @Override     public void start() {         runtime.reset();     }      @Override     public void loop()     {          double leftPower;         double rightPower;          leftPower = gamepad1.left_stick_y;         rightPower  =  gamepad1.right_stick_y;          // Drive Mechanics         if (gamepad1.left_bumper == true)         {             robot.leftRearDrive.setPower(1);             robot.leftFrontDrive.setPower(-1);             robot.rightRearDrive.setPower(-1);             robot.rightFrontDrive.setPower(1);         }         else if (gamepad1.right_bumper == true)         {             robot.leftRearDrive.setPower(-1);             robot.leftFrontDrive.setPower(1);             robot.rightRearDrive.setPower(1);             robot.rightFrontDrive.setPower(-1);         }         else if (gamepad1.left_stick_y != 0 || gamepad1.right_stick_y != 0)         {             robot.leftRearDrive.setPower(rightPower);             robot.leftFrontDrive.setPower(rightPower);             robot.rightRearDrive.setPower(leftPower);             robot.rightFrontDrive.setPower(leftPower);         }        else         {             robot.leftRearDrive.setPower(0);             robot.leftFrontDrive.setPower(0);             robot.rightRearDrive.setPower(0);             robot.rightFrontDrive.setPower(0);         }      }      @Override     public void stop() {} }
    Here is the hardware
    Code:
     
       package org.firstinspires.ftc.teamcode;  import com.qualcomm.hardware.rev.Rev2mDistanceSensor; import com.qualcomm.robotcore.hardware.CRServo; import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.DigitalChannel; import com.qualcomm.robotcore.hardware.DistanceSensor; import com.qualcomm.robotcore.hardware.HardwareMap; import com.qualcomm.robotcore.hardware.Servo; import com.qualcomm.robotcore.util.ElapsedTime; import com.qualcomm.hardware.bosch.BNO055IMU;  /**  *   */ public class Hardware {     /* Public OpMode members. */     public DcMotor  leftRearDrive   = null;     public DcMotor  rightRearDrive  = null;     public DcMotor  leftFrontDrive   = null;     public DcMotor  rightFrontDrive  = null;     public DcMotor  Lifter     = null;     public DcMotor  ArmLeft     = null;     public DcMotor  ArmRight     = null;     public CRServo ArmExtend = null;      public CRServo sweeper = null;     public Servo sweeperDropper = null;     DigitalChannel touchDown;     DigitalChannel touchUp;     public BNO055IMU imu=null; //for gyro       //public DistanceSensor sensorRangeLeft;     public DistanceSensor sensorRangeRight;     public DistanceSensor sensorRangeCenter;       public static final double MID_SERVO       =  0.5 ;     public static final double ARM_UP_POWER    =  0.45 ;     public static final double ARM_DOWN_POWER  = -0.45 ;      /* local OpMode members. */     HardwareMap hwMap           =  null;     private ElapsedTime period  = new ElapsedTime();      /* Constructor */     public Hardware(){      }      /* Initialize standard Hardware interfaces */     public void init(HardwareMap ahwMap) {         // Save reference to Hardware map         hwMap = ahwMap;          touchDown = hwMap.get(DigitalChannel .class, "td");         touchUp = hwMap.get(DigitalChannel .class, "tu");          // set the digital channel to input.         touchDown.setMode(DigitalChannel.Mode.INPUT);         touchUp.setMode(DigitalChannel.Mode.INPUT);         // Define and Initialize Motors         leftRearDrive  = hwMap.get(DcMotor.class, "left_Rear_drive");         rightRearDrive = hwMap.get(DcMotor.class, "right_Rear_drive");         leftFrontDrive  = hwMap.get(DcMotor.class, "left_Front_drive");         rightFrontDrive = hwMap.get(DcMotor.class, "right_Front_drive");         Lifter = hwMap.get(DcMotor.class, "lifter");         ArmLeft = hwMap.get(DcMotor.class, "al");         ArmRight = hwMap.get(DcMotor.class, "ar");         leftRearDrive.setDirection(DcMotor.Direction.FORWARD); // Set to REVERSE if using AndyMark motors         rightRearDrive.setDirection(DcMotor.Direction.REVERSE);// Set to FORWARD if using AndyMark motors         leftFrontDrive.setDirection(DcMotor.Direction.FORWARD); // Set to REVERSE if using AndyMark motors         rightFrontDrive.setDirection(DcMotor.Direction.REVERSE);// Set to FORWARD if using AndyMark motors         Lifter.setDirection(DcMotor.Direction.REVERSE);// Set to FORWARD if using AndyMark motors         ArmLeft.setDirection(DcMotor.Direction.REVERSE);         ArmRight.setDirection(DcMotor.Direction.REVERSE);         // Set all motors to zero power         leftRearDrive.setPower(0);         rightRearDrive.setPower(0);         leftFrontDrive.setPower(0);         rightFrontDrive.setPower(0);         Lifter.setPower(0);          // Set all motors to run without encoders.         // May want to use RUN_USING_ENCODERS if encoders are installed.         leftRearDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);         rightRearDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);         leftFrontDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);         rightFrontDrive.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);         Lifter.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);         ArmLeft.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);         ArmRight.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);          //Set Brake         leftRearDrive.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);; // Stop motor if power set yo zero         rightRearDrive.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);;// Stop motor if power set yo zero         leftFrontDrive.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);;// Stop motor if power set yo zero         rightFrontDrive.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);;// Stop motor if power set yo zero         Lifter.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);;// Stop motor if power set yo zero         ArmLeft.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);         ArmRight.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);           imu = hwMap.get(BNO055IMU.class, "imu"); //these are for the gyro         BNO055IMU.Parameters parameters = new BNO055IMU.Parameters();//these are for the gyro         imu.initialize(parameters);//these are for the gyro                sweeper = hwMap.get(CRServo.class, "sweepL");         ArmExtend = hwMap.get(CRServo.class, "extender");         sweeperDropper = hwMap.get(Servo.class, "sweepR");              //sensorRangeLeft = hwMap.get(DistanceSensor.class, "sensorL");         sensorRangeRight = hwMap.get(DistanceSensor.class, "sensorR");         sensorRangeCenter = hwMap.get(DistanceSensor.class, "sensorC");              }  }
    Is the issue having the imu initialized in the hardware class? Ideally we would use the code to make our robot auto align to the best scoring spot. If that is the problem is there a fix? Any help would be appreciated.

  • #2
    The IMU takes a few seconds to initialize, so yes, initializing it during init() will cause this delay. If you are actually going to use it, you might have to have the delay. If your tele-op is not using it, don't initialize it?

    Comment


    • #3
      Originally posted by markdmatthews View Post
      The IMU takes a few seconds to initialize, so yes, initializing it during init() will cause this delay. If you are actually going to use it, you might have to have the delay. If your tele-op is not using it, don't initialize it?
      Speaking from experience, the BNO055 does not take 5+ seconds to initialize. Also, to avoid re-initing after autonomous, you could store it in a static variable and then just use it from teleop without initing first.

      Comment


      • #4
        What is up with all the double semicolons? 4634 Programmer the BNO055 doesn't cause 5+ second lag by itself, but the BNO055 and all the other hardware can cause lag of 5+ seconds.

        Comment

        Working...
        X