Brighton-FTC / FTC-2023

BSD 3-Clause Clear License
1 stars 0 forks source link

Look into ways to prevent collision w/ game pieces #19

Open WebCoder49 opened 1 year ago

sbottingota commented 1 year ago

We could use a SensorRevTOFDistance object.

import com.arcrobotics.ftclib.hardware.SensorDistanceEx;
import com.arcrobotics.ftclib.hardware.SensorRevTOFDistance;

import org.firstinspires.ftc.robotcore.external.navigation.DistanceUnit;
import org.firstinspires.ftc.teamcode.libs.brightonCollege.modeBases.TeleOpModeBase;
import org.firstinspires.ftc.teamcode.libs.brightonCollege.util.HardwareMapContainer;

SensorRevTOFDistance distanceSensor = new SensorRevTOFDistance(HardwareMapContainer.getMap(), "DemoDistanceSensor");

And every tick:

if (distanceSensor.targetReached(new SensorDistanceEx.DistanceTarget(DistanceUnit.CM, 10D))) {
    System.out.println("Stuff detected within 10cm");
}

This probably won't work, but whatever...

sbottingota commented 1 year ago

NB: We can't use a distance sensor, as we don't have one of those.