No announcement yet.

My TeleOp Files wont load to Phone

  • Filter
  • Time
  • Show
Clear All
new posts

  • My TeleOp Files wont load to Phone

    i am not sure how to register my opmode onto the phone, please help the following is my code,

    package org.firstinspires.ftc.teamcode;

    //import com.qualcomm.robotcore.eventloop.opmode.Disabled;
    //import com.qualcomm.robotcore.eventloop.opmode.Disabled;
    import com.qualcomm.robotcore.eventloop.opmode.OpMode;
    //import com.qualcomm.robotcore.hardware.ColorSensor;
    import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
    import com.qualcomm.robotcore.hardware.CRServo;
    import com.qualcomm.robotcore.hardware.DcMotor;
    //import com.qualcomm.robotcore.hardware.LightSensor;
    import com.qualcomm.robotcore.hardware.Servo;
    import com.qualcomm.robotcore.hardware.TouchSensor;
    import com.qualcomm.robotcore.util.Range;

    import java.util.Set;

    * Created by Robo on 11/06/2016.
    @TeleOp(name = "Boys Bot", group = "TeOpmode")
    public class driveOp extends OpMode {


    final static double ARM_MIN_RANGE = 0.20;
    final static double ARM_MAX_RANGE = 0.90;
    final static double CLAW_MIN_RANGE = 0.20;
    final static double CLAW_MAX_RANGE = 0.7;*/

    // position of the arm servo.
    double armPosition;
    double reverseTime = 500;
    double powerLevel = -0.35;

    // amount to change the arm servo position.
    double armDelta = 0.1;

    // position of the claw servo
    double clawPosition;

    // amount to change the claw servo position by
    double clawDelta = 0.1;
    TouchSensor tSensor;
    DcMotor right_Drive;
    DcMotor left_Drive;
    DcMotor spinner;
    DcMotor launcher;
    Servo release;
    CRServo lftS;
    CRServo rgtS;

    public driveOp() {


    public void init() {

    right_Drive = hardwareMap.dcMotor.get("rd");
    left_Drive = hardwareMap.dcMotor.get("ld");
    left_Drive.setDirection(DcMotor.Direction.REVERSE) ;

    spinner = hardwareMap.dcMotor.get("spn");
    launcher = hardwareMap.dcMotor.get("lnc");
    release = hardwareMap.servo.get("rlr");
    lftS = hardwareMap.crservo.get("lss");
    rgtS = hardwareMap.crservo.get("rss");
    tSensor = hardwareMap.touchSensor.get("tsnr");


    public void loop() {

    * Gamepad 1
    * Gamepad 1 controls the motors via the left stick, and it controls the
    * wrist/claw via the a,b, x, y buttons

    // throttle: left_stick_y ranges from -1 to 1, where -1 is full up, and
    // 1 is full down
    // direction: left_stick_x ranges from -1 to 1, where -1 is full left
    // and 1 is full right
    float throttle = -gamepad1.left_stick_y;
    float direction = gamepad1.left_stick_x;
    float right = throttle - direction;
    float left = throttle + direction;

    // clip the right/left values so that the values never exceed +/- 1
    right = Range.clip(right, -1, 1);
    left = Range.clip(left, -1, 1);

    // scale the joystick value to make it easier to control
    // the robot more precisely at slower speeds.
    right = (float) scaleInput(right);
    left = (float) scaleInput(left);

    // write the values to the motors


    if (gamepad2.dpad_up) {


    } else if (gamepad2.dpad_down) {


    } else {



    //Right Bumper controls Intake
    //Left Bumper Controls Outtake in case of error or any other anomaly
    if (gamepad2.right_bumper) {


    } else if (gamepad2.left_bumper) {


    } else {

    // Servos for Beacons
    //x button controls Left servo
    //B button controls Right servo

    if (gamepad2.x) {


    } else if (gamepad1.x) {


    } else {

    if (gamepad2.b) {


    } else if (gamepad1.b) {


    } else {

    if (gamepad1.dpad_down) {


    } else if(gamepad1.dpad_up){

    /* if (gamepad1.x) {
    // if the x button is pushed on gamepad1, decrease the position of
    // the arm servo.
    armPosition -= armDelta;

    // update the position of the claw
    if (gamepad1.b) {
    clawPosition += clawDelta;

    if (gamepad1.b) {
    clawPosition -= clawDelta;

    // clip the position values so that they never exceed their allowed range.
    //armPosition = Range.clip(armPosition, ARM_MIN_RANGE, ARM_MAX_RANGE);
    // clawPosition = Range.clip(clawPosition, CLAW_MIN_RANGE, CLAW_MAX_RANGE);

    // write position values to the wrist and claw servo

    * Send telemetry data back to driver station. Note that if we are using
    * a legacy NXT-compatible motor controller, then the getPower() method
    * will return a null value. The legacy NXT-compatible motor controllers
    * are currently write only.

    telemetry.addData("Text", "*** Robot Data***");
    telemetry.addData("arm", "arm: " + String.format("%.2f", armPosition));
    telemetry.addData("claw", "claw: " + String.format("%.2f", clawPosition));
    telemetry.addData("left tgt pwr", "left pwr: " + String.format("%.2f", left));
    telemetry.addData("right tgt pwr", "right pwr: " + String.format("%.2f", right));

    * Code to run when the op mode is first disabled goes here
    * @see com.qualcomm.robotcore.eventloop.opmode.OpMode#sto p()
    public void stop() {


    * This method scales the joystick input so for low joystick values, the
    * scaled value is less than linear. This is to make it easier to drive
    * the robot more precisely at slower speeds.
    double scaleInput(double dVal) {
    double[] scaleArray = {0.0, 0.05, 0.09, 0.10, 0.12, 0.15, 0.18, 0.24,
    0.30, 0.36, 0.43, 0.50, 0.60, 0.72, 0.85, 1.00, 1.00};

    // get the corresponding index for the scaleInput array.
    int index = (int) (dVal * 16.0);

    // index should be positive.
    if (index < 0) {
    index = -index;

    // index cannot exceed size of array minus 1.
    if (index > 16) {
    index = 16;

    // get value from the array.
    double dScale = 0.0;
    if (dVal < 0) {
    dScale = -scaleArray[index];
    } else {
    dScale = scaleArray[index];

    // return scaled value.
    return dScale;


  • #2
    i found a way to manually register it to the phone, now when i hit the initiate button on the phone it wont initiate the op mode anyone have a clue why??? The File appears on the Driver Station phone but wont initiate when you hit the button.???


    • #3
      To register an opMode with this year's SDK you should only need to comment out the @Disable annotation.
      I would try one of the sample files as a quick test to see if it is a problem with your opMode or a more general issue.

      Copy TemplateOpMode_Iterative from the samples to your teamcode package, comment out @Disabled, don't make any other changes to the program , build the project to your Robot Controller, & see if that one works. It will only keep show how long the program has been running, but this will let you know that you are using the correct procedure to load to your phone.


      • #4
        You code has the @Disabled commented out, so it should AUTOMATICALLY be registered... No need to do anything else.
        If you download it to the ROBOT controller, it should show up on the right hand pulldown list of teleop opmodes.

        I would remove the "other " way you found to register it.

        When you say it "won't init the opmode" what do you mean? What happens?

        Make sure the driver station is connected to the Robot controller.... the PING number should be changing.
        Select the opmode and click init.


        • #5
          BTW, I notice that you have telemetry statements in your code... That's good.

          You should uncomment these, and then add a telemetry.update() call after the last one.

          I also note that you have an extra block-comment-start here:

          /* if (gamepad1.x) {

          There is no matching end-block-comment for this, so a whole section of you program is commented out.