This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from rh-robotics/george-jensen-prop-detection
Team Prop Detection
- Loading branch information
Showing
2 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/auton/colorSensor/PropDetection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.firstinspires.ftc.teamcode.auton.colorSensor; | ||
|
||
import com.qualcomm.robotcore.eventloop.opmode.Autonomous; | ||
import com.qualcomm.robotcore.eventloop.opmode.OpMode; | ||
import com.qualcomm.robotcore.hardware.ColorSensor; | ||
|
||
import org.firstinspires.ftc.teamcode.subsystems.hardware.Hardware; | ||
import org.firstinspires.ftc.teamcode.subsystems.hardware.HardwareElement; | ||
|
||
@Autonomous(name = "Prop Dectection") | ||
public class PropDetection extends OpMode { | ||
|
||
private Hardware robot; | ||
int red; | ||
int blue; | ||
int colorTolerence = 30; | ||
boolean teamPropDetected = false; | ||
|
||
@Override | ||
public void init() { | ||
robot = new Hardware(hardwareMap, telemetry); | ||
robot.introduce(new HardwareElement<>(ColorSensor.class, hardwareMap, "colorSensor")); | ||
|
||
telemetry.addData("Status", "Init"); | ||
} | ||
|
||
@Override | ||
public void loop() { | ||
red = robot.<ColorSensor>get("colorSensor").red(); | ||
|
||
if (red - colorTolerence < red && red < red + colorTolerence) { | ||
teamPropDetected = true; | ||
} | ||
|
||
if (blue - colorTolerence < blue && blue < blue + colorTolerence) { | ||
teamPropDetected = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters