color read up, not tested

This commit is contained in:
robotics2
2023-10-03 17:05:29 -07:00
parent ee86476ca3
commit c3d8dc6b11

View File

@ -31,6 +31,7 @@ package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.hardware.ColorSensor;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.util.ElapsedTime;
@ -69,6 +70,7 @@ public class Autonomoustest extends LinearOpMode {
private DcMotor rightDrive = null;
private DcMotor backrightDrive = null;
private DcMotor backleftDrive = null;
private ColorSensor colorRight = null;
@ -97,6 +99,7 @@ public class Autonomoustest extends LinearOpMode {
rightDrive = hardwareMap.get(DcMotor.class, "Drive front rt");
backleftDrive = hardwareMap.get(DcMotor.class, "Drive back lt");
backrightDrive = hardwareMap.get(DcMotor.class, "Drive back rt");
colorRight = hardwareMap.get(ColorSensor.class, "color right");
// To drive forward, most robots need the motor on one side to be reversed, because the axles point in opposite directions.
// When run, this OpMode should start both motors driving forward. So adjust these two lines based on your first test drive.
// Note: The settings here assume direct drive on left and right wheels. Gear Reduction or 90 Deg drives may require direction flips
@ -131,7 +134,7 @@ public class Autonomoustest extends LinearOpMode {
// Note: Reverse movement is obtained by setting a negative distance (not speed)
//driveForward(2);
//driveForward(80);
driveForward(28);
readColor();
//turnRight(90);
@ -185,6 +188,13 @@ public class Autonomoustest extends LinearOpMode {
double turning_distance = degrees * DEGREE_TOO_DISTANCE;
encoderDrive(DRIVE_SPEED, turning_distance, turning_distance, LONG_TIMEOUT);
}
public void readColor()
{
telemetry.addData("Clear", colorRight.alpha());
telemetry.addData("Red ", colorRight.red());
telemetry.addData("Green", colorRight.green());
telemetry.addData("Blue ", colorRight.blue());
}
/*
* Method to perform a relative move, based on encoder counts.