Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2027_alpha7",
"teamNumber": 6328
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2027_alpha7",
"teamNumber": 1425
}
11 changes: 11 additions & 0 deletions src/main/java/first/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import first.generated.CompTunerConstants;
import first.robot.Constants.DriveConstants;
import first.robot.commands.drive.DriveCommands;
import first.robot.subsystems.colorsensor.ColorSensor;
import first.robot.subsystems.colorsensor.ColorSensorIO;
import first.robot.subsystems.colorsensor.ColorSensorIORev;
import first.robot.subsystems.drive.Drive;
import first.robot.subsystems.drive.GyroIO;
import first.robot.subsystems.drive.GyroIOPigeon2;
Expand All @@ -31,12 +34,14 @@
import org.wpilib.command2.Commands;
import org.wpilib.command2.button.CommandXboxController;
import org.wpilib.hardware.bus.CANPort;
import org.wpilib.hardware.bus.I2C;

public class RobotContainer {

private Drive drive;
private AprilTagVision vision;
private Motor motor;
private ColorSensor colorSensor;

private final CommandXboxController gamepad = new CommandXboxController(0);

Expand All @@ -57,6 +62,8 @@ public RobotContainer() {

motor = new Motor(new MotorIOHardware(4, new CANBus(CANPort.CAN_S4)));

colorSensor = new ColorSensor(new ColorSensorIORev(I2C.Port.PORT_1));

vision =
new AprilTagVision(
drive::addVisionMeasurement,
Expand Down Expand Up @@ -93,6 +100,10 @@ public RobotContainer() {
motor = new Motor(new MotorIO() {});
}

if (colorSensor == null) {
colorSensor = new ColorSensor(new ColorSensorIO() {});
}

if (vision == null) {
vision = new AprilTagVision(drive::addVisionMeasurement, new CameraIO() {});
}
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/first/robot/subsystems/colorsensor/ColorSensor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2026 FRC 1425 Error Code Xero
// http://github.com/errorcodexero
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file at
// the root directory of this project.

package first.robot.subsystems.colorsensor;

import org.littletonrobotics.junction.Logger;
import org.wpilib.command2.SubsystemBase;

public class ColorSensor extends SubsystemBase {
private final ColorSensorIO io;
private final ColorSensorInputsAutoLogged inputs = new ColorSensorInputsAutoLogged();

public ColorSensor(ColorSensorIO io) {
this.io = io;
}

@Override
public void periodic() {
io.updateInputs(inputs);
Logger.processInputs("ColorSensor", inputs);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2026 FRC 1425 Error Code Xero
// http://github.com/errorcodexero
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file at
// the root directory of this project.

package first.robot.subsystems.colorsensor;

import org.littletonrobotics.junction.AutoLog;
import org.wpilib.util.Color;

public interface ColorSensorIO {
@AutoLog
public static class ColorSensorInputs {
public boolean connected = false;

public int[] rawColor = {0, 0, 0, 0}; // red, green, blue, ir
public Color color = Color.BLACK;
public int proximity = 0;
}

public default void updateInputs(ColorSensorInputs inputs) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2026 FRC 1425 Error Code Xero
// http://github.com/errorcodexero
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file at
// the root directory of this project.

package first.robot.subsystems.colorsensor;

import com.revrobotics.ColorSensorV3;
import com.revrobotics.ColorSensorV3.RawColor;
import org.wpilib.hardware.bus.I2C.Port;

public class ColorSensorIORev implements ColorSensorIO {
private final ColorSensorV3 sensor;

public ColorSensorIORev(Port i2CPort) {
sensor = new ColorSensorV3(i2CPort);
}

@Override
public void updateInputs(ColorSensorInputs inputs) {
inputs.connected = sensor.isConnected();

RawColor rawColor = sensor.getRawColor();

inputs.rawColor[0] = rawColor.red;
inputs.rawColor[1] = rawColor.green;
inputs.rawColor[2] = rawColor.blue;
inputs.rawColor[3] = rawColor.ir;
inputs.color = sensor.getColor();
inputs.proximity = sensor.getProximity();
}
}
126 changes: 126 additions & 0 deletions vendordeps/REVLib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"fileName": "REVLib.json",
"name": "REVLib",
"version": "2027.0.0-alpha-9",
"wpilibYear": "2027_alpha7",
"uuid": "3f48eb8c-50fe-43a6-9cb7-44c86353c4cb",
"mavenUrls": [
"https://maven.revrobotics.com/"
],
"jsonUrl": "https://software-metadata.revrobotics.com/REVLib-2027.json",
"javaDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-java",
"version": "2027.0.0-alpha-9"
}
],
"jniDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-driver",
"version": "2027.0.0-alpha-9",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
"windowsx86-64",
"linuxarm64",
"linuxx86-64",
"linuxsystemcore",
"osxuniversal"
]
},
{
"groupId": "com.revrobotics.frc",
"artifactId": "RevLibBackendDriver",
"version": "2027.0.0-alpha-9",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
"windowsx86-64",
"linuxarm64",
"linuxx86-64",
"linuxsystemcore",
"osxuniversal"
]
},
{
"groupId": "com.revrobotics.frc",
"artifactId": "RevLibWpiBackendDriver",
"version": "2027.0.0-alpha-9",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
"windowsx86-64",
"linuxarm64",
"linuxx86-64",
"linuxsystemcore",
"osxuniversal"
]
}
],
"cppDependencies": [
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-cpp",
"version": "2027.0.0-alpha-9",
"libName": "REVLib",
"headerClassifier": "headers",
"sharedLibrary": false,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxarm64",
"linuxx86-64",
"linuxsystemcore",
"osxuniversal"
]
},
{
"groupId": "com.revrobotics.frc",
"artifactId": "REVLib-driver",
"version": "2027.0.0-alpha-9",
"libName": "REVLibDriver",
"headerClassifier": "headers",
"sharedLibrary": false,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxarm64",
"linuxx86-64",
"linuxsystemcore",
"osxuniversal"
]
},
{
"groupId": "com.revrobotics.frc",
"artifactId": "RevLibBackendDriver",
"version": "2027.0.0-alpha-9",
"libName": "BackendDriver",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxarm64",
"linuxx86-64",
"linuxsystemcore",
"osxuniversal"
]
},
{
"groupId": "com.revrobotics.frc",
"artifactId": "RevLibWpiBackendDriver",
"version": "2027.0.0-alpha-9",
"libName": "REVLibWpi",
"sharedLibrary": true,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxarm64",
"linuxx86-64",
"linuxsystemcore",
"osxuniversal"
]
}
]
}
Loading