Skip to content
Draft
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4560855
first pass at rev IO
garrett928 Oct 22, 2025
f70cae7
Merge branch 'dev' into implement-rev-motorio
garrett928 Oct 24, 2025
35fc34f
add seperate rev subsytem and update docs
garrett928 Oct 24, 2025
6b067e8
refactor MotorIORev: clean up imports and improve code formatting
garrett928 Nov 24, 2025
cd9d261
Merge branch 'dev' into implement-rev-motorio
garrett928 Nov 24, 2025
e152663
merge dev
garrett928 Nov 24, 2025
cbb9d84
merge rotary
garrett928 Nov 24, 2025
631cc53
merge dev
garrett928 Nov 24, 2025
1e90100
merge dev
garrett928 Nov 24, 2025
b9de937
partially working
garrett928 Nov 24, 2025
6bdb24f
rev sim mostly working
garrett928 Nov 24, 2025
ee5d549
working rev sim
garrett928 Nov 24, 2025
53a3377
Refactor rotary subsystem
garrett928 Nov 25, 2025
cb649e1
test working
garrett928 Nov 25, 2025
ecf6f8f
update sim
garrett928 Nov 25, 2025
e285b3e
Update src/main/java/frc/robot/subsystems/revRotary/RevRotaryConstant…
garrett928 Nov 25, 2025
f29b6e6
Update src/main/java/frc/robot/RobotContainer.java
garrett928 Nov 25, 2025
b125589
Update src/main/java/frc/lib/io/motor/MotorIORev.java
garrett928 Nov 25, 2025
80e922b
Update .github/instructions/default.instructions.md
garrett928 Nov 25, 2025
c9cc5b5
Update src/main/java/frc/robot/subsystems/revRotary/RevRotary.java
garrett928 Nov 25, 2025
afd56fd
Update src/main/java/frc/robot/subsystems/revRotary/RevRotaryConstant…
garrett928 Nov 25, 2025
97d8fc8
Update src/test/java/frc/robot/subsystems/rotary/RotaryTest.java
garrett928 Nov 25, 2025
21602a8
Update src/main/java/frc/lib/io/motor/MotorIORevSim.java
garrett928 Nov 25, 2025
81f0df1
Update src/main/java/frc/lib/io/motor/MotorIOSim.java
garrett928 Nov 25, 2025
078adda
Initial plan
Copilot Nov 25, 2025
2448e41
add close method
garrett928 Nov 25, 2025
01e8bb3
Address review comments: fix debug prints, initialization logic, nami…
Copilot Nov 25, 2025
2b5bef9
Merge branch 'implement-rev-motorio' into copilot/sub-pr-190
garrett928 Nov 25, 2025
9952272
Merge pull request #218 from WHS-FRC-3467/copilot/sub-pr-190
garrett928 Nov 25, 2025
3e7c325
Merge branch 'dev' into implement-rev-motorio
garrett928 Nov 26, 2025
475d964
rename folder
garrett928 Nov 26, 2025
66dc14c
Merge branch 'implement-rev-motorio' of https://github.com/WHS-FRC-34…
garrett928 Nov 26, 2025
5eed051
add comment
garrett928 Nov 26, 2025
c0dd131
fix import
garrett928 Nov 26, 2025
6743832
remove debug logging
garrett928 Nov 26, 2025
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
82 changes: 82 additions & 0 deletions .github/instructions/default.instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# FRC Team W8 Library - AI Assistant Instructions

You are a sr Java engineer with 10+ years of expereince. You are helping high school students on an FRC (FIRST Robotics Competition) team. Write clear, educational code that students can learn from and maintain.
Comment thread
garrett928 marked this conversation as resolved.
Outdated

## Technology Stack

- **Language**: Java
- **Framework**: WPILib - https://frcdocs.wpi.edu/en/latest/docs/software/what-is-wpilib.html
- **Vendor Libraries**:
- CTRE (Phoenix 6) for motors/sensors: https://v6.docs.ctr-electronics.com/en/stable/docs/api-reference/api-usage/api-overview.html
- REV (REVLib) for motors/sensors: https://docs.revrobotics.com/revlib
- **Logging**: AdvantageKit - https://docs.advantagekit.org/
- Logs are viewed in AdvantageScope

## Library Architecture (`lib` folder)

This codebase uses a **hardware abstraction layer** to make robot code portable and testable:

### Key Patterns

1. **IO Interfaces**: Define hardware operations (e.g., `ElevatorIO`, `DriveIO`)
- Methods for reading sensors and controlling actuators
- Contain nested `Inputs` class for sensor data logged by AdvantageKit

2. **IO Implementations**: Hardware-specific code (e.g., `ElevatorIOSparkMax`, `ElevatorIOSim`)
- Real hardware implementation uses vendor libraries (CTRE, REV)
- Simulation implementations for testing without hardware
- Keep vendor-specific code isolated here

3. **Subsystems**: High-level robot logic extends WPILib's `SubsystemBase`
- Accept an `IO` interface in the constructor (dependency injection)
- Contain robot behavior and state machines
- Call `Logger.processInputs()` to log sensor data

### Best Practices

- **Keep subsystems hardware-agnostic**: They should only use the IO interface, never vendor classes directly
- **Log everything**: Use AdvantageKit's `@AutoLog` for all sensor inputs
- **One IO implementation per hardware type**: Separate real vs. simulation, different motor controllers, etc.
- **Throw from default interface methods**: Default methods in IO interfaces should throw `NotImplementedException` to ensure they are explicitly implemented where needed.
- **Commands for actions**: Use WPILib's command-based framework for robot behaviors
- **Constants in separate classes**: Keep tunable values organized and easy to find

### Example Usage

```java
// IO Interface defines contract
public interface DriveIO {
@AutoLog
class DriveInputs {
double leftVelocityMPS = 0.0;
double rightVelocityMPS = 0.0;
}

void updateInputs(DriveInputs inputs);
void setVoltage(double left, double right);
}

// Subsystem uses IO interface
public class Drive extends SubsystemBase {
private final DriveIO io;
private final DriveInputsAutoLogged inputs = new DriveInputsAutoLogged();

public Drive(DriveIO io) {
this.io = io;
}

@Override
public void periodic() {
io.updateInputs(inputs);
Logger.processInputs("Drive", inputs);
}
}
```

## Guidance for Students

- Explain your code with comments when introducing new concepts
- Prefer readability over cleverness
- Break complex logic into small, named methods
- Use descriptive variable names (`leftMotorVolts` not `lmv`)
- Test code in simulation before deploying to robot hardware
6 changes: 3 additions & 3 deletions src/main/java/frc/lib/devices/ObjectDetection.java
Comment thread
garrett928 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

import org.littletonrobotics.junction.Logger;
import java.util.ArrayList;
import frc.lib.io.objectdetection.ObjectDetectionIO;
import frc.lib.io.objectdetection.ObjectDetectionIOInputsAutoLogged;
import frc.lib.io.objectdetection.ObjectDetectionIO.TargetObservation;
import java.util.Arrays;
import java.lang.Math;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Transform2d;
import edu.wpi.first.math.geometry.Transform3d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import frc.lib.io.objectDetection.ObjectDetectionIO;
import frc.lib.io.objectDetection.ObjectDetectionIO.TargetObservation;
import frc.lib.io.objectDetection.ObjectDetectionIOInputsAutoLogged;

/**
* Device level implementation of an object detection camera. While the IO layer is responsible for
Expand Down
74 changes: 63 additions & 11 deletions src/main/java/frc/lib/io/motor/MotorIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static edu.wpi.first.units.Units.RadiansPerSecond;
import static edu.wpi.first.units.Units.Volts;

import org.apache.commons.lang3.NotImplementedException;
import org.littletonrobotics.junction.AutoLog;

import edu.wpi.first.units.AngularAccelerationUnit;
Expand Down Expand Up @@ -97,7 +98,7 @@ abstract class MotorInputs {
*/
public default String getName()
{
return "";
throw new NotImplementedException("This method has not been implemented");
Comment on lines -100 to +101

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method needs to be removed for replay support

}

/**
Expand All @@ -107,35 +108,45 @@ public default String getName()
* @param inputs The structure to populate with updated sensor values.
*/
public default void updateInputs(MotorInputs inputs)
{}
{
throw new NotImplementedException("This method has not been implemented");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Sets the motor to coast mode.
*/
public default void runCoast()
{}
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -116 to +121

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Sets the motor to brake mode.
*/
public default void runBrake()
{}
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -122 to +129

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Runs the motor using direct voltage control.
*
* @param voltage Desired voltage output.
*/
public default void runVoltage(Voltage voltage)
{}
{
throw new NotImplementedException("This method has not been implemented");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay

/**
* Runs the motor with a specified current output.
*
* @param current Desired torque-producing current.
*/
public default void runCurrent(Current current)
{}
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -138 to +149

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Runs the motor with a specified current output and duty cycle.
Expand All @@ -144,15 +155,19 @@ public default void runCurrent(Current current)
* @param dutyCycle Desired dutycycle of current output, limiting top speed
*/
public default void runCurrent(Current current, double dutyCycle)
{}
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -147 to +160

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Runs the motor using duty cycle (percentage of available voltage).
*
* @param dutyCycle Fractional output between 0 and 1.
*/
public default void runDutyCycle(double dutyCycle)
{}
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -155 to +170

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Runs the motor to a specific position.
Expand All @@ -166,7 +181,20 @@ public default void runDutyCycle(double dutyCycle)
public default void runPosition(Angle position, AngularVelocity cruiseVelocity,
AngularAcceleration acceleration,
Velocity<AngularAccelerationUnit> maxJerk, PIDSlot slot)
{}
{
throw new NotImplementedException("This method has not been implemented");
}

/**
* Runs the motor to a specific position.
*
* @param position Target position.
* @param slot PID slot index.
*/
public default void runPosition(Angle position, PIDSlot slot)
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -169 to +197

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Runs the motor at a target velocity.
Expand All @@ -177,13 +205,37 @@ public default void runPosition(Angle position, AngularVelocity cruiseVelocity,
*/
public default void runVelocity(AngularVelocity velocity, AngularAcceleration acceleration,
PIDSlot slot)
{}
{
throw new NotImplementedException("This method has not been implemented");
}

/**
* Runs the motor at a target velocity.
*
* @param velocity Desired velocity.
* @param slot PID slot index.
*/
public default void runVelocity(AngularVelocity velocity, PIDSlot slot)
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -180 to +221

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Sets the position of the motor's internal encoder
*
* @param position Desired position to set encoder to
*/
public default void setEncoderPosition(Angle position)
{}
{
throw new NotImplementedException("This method has not been implemented");
}
Comment on lines -188 to +231

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks replay


/**
* Closes and cleans up motor controller resources. Called when the motor is no longer needed to
* properly release hardware.
*/
public default void close()
{
// Default implementation does nothing for interfaces that don't need cleanup
}
Comment on lines +237 to +240

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the interface extend AutoClosable

}
Loading
Loading