Announcement

Collapse
No announcement yet.

Robot doesn't run

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

  • Robot doesn't run

    Hello,

    So my current team code compiles and doesn't give me errors, but then when I run the robot, the motors do not work. Here is the list of code that I am using
    Code:
    robot = new Robot(this);
            //robot.driveBase.constantSpeed();
            waitForStart();
            while (opModeIsActive()) {
                // Drive Train command
                robot.driveBase.tankDrive(-gamepad1.left_stick_y, -gamepad1.right_stick_y);
                // Tape Measure and Winch motor
                if (-gamepad2.left_stick_y > 0) {
                    //robot.hanger.runUP();
                } else if (-gamepad2.left_stick_y < 0) {
                    //robot.hanger.runDOWN();
                } else {
                    //robot.hanger.stop();
                }
                //
                if (gamepad2.left_bumper) {
                    //robot.hanger.hookArm50();
                } else if (gamepad2.right_bumper) {
                    //robot.hanger.hookArm150();
                } else if (gamepad2.left_trigger != 0) {
                    //robot.hanger.hookArm135();
                } else if (gamepad2.right_trigger != 0) {
                   //robot.hanger.hookArm0();
                } else {
                    //robot.hanger.steadyHookArm();
                }
                //
                if (gamepad1.left_bumper) {
                    //robot.climberDeployer.dP0();
                } else if (gamepad1.right_bumper) {
                    //robot.climberDeployer.dP250();
                } else if (gamepad1.left_trigger == 1) {
                    //robot.climberDeployer.dP700();
                } else if (gamepad1.right_trigger == 1) {
                   //robot.climberDeployer.dP950();
                } else {
                    //robot.climberDeployer.steadydP();
                }
                //
                if (gamepad1.dpad_up) {
                    //robot.hanger.upAllClear();
                } else if (gamepad1.dpad_down) {
                    //robot.hanger.downAllClear();
                } else {
                    //robot.hanger.noAllClear();
                }
                //
                if (gamepad1.dpad_left) {
                    //robot.climberDeployer.setFlipper();
                }
                if (gamepad1.dpad_right) {
                    //robot.climberDeployer.stopFlipper();
                }
                //
                if (gamepad2.dpad_up) {
                    //robot.climberDeployer.tZero();
                }
                if (gamepad2.dpad_right) {
                    //robot.climberDeployer.tPrep();
                }
                if (gamepad2.dpad_down) {
                    //robot.climberDeployer.tDrop();
                }
                if (gamepad2.dpad_left) {
                    //robot.climberDeployer.tHighUp();
                }
                if (gamepad2.x) {
                    //robot.climberDeployer.tiltBoxLeft();
                } else if (gamepad2.b) {
                    //robot.climberDeployer.tiltBoxRight();
                } else {
                    //robot.climberDeployer.centerBox();
                }
                // Zipline Climbers
                if (gamepad1.x) {
                    //robot.hanger.raiseZipline();
                } else if (gamepad1.b) {
                    //robot.hanger.lowerZipline();
                } else {
                    //robot.hanger.zeroZipline();
                }
            } // end of if gamepad1.back not pressed
    
    
    public DriveBase(LinearOpMode opMode) throws InterruptedException {
            this.opMode = opMode;
            rightMotor = opMode.hardwareMap.dcMotor.get("rightMotor");
            rightMotor.setDirection(DcMotorSimple.Direction.REVERSE);
            leftMotor = opMode.hardwareMap.dcMotor.get("leftMotor");
            leftMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
            rightMotor.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
            leftMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
            rightMotor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
            //gyroSensor = (ModernRoboticsI2cGyro)opMode.hardwareMap.gyroSensor.get("gyro");
            mRunTime.reset();
            //gyroSensor.calibrate();
            //while(gyroSensor.isCalibrating()) {
            //   Thread.sleep(50);
            //    opMode.idle();
            //}
            //gyroSensor.resetZAxisIntegrator();
        }
    I can't seem to pinpoint where the error is. I have checked that the two motors are named leftMotor and rightMotor respectively and that I am just testing this out in teleOp mode with the tankDrive method.

    Thanks!

  • #2
    I forgot to add in the tankDrive method
    Code:
    public void tankDrive(float leftPower, float rightPower) throws InterruptedException {
            leftPower = Range.clip(leftPower, -1, 1);
            rightPower = Range.clip(rightPower, -1, 1);
            leftPower = (float) scaleInput(leftPower);
            rightPower = (float) scaleInput(rightPower);
            leftMotor.setPower(leftPower);
            rightMotor.setPower(rightPower);
        }

    Comment


    • #3
      I also forgot to mention that I'm using LinearOpMode for this as it worked for me in the past. Hopefully, that's enough information to find out where the error came from. I don't think it's a wiring problem because there is power to the modern robotics motor controller and the cables are put in correctly.

      Comment


      • #4
        Originally posted by FTC8564 View Post
        I also forgot to mention that I'm using LinearOpMode for this as it worked for me in the past. Hopefully, that's enough information to find out where the error came from. I don't think it's a wiring problem because there is power to the modern robotics motor controller and the cables are put in correctly.
        A number of things to check:
        Is both sides of your cable connected to their intended targets, and, if splices are used in your wire, does the wire passes a continuity check?
        Is your config file correct, and pointing the right motor port to the right name?
        Are you obtaining your DcMotor instance from the hardware map?
        Do your motors work?
        Is the function scaleInput() correct?
        By running the robot, I presuming that you are connecting gamepad 1 to the Driver Station, you configure gamepad 1 to be recognized by the Driver Station as gamepad1 (Start+A), the gamepad is in the right mode, the phone is using the right mode for the joystick?

        If you said yes to all of the above questions, post your Robot Controller logs for more information (pastebin or gist).

        Comment


        • #5
          Yes to all of these questions and it seems that the robot controller is repeating some wait function quite repeatedly. I've attached a link to pastebin: http://pastebin.com/6CtXKyfb

          Comment


          • #6
            Originally posted by FTC8564 View Post
            Yes to all of these questions and it seems that the robot controller is repeating some wait function quite repeatedly. I've attached a link to pastebin: http://pastebin.com/6CtXKyfb
            So far, everything looks fine. The log looks normal.

            Do you have more than one motor controller? Could this code be sending motor commands to a controller with no motors attached?
            Have you verified that the Gamepad is working..?

            If it was me, the FIRST thing I'd do would be to verify that my code is actually sending non-zero commands to the motors...

            Inside the TankDrive method I'd add some telementry data.

            public void tankDrive(float leftPower, float rightPower) throws InterruptedException {
            leftPower = Range.clip(leftPower, -1, 1);
            rightPower = Range.clip(rightPower, -1, 1);
            leftPower = (float) scaleInput(leftPower);
            rightPower = (float) scaleInput(rightPower);
            leftMotor.setPower(leftPower);
            rightMotor.setPower(rightPower);

            telemetry.addData("Drive", "L[%5.2f], R[%5.2f]", leftPower, rightPower);
            telemetry.update();
            }

            Now run it and see what you are actually sending to the motors.
            If it's zero, then add some more telemetry until you see where the hole is.
            If it's non-zero, then it's your hardware/wiring/config.....

            Comment


            • #7
              I don't have more than one motor controller. All I have is just a Power Distribution module, one Motor Controller, two motors, and the TileRunner drive chassis. Am I supposed to create an object for Telemetry like Telemetry telemetry;? I've imported the Telemetry class and am a bit lost since the last two lines you suggested come up as an error since telemetry isn't a defined object. I tried doing Telemetry telemetry but I get a NullPointerException error since it doesn't have anything inside it. I tried this
              Code:
              private Telemetry telemetry = new Telemetry() {
                      @Override
                      public Item addData(String caption, String format, Object... args) {
                          return null;
                      }
              
                      @Override
                      public Item addData(String caption, Object value) {
                          return null;
                      }
              
                      @Override
                      public <T> Item addData(String caption, Func<T> valueProducer) {
                          return null;
                      }
              
                      @Override
                      public <T> Item addData(String caption, String format, Func<T> valueProducer) {
                          return null;
                      }
              
                      @Override
                      public boolean removeItem(Item item) {
                          return false;
                      }
              
                      @Override
                      public void clear() {
              
                      }
              
                      @Override
                      public void clearAll() {
              
                      }
              
                      @Override
                      public Object addAction(Runnable action) {
                          return null;
                      }
              
                      @Override
                      public boolean removeAction(Object token) {
                          return false;
                      }
              
                      @Override
                      public boolean update() {
                          return false;
                      }
              
                      @Override
                      public Line addLine() {
                          return null;
                      }
              
                      @Override
                      public Line addLine(String lineCaption) {
                          return null;
                      }
              
                      @Override
                      public boolean removeLine(Line line) {
                          return false;
                      }
              
                      @Override
                      public boolean isAutoClear() {
                          return false;
                      }
              
                      @Override
                      public void setAutoClear(boolean autoClear) {
              
                      }
              
                      @Override
                      public int getMsTransmissionInterval() {
                          return 0;
                      }
              
                      @Override
                      public void setMsTransmissionInterval(int msTransmissionInterval) {
              
                      }
              
                      @Override
                      public String getItemSeparator() {
                          return null;
                      }
              
                      @Override
                      public void setItemSeparator(String itemSeparator) {
              
                      }
              
                      @Override
                      public String getCaptionValueSeparator() {
                          return null;
                      }
              
                      @Override
                      public void setCaptionValueSeparator(String captionValueSeparator) {
              
                      }
              
                      @Override
                      public Log log() {
                          return null;
                      }
                  };
              but it didn't seem to do anything.

              Comment


              • #8
                You need the reference to telemetry that your LinearOpMode has.

                Comment


                • #9
                  Well... now, it's a hardware or wiring problem. Yet, it looks fine. I can send a picture of the robot. http://puu.sh/rDccf/8564269c3f.jpg I believe that it must be a wiring problem now because the RobotController logs pick up each motor and the controller itself. Just wondering but is there a line of code that I need to define for the motor controller itself? We used the legacy controllers last year and this is our first time with Modern Robotics Controllers.

                  Comment


                  • #10
                    Actually, I noticed something odd when taking a look at the Self-Inspect page. It says the version of the robot controller is 1.5 when I installed the new apk and on the RC phone, it says 2.35. However, the driver station says 2.2. Don't know if my problem has to do with that?

                    Comment


                    • #11
                      I patched them to the same version but still doesn't work

                      Comment


                      • #12
                        Forget about software versions and android code. Download the core device discovery app and connect your robot to the computer via USB instead of to the phone. If you can't get motors to work with their application then nothing you do in code is going to help. It's a hardware or wiring problem at that point.

                        http://www.modernroboticsinc.com/coredevicediscovery

                        If everything does work as expected then it is a software problem. Your software is a bit hard to follow because it's last years code with most of the functionality commented out. I suggest staring simple with a new OpMode like the following:


                        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;
                        
                        
                        @TeleOp(name="Sample", group="Sample")
                        public class Sample extends OpMode {
                            
                            DcMotor leftMotor;
                        
                            @Override
                            public void init() {
                                leftMotor = hardwareMap.dcMotor.get("left_motor"); // Use the proper name here
                            }
                        
                            @Override
                            public void loop() {
                                leftMotor.setPower(gamepad1.left_stick_y);
                            }
                        }

                        Comment


                        • #13
                          Using the discovery app, it turns out that it's definitely a hardware problem with the motor controller. We actually sent this one in to get upgraded to 2.0 but it seems like something went wrong. We'll swap it out for another one we have.

                          Comment


                          • #14
                            Using the opMode you suggested, it works but using my own opMode, it doesn't seem to work at all. Going to use telemetry to pinpoint where it's going wrong.

                            Comment


                            • #15
                              One thing we always do is comment out all of the code and slowly add it all back. It usually works for us. It's weird that the discovery app didn't work for you. That's how we test all of our modules and if it works with the discovery app and not the code, it is usually a software problem but yours wasn't working with either.

                              Comment

                              Working...
                              X