Announcement

Collapse
No announcement yet.

Motors are running slower in TeleOp then in Autonomous

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

  • Motors are running slower in TeleOp then in Autonomous

    Our team is having a problem with the drive motors running at around 40% power in TeleOp, but 100% power in Autonomous. Our drive motors have a gearbox ratio of 27:1.

  • #2

    Sorry, forgot to add the code.
    import com.qualcomm.robotcore.eventloop.opmode.LinearOpMo de; import com.qualcomm.robotcore.eventloop.opmode.TeleOp; import com.qualcomm.robotcore.hardware.DcMotor; import com.qualcomm.robotcore.hardware.Servo; @TeleOp (name = "RoverTele", group = "TeleOp") public class RoverTele extends LinearOpMode { DcMotor motor1; DcMotor motor2; DcMotor motor3; DcMotor motor4; DcMotor motor5; DcMotor motor6; DcMotor motor7; DcMotor motor8; Servo servo1; Servo servo2; // Servo servo3; // Servo servo4; @Override public void runOpMode(){ motor1 = hardwareMap.dcMotor.get("m1"); motor2 = hardwareMap.dcMotor.get("m2"); motor3 = hardwareMap.dcMotor.get("m3"); motor4 = hardwareMap.dcMotor.get("m4"); motor5 = hardwareMap.dcMotor.get("m5"); motor6 = hardwareMap.dcMotor.get("m6"); motor7 = hardwareMap.dcMotor.get("m7"); motor8 = hardwareMap.dcMotor.get("m8"); servo1 = hardwareMap.servo.get("s1"); servo2 = hardwareMap.servo.get("s2"); // servo3 = hardwareMap.servo.get("s3"); // servo4 = hardwareMap.servo.get("s4"); motor1.setDirection(DcMotor.Direction.FORWARD); motor2.setDirection(DcMotor.Direction.REVERSE); motor3.setDirection(DcMotor.Direction.FORWARD); motor4.setDirection(DcMotor.Direction.REVERSE); motor6.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCO DER); motor6.setMode(DcMotor.RunMode.RUN_USING_ENCODER); // servo1.setPosition(0.1); waitForStart(); telemetry.addLine("Waiting"); motor6.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCO DER); motor6.setMode(DcMotor.RunMode.RUN_USING_ENCODER); while (opModeIsActive()) { motor6.setMode(DcMotor.RunMode.RUN_USING_ENCODER); //----------------------DRIVE------------------------ /* motor1.setPower(gamepad1.right_stick_y); //straight motor2.setPower(-gamepad1.left_stick_y); motor3.setPower(gamepad1.left_stick_y); motor4.setPower(gamepad1.right_stick_y); */ motor1.setPower(gamepad1.right_stick_y); //straight motor2.setPower(-gamepad1.right_stick_y); motor3.setPower(gamepad1.right_stick_y); motor4.setPower(gamepad1.right_stick_y); motor1.setPower(gamepad1.left_stick_y); //turn motor2.setPower(gamepad1.left_stick_y); motor3.setPower(-gamepad1.left_stick_y); motor4.setPower(gamepad1.left_stick_y); //--------------------------ROBOT LIFTER---------------------------------- motor7.setPower(gamepad2.right_stick_y); //------------The hook---------------- //--------------CRAB LEFT----------------- if (gamepad1.dpad_left){ motor1.setPower(-1); motor2.setPower(-1); motor3.setPower(-1); motor4.setPower(1); } //------------CRAB RIGHT---------------- else if (gamepad1.dpad_right){ motor1.setPower(1); motor2.setPower(1); motor3.setPower(1); motor4.setPower(-1); } //---------------Don't Crab-------------- else{ motor1.setPower(0); motor2.setPower(0); motor3.setPower(0); motor4.setPower(0); } //--------------Trophy Holder Test------------- if (gamepad1.a){ servo2.setPosition(0); } else{ servo2.setPosition(-0.15); } //--------------DROPPER-------------- if (gamepad2.a){ //-----SILVER----- servo1.setPosition(0.50); } else if (gamepad2.b){ //-----GOLD------ servo1.setPosition(0.7); } else { servo1.setPosition(0); //-----Set Position----- } //-----------SLIDE LIFTER------------- if (gamepad2.dpad_up){ motor5.setPower(1); //----UP----- } else if (gamepad2.dpad_down){ motor5.setPower(-1); //----DOWN---- } else { motor5.setPower(0); //----Don't Move----- } //-------------------------BUCKET LIFTER-------------------------------- //--------Lift Up--------- if (gamepad1.left_bumper){ motor6.setPower(0.2); } //---------Lift Down--------- else if (gamepad1.right_bumper){ motor6.setPower(-0.2); } //-------Don't Move------- else{ motor6.setPower(0); } //----------------------------MATERIAL PICKUP--------------------------------- if (gamepad1.dpad_up){ motor8.setPower(-1); //-----In---------- } else if(gamepad1.dpad_down){ motor8.setPower(1); //------Out------- } else { motor8.setPower(0); //-------Don't Move-------- } } } }
    Attached Files

    Comment


    • #3
      Jynx,

      It's hard to tell from your teleop op mode listing (it's not formatted well in your post), but could the difference be because you are using RUN_USING_ENCODER mode in that op mode (for motor6)? This mode is a "closed loop" control mode of the motor controller. The motor controller is using feedback from the motor encoder to try and control the speed of the motor and keep at the target value that you set.

      If you do not want to run the motor in uncontrolled (non closed loop) mode, you want to set the motor mode to RUN_WITHOUT_ENCODER instead of RUN_USING_ENCODER.

      Tom

      Comment


      • #4
        Adding to what Tom posted.

        If you are running your motors in RUN_USING_ENCODER mode it's VERRRRRRY important to select the correct motor type in your robot configuration on your phone.

        When you select your motor type, it sets the maximum Encoder Counts Per Second that the motor can generate, and this is use by RUN_USING_ENCODER to manage the motor speed.

        If you choose a motor with higher counts than yours it will run too fast.
        If you choose a motor with lower counts than yours it will run too slow.

        Either way, RUN_USING_ENCODER will use a top speed that is only 85% of the uncontrolled speed of the motor.
        You can override this behavior by using setVelocity, instead of setPower() if you want to get into the nitty gritty.


        Comment


        • #5
          Does RUN_TO_POSITION also use closed loop for velocity? Or is it just open loop at setSpeed and encoders use is for rotation count?

          Comment


          • #6
            Originally posted by FTC12676 View Post
            Does RUN_TO_POSITION also use closed loop for velocity? Or is it just open loop at setSpeed and encoders use is for rotation count?
            Yes. And in previous forum discussions it was found to be a lower max speed than run using encoders. I don't remember if that was ever changed.

            Comment


            • #7
              Originally posted by Tom Eng View Post
              Jynx,

              It's hard to tell from your teleop op mode listing (it's not formatted well in your post), but could the difference be because you are using RUN_USING_ENCODER mode in that op mode (for motor6)? ...

              Tom
              Fyi, motor6 appears to be the "bucket lifter" motor. The bucket lifter motor is the only motor that is using RUN_USING_ENCODER.

              The drive motors appear to be motor1 through motor4:
              Code:
              import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
              import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
              import com.qualcomm.robotcore.hardware.DcMotor;
              import com.qualcomm.robotcore.hardware.Servo;
              
              
              @TeleOp (name = "RoverTele", group = "TeleOp")
              
              public class RoverTele extends LinearOpMode {
              
                  DcMotor motor1;
                  DcMotor motor2;
                  DcMotor motor3;
                  DcMotor motor4;
                  DcMotor motor5;
                  DcMotor motor6;
                  DcMotor motor7;
                  DcMotor motor8;
              
                  Servo servo1;
                  Servo servo2;
                 // Servo servo3;
                // Servo servo4;
              
                  @Override
                  public void runOpMode(){
              
                      motor1 = hardwareMap.dcMotor.get("m1");
                      motor2 = hardwareMap.dcMotor.get("m2");
                      motor3 = hardwareMap.dcMotor.get("m3");
                      motor4 = hardwareMap.dcMotor.get("m4");
                      motor5 = hardwareMap.dcMotor.get("m5");
                      motor6 = hardwareMap.dcMotor.get("m6");
                      motor7 = hardwareMap.dcMotor.get("m7");
                      motor8 = hardwareMap.dcMotor.get("m8");
              
                      servo1 = hardwareMap.servo.get("s1");
                      servo2 = hardwareMap.servo.get("s2");
                     // servo3 = hardwareMap.servo.get("s3");
                     // servo4 = hardwareMap.servo.get("s4");
              
                      motor1.setDirection(DcMotor.Direction.FORWARD);
                      motor2.setDirection(DcMotor.Direction.REVERSE);
                      motor3.setDirection(DcMotor.Direction.FORWARD);
                      motor4.setDirection(DcMotor.Direction.REVERSE);
              
              
                      motor6.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
                      motor6.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
              
                     // servo1.setPosition(0.1);
              
              
                      waitForStart();
              
                      telemetry.addLine("Waiting");
              
                      motor6.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
                      motor6.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
              
              
                      while (opModeIsActive()) {
              
                          motor6.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
              
                          //----------------------DRIVE------------------------
              
              
                    /*  motor1.setPower(gamepad1.right_stick_y); //straight
                      motor2.setPower(-gamepad1.left_stick_y);
                      motor3.setPower(gamepad1.left_stick_y);
                      motor4.setPower(gamepad1.right_stick_y); */
              
                    motor1.setPower(gamepad1.right_stick_y); //straight
                    motor2.setPower(-gamepad1.right_stick_y);
                    motor3.setPower(gamepad1.right_stick_y);
                    motor4.setPower(gamepad1.right_stick_y);
              
                    motor1.setPower(gamepad1.left_stick_y); //turn
                    motor2.setPower(gamepad1.left_stick_y);
                    motor3.setPower(-gamepad1.left_stick_y);
                    motor4.setPower(gamepad1.left_stick_y);
              
              
                      //--------------------------ROBOT LIFTER----------------------------------
              
                      motor7.setPower(gamepad2.right_stick_y); //------------The hook----------------
              
                      //--------------CRAB LEFT-----------------
                      if (gamepad1.dpad_left){
                          motor1.setPower(-1);
                          motor2.setPower(-1);
                          motor3.setPower(-1);
                          motor4.setPower(1);
                      }
              
                      //------------CRAB RIGHT----------------
                      else if (gamepad1.dpad_right){
                          motor1.setPower(1);
                          motor2.setPower(1);
                          motor3.setPower(1);
                          motor4.setPower(-1);
                      }
              
                      //---------------Don't Crab--------------
                      else{
                          motor1.setPower(0);
                          motor2.setPower(0);
                          motor3.setPower(0);
                          motor4.setPower(0);
                      }
              
                      //--------------Trophy Holder Test-------------
                      if (gamepad1.a){
                          servo2.setPosition(0);
                      }
                      else{
                          servo2.setPosition(-0.15);
                      }
              
              
                          //--------------DROPPER--------------
                          if (gamepad2.a){  //-----SILVER-----
              
                              servo1.setPosition(0.50);
                          }
                          else if (gamepad2.b){  //-----GOLD------
              
                              servo1.setPosition(0.7);
                          }
                          else {
                          servo1.setPosition(0);  //-----Set Position-----
                          }
              
              
                         //-----------SLIDE LIFTER-------------
                         if (gamepad2.dpad_up){
                             motor5.setPower(1);  //----UP-----
                         }
                         else if (gamepad2.dpad_down){
                             motor5.setPower(-1);  //----DOWN----
                         }
                         else {
                             motor5.setPower(0);  //----Don't Move-----
                         }
              
                          //-------------------------BUCKET LIFTER--------------------------------
                              //--------Lift Up---------
                          if (gamepad1.left_bumper){
                             motor6.setPower(0.2);
                         }
                              //---------Lift Down---------
                         else if (gamepad1.right_bumper){
                             motor6.setPower(-0.2);
                         }
                              //-------Don't Move-------
                         else{
                              motor6.setPower(0);
                         }
              
                         //----------------------------MATERIAL PICKUP---------------------------------
                         if (gamepad1.dpad_up){
              
                          motor8.setPower(-1);  //-----In----------
                         }
                         else if(gamepad1.dpad_down){
              
                          motor8.setPower(1);  //------Out-------
                          }
                          else {
              
                          motor8.setPower(0);  //-------Don't Move--------
                         }
              
                      }
                  }
              }

              Comment


              • #8
                Jynx, please post your autonomous code. Post your code as follows:


                [CODE]

                your autonomous code

                [/CODE]

                Comment


                • #9
                  Originally posted by Jynx View Post
                  Our team is having a problem with the drive motors running at around 40% power in TeleOp, but 100% power in Autonomous …
                  I believe your drive motors are running at around 40% because of the following tight loop in your opmode:
                  Code:
                  while (opModeIsActive()) {
                  
                        ...
                  
                        motor1.setPower(gamepad1.left_stick_y); //turn
                        motor2.setPower(gamepad1.left_stick_y);
                        motor3.setPower(-gamepad1.left_stick_y);
                        motor4.setPower(gamepad1.left_stick_y);
                  
                        ...
                  
                        motor1.setPower(0);
                        motor2.setPower(0);
                        motor3.setPower(0);
                        motor4.setPower(0);
                  
                        ...
                  }
                  Remove the setPower(0) calls and replace the top section of your loop as follows:
                  Code:
                       motor6.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
                       motor6.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
                  
                       while (opModeIsActive()) {
                  
                          //--------------CRAB LEFT-----------------
                          if (gamepad1.dpad_left){
                              motor1.setPower(-1);
                              motor2.setPower(-1);
                              motor3.setPower(-1);
                              motor4.setPower(1);
                          }
                  
                          //------------CRAB RIGHT----------------
                          else if (gamepad1.dpad_right){
                              motor1.setPower(1);
                              motor2.setPower(1);
                              motor3.setPower(1);
                              motor4.setPower(-1);
                          }
                  
                          //---------------Don't Crab--------------
                          else{
                             motor1.setPower(gamepad1.left_stick_y); //turn
                             motor2.setPower(gamepad1.left_stick_y);
                             motor3.setPower(-gamepad1.left_stick_y);
                             motor4.setPower(gamepad1.left_stick_y);
                          }
                  
                         //--------------------------ROBOT LIFTER----------------------------------
                  
                          motor7.setPower(gamepad2.right_stick_y); //------------The hook----------------
                  
                          ...

                  Comment


                  • #10
                    Originally posted by FTC12676 View Post
                    Does RUN_TO_POSITION also use closed loop for velocity? Or is it just open loop at setSpeed and encoders use is for rotation count?
                    RUN_TO_POSITION uses the same Closed loop velocity control , ie: the same limits from RUN_USING_ENCODER applies.

                    Please read my post on this thread about Motor types and setVelocity() You can specif the exact counts per second for closed loop velocity control this way.

                    Comment


                    • #11
                      Originally posted by FTC2818 View Post

                      RUN_TO_POSITION uses the same Closed loop velocity control , ie: the same limits from RUN_USING_ENCODER applies.

                      Please read my post on this thread about Motor types and setVelocity() You can specif the exact counts per second for closed loop velocity control this way.
                      Sorry, posted under team login. FTC2818 = Philbot

                      Comment


                      • #12
                        Thanks for information

                        Comment


                        • #13
                          Phil - please need more clarification. Let us assume I set motor mode to RUN_TO_POSITION, set target and set power to 0.1. Now assume that motor need full power to move due to heavy load. In case if position mode uses velocity loop then actual power to motor will 0.85 to achieve 0.1 speed. Is this assumption correct?

                          Comment


                          • #14
                            Originally posted by FTC12676 View Post
                            Phil - please need more clarification. Let us assume I set motor mode to RUN_TO_POSITION, set target and set power to 0.1. Now assume that motor need full power to move due to heavy load. In case if position mode uses velocity loop then actual power to motor will 0.85 to achieve 0.1 speed. Is this assumption correct?
                            Yes, this is true of both RUN_TO_POSITION, and RUN_USING_ENCODER

                            Comment


                            • #15
                              Originally posted by FTC12676 View Post
                              Phil - please need more clarification. Let us assume I set motor mode to RUN_TO_POSITION, set target and set power to 0.1. Now assume that motor need full power to move due to heavy load. In case if position mode uses velocity loop then actual power to motor will 0.85 to achieve 0.1 speed. Is this assumption correct?
                              Actually I need to modify my answer.... if the load on the arm is very high, and you request Power = 0.1, the actual output power may actually go all the way up to 100%.
                              It's the top speed that is limited to 85%. This is so the motor has some extra power to spare if you request top speed, (and there is some extra friction/load to overcome.)

                              It's a tricky situation.

                              The code knows that it may need extra power overhead to overcome friction etc, so it reduces the range of power (speed) that you can request.

                              Personally, I like to know exactly what I'm requesting, so I calculate the top motor speed using the max RPM and Counts per revolution, and then explicitly request the speed I want by using setVelocity() instead of setPower().

                              The code does not scale down my request in any way when I do this, so it's up to me to decide how much overhead I want to allow for the actual speed control.
                              eg: If it's for autonomous, I know I have a full battery, so I may push the upper limit of the motor speed, but later in teleop I may lower the max speed I request.

                              Comment

                              Working...
                              X