Robot Control Full Program
Full Program
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.Blinker;
import com.qualcomm.robotcore.hardware.Servo;
import com.qualcomm.robotcore.hardware.TouchSensor;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.DcMotorSimple;
import com.qualcomm.robotcore.util.ElapsedTime;
@TeleOp
public class HelloRobot_TeleOp extends LinearOpMode {
private Blinker control_Hub;
private DcMotor arm;
private DcMotor leftmotor;
private DcMotor rightmotor;
private DcMotor test_motor;
private Servo test_servo;
private TouchSensor test_touch;
@Override
public void runOpMode() {
control_Hub = hardwareMap.get(Blinker.class, "Control Hub");
arm = hardwareMap.get(DcMotor.class, "arm");
leftmotor = hardwareMap.get(DcMotor.class, "leftmotor");
rightmotor = hardwareMap.get(DcMotor.class, "rightmotor");
test_motor = hardwareMap.get(DcMotor.class, "test_motor");
test_servo = hardwareMap.get(Servo.class, "test_servo");
test_touch = hardwareMap.get(TouchSensor.class, "test_touch");
rightmotor.setDirection(DcMotorSimple.Direction.REVERSE);
double x;
double y;
telemetry.addData("Status", "Initialized");
telemetry.update();
// Wait for the game to start (driver presses PLAY)
waitForStart();
// run until the end of the match (driver presses STOP)
while (opModeIsActive()) {
//Drivetrain Control
x = gamepad1.right_stick_x;
y = -gamepad1.right_stick_y;
rightmotor.setPower(y-x);
leftmotor.setPower(y+x);
//Arm Control with Limit Switch
if(test_touch.isPressed()){
if(gamepad1.dpad_up){
arm.setPower(0.2);
}
else{
arm.setPower(0);
}
}
else {
if(gamepad1.dpad_up){
arm.setPower(0.2);
}
else if (gamepad1.dpad_down){
arm.setPower(-0.2);
}
else {
arm.setPower(0);
}
}
telemetry.addData("Status", "Running");
telemetry.update();
}
}
}Downloads
Last updated
Was this helpful?

