From c3d8dc6b111adbdbffbd996adde2e0fa2c0bb437 Mon Sep 17 00:00:00 2001 From: robotics2 Date: Tue, 3 Oct 2023 17:05:29 -0700 Subject: [PATCH] color read up, not tested --- .../firstinspires/ftc/teamcode/Autonomoustest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Autonomoustest.java b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Autonomoustest.java index b092fd5..b3e66c4 100644 --- a/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Autonomoustest.java +++ b/TeamCode/src/main/java/org/firstinspires/ftc/teamcode/Autonomoustest.java @@ -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.