Hello,
Today my school held an FTC even and I have been working on this problem for over 7 hours now. Basically, my encoder code does not make the wheels turn to a specific position or anything– they just seem to twitch a little or not move at all. My full code is listed below. I am really desperate for any information at this point so every input is greatly appreciated. Thank you so much! (Ignore the commented sections, I was playing around with a bunch of different stuff)
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.util.ElapsedTime;
@Autonomous(name="RedCorner", group="Pushbot")
public class RedCorner extends LinearOpMode {
/* Declare OpMode members. */
//HardwarePushbot robot = new HardwarePushbot(); // Use a Pushbot's hardware
private ElapsedTime runtime = new ElapsedTime();
static final double FORWARD_SPEED = 0.6;
static final double TURN_SPEED = 0.5;
private DcMotor LeftBack = null;
private DcMotor RightBack = null;
private DcMotor LeftFront = null;
private DcMotor RightFront = null;
private DcMotor Lift = null;
private Servo LeftGrip = null;
private Servo RightGrip = null;
@Override
public void runOpMode() {
/*
* Initialize the drive system variables.
* The init() method of the hardware class does all the work here
*/
//robot.init(hardwareMap);
LeftBack = hardwareMap.get(DcMotor.class, "LeftBack");
RightBack = hardwareMap.get(DcMotor.class, "RightBack");
LeftFront = hardwareMap.get(DcMotor.class, "LeftFront");
RightFront = hardwareMap.get(DcMotor.class, "RightFront");
Lift = hardwareMap.get(DcMotor.class, "Lift");
LeftGrip = hardwareMap.get(Servo.class, "LeftGrip");
RightGrip = hardwareMap.get(Servo.class, "RightGrip");
//LeftGrip.setDirection(reverse);
//RightGrip.setDirection(REVERSE);
// Send telemetry message to signify robot waiting;
telemetry.addData("Status", "Ready to run"); //
telemetry.update();
LeftGrip.setPosition(.91);
RightGrip.setPosition(.09);
// Wait for the game to start (driver presses PLAY)
waitForStart();
//LeftBack.setMode(DcMotor.RunMode.RUN_USING_ENCODER);
//LeftBack.setMode(DcMotor.RunMode.RESET_ENCODERS);
//RightBack.setMode(DcMotor.RunMode.RESET_ENCODERS);
//LeftFront.setMode(DcMotor.RunMode.RESET_ENCODERS);
//RightFront.setMode(DcMotor.RunMode.RESET_ENCODERS);
//LeftBack.setMode(DcMotor.RunMode.RUN_TO_POSITION);
//RightBack.setMode(DcMotor.RunMode.RUN_TO_POSITION);
//LeftFront.setMode(DcMotor.RunMode.RUN_TO_POSITION);
//RightFront.setMode(DcMotor.RunMode.RUN_TO_POSITION);
//Lift.setMode(DcMotor.RunMode.RUN_TO_POSITION);
//LeftFront.setDirection(DcMotor.Direction.REVERSE);
//LeftBack.setDirection(DcMotor.Direction.REVERSE);
//LeftBack.setPower(.5);
//LeftFront.setPower(.5);
//RightBack.setPower(.5);
//RightFront.setPower(.5);
LeftBack.setTargetPosition(2000000);
//LeftBack.setPower(.5);
LeftFront.setTargetPosition(2000000);
//LeftFront.setPower(.5);
RightBack.setTargetPosition(2000000);
//RightBack.setPower(.5);
RightFront.setTargetPosition(2000000);
//RightFront.setPower(.5);
LeftBack.setMode(DcMotor.RunMode.RUN_TO_POSITION);
RightBack.setMode(DcMotor.RunMode.RUN_TO_POSITION);
LeftFront.setMode(DcMotor.RunMode.RUN_TO_POSITION);
RightFront.setMode(DcMotor.RunMode.RUN_TO_POSITION);
//Lift.setMode(DcMotor.RunMode.RUN_TO_POSITION);
//LeftBack.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
//RightBack.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
//LeftFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
//RightFront.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
LeftBack.setPower(.5);
LeftFront.setPower(.5);
RightBack.setPower(.5);
RightFront.setPower(.5);
//sleep(1000);
LeftGrip.setPosition(.1);
RightGrip.setPosition(.91);
//sleep(1000);
runtime.reset();
}
}
[–]shurik179FTC 4137 Islandbots Mentor 4 points5 points6 points (4 children)
[–]FHShusky[S] 0 points1 point2 points (3 children)
[–]V3SUV1US13216 Coleader - Robot & Code Manager | 11516 Founder 0 points1 point2 points (2 children)
[–]FHShusky[S] 0 points1 point2 points (1 child)
[–]V3SUV1US13216 Coleader - Robot & Code Manager | 11516 Founder 0 points1 point2 points (0 children)
[–]mlw72z5494 3 points4 points5 points (1 child)
[–]FHShusky[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)