Skip to content

Commit

Permalink
docs done!
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanErn committed Dec 5, 2024
1 parent fb15e65 commit 898d5de
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 143 deletions.
84 changes: 84 additions & 0 deletions docs/mkdocs/docs/library/subsystems/bling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Bling Subsystem

## Overview
The BlingSubsystem controls LED lighting (Bling) on the robot using a CTRE CANdle controller. This subsystem provides comprehensive LED control capabilities, including solid colors, animations, queued patterns, and alliance-based color schemes. The system is designed to provide visual feedback about robot state and enhance field presence.

## Core Features
The subsystem provides robust LED control through several key mechanisms:

### Color Management
The system supports immediate and queued color changes:
```java
// Set immediate color
bling.setSolidColor(Color.RED);

// Queue next color
bling.queueColor(nextColor);
bling.setQueuedColor(); // Apply when ready
```

### Animation Control
Animations can be controlled directly or through a queue system:
```java
// Run animation immediately
bling.runAnimation(new RainbowAnimation());

// Queue animation
bling.queueAnimation(nextAnimation);
bling.runQueuedAnimation(); // Apply when ready
```

### Alliance Integration
The system automatically handles alliance colors:
```java
bling.setLedToAllianceColor(); // Sets red/blue based on alliance
```

## Configuration

### Hardware Setup
The system expects:
- CTRE CANdle controller
- GRB LED strip type
- Configurable number of LEDs (default 92)
- Optional LED offset (default 8)

### Tunable Constants
Key parameters in BlingSubsystemConstants:
```java
public static final boolean BLING_ENABLED = false;
public static final double MAX_LED_BRIGHTNESS = 0.25;
public static final int NUM_LEDS = 92;
public static final int LED_OFFSET = 8;
```

## Telemetry
The subsystem includes comprehensive telemetry through Shuffleboard:
- Current color display
- Active animation status
- System enable/disable status

## Best Practices

### State Management
The subsystem maintains clear state through dedicated methods:
- `clearAnimation()` for stopping animations
- `clearSolidColor()` for turning off LEDs
- `clearAll()` for complete reset
- `runDefault()` for returning to baseline behavior

### Update Cycle
The subsystem handles updates automatically through:
- Periodic updates in the subsystem
- Automatic telemetry updates
- State management in the command loop

## Integration Notes
To add this subsystem to your robot:

1. Configure CAN ID for the CANdle
2. Adjust constants for your LED strip configuration
3. Set up default command (typically DefaultSetToAllianceColor)
4. Integrate with robot state indicators as needed

This subsystem is designed to be both robust for competition use and flexible for development and testing purposes.
File renamed without changes.
167 changes: 167 additions & 0 deletions docs/mkdocs/docs/library/subsystems/swerve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# SwerveDrive Subsystem

## System Overview

The SwerveDrive system consists of multiple interconnected components that work together to provide a complete swerve drive implementation for FRC robots. The system is built on CTRE's Phoenix 6 framework and integrates with PathPlanner for autonomous path following.

## Core Components

### 1. SwerveDriveSubsystem
The main subsystem class that handles drive control and odometry. This class extends CTRE's `SwerveDrivetrain` and implements WPILib's `Subsystem` interface.

### 2. SwerveDrivePathPlanner
Manages autonomous path following and path generation capabilities. This includes auto path selection and execution.

### 3. TunerConstants
Year-specific configuration files (mk4il22023 and mk4il32024) that contain hardware-specific constants and module configurations.

### 4. SwerveDriveTelemetry
Handles data visualization and debugging through Shuffleboard.

### 5. SwerveDriveSubsystemConstants
Contains performance-related constants for different drive modes.

## Configuration Guide

### Module Configuration

Module configuration is handled in the year-specific TunerConstants files. To configure for your robot:

1. Choose the appropriate year's TunerConstants file:
- `mk4il22023/TunerConstants.java` for L2 robot (2023)
- `mk4il32024/TunerConstants.java` for L3 robot (2024)
2. Or, generate a new one via PhoenixTunerX

3. Update the following constants in your chosen TunerConstants file:
```java
// PID Gains
private static final Slot0Configs steerGains = new Slot0Configs()
.withKP(100) // Adjust based on your robot's steering response
.withKI(0)
.withKD(0.2);

private static final Slot0Configs driveGains = new Slot0Configs()
.withKP(3) // Adjust based on your robot's driving response
.withKI(0)
.withKD(0);
```

### PathPlanner Integration

In SwerveDrivePathPlanner.java:

1. Configure path constraints:
```java
// In the corresponding year's TunerConstants.java
public static final PathConstraints PATHFINDING_CONSTRAINTS = new PathConstraints(
5.2, // Max velocity (m/s)
3.5, // Max acceleration (m/s²)
Units.degreesToRadians(540), // Max angular velocity
Units.degreesToRadians(460) // Max angular acceleration
);
```

2. Configure the holonomic drive controller:
```java
public static final PPHolonomicDriveController PP_HOLONOMIC_DRIVE_CONTROLLER =
new PPHolonomicDriveController(
new PIDConstants(2.4, 0, 0.015), // Translation PID
new PIDConstants(7.8, 0, 0.015) // Rotation PID
);
```

### Performance Tuning

In SwerveDriveSubsystemConstants.java:

1. Configure performance modes:
```java
public static final class PerformanceModeDefault {
public static final double DRIVE_TRAIN_MAX_SPD = 3.5; // m/s
public static final double DRIVE_TRAIN_MAX_ACCELERATION = 2.0; // m/s²
public static final double DRIVE_TRAIN_MAX_ROT_SPD = 0.75 * 2 * Math.PI; // rad/s
}
```

2. Configure acceleration limits:
```java
public static final double DRIVE_XY_SPD_PERF_MODE_SW_FILTER_RATE = 8.0; // m/s/s
public static final double DRIVE_ROT_SPD_PERF_MODE_SW_FILTER_RATE = 4.0; // rad/s/s
```

## Telemetry Configuration

In SwerveDriveTelemetry.java:

1. Configure Shuffleboard layout:
```java
private ShuffleboardLayout initializePoseList(SwerveDriveSubsystem swerveDrive) {
return driveTab
.getLayout("Pose", BuiltInLayouts.kList)
.withSize(2, 3)
.withPosition(0, 0);
}
```

2. Add custom telemetry data:
```java
private void initializeOtherWidgets(SwerveDriveSubsystem swerveDrive) {
driveTab.addBoolean("Custom Metric", () -> /* your condition */);
}
```

## Usage Examples

### Basic Drive Configuration
```java
// Create drivetrain using the appropriate year's TunerConstants
SwerveDriveSubsystem swerve = TunerConstants.createDrivetrain();

// Configure PathPlanner
SwerveDrivePathPlanner pathPlanner = new SwerveDrivePathPlanner(swerve);
```

### Autonomous Path Following
```java
// Load and run an autonomous path
Command autoPath = pathPlanner.getAutoPath("YourPathName");
autoPath.schedule();

// Create a pathfinding command to a specific pose
Command pathfindCommand = pathPlanner.getPathFinderCommand(
new Pose2d(1, 1, new Rotation2d()),
MetersPerSecond.of(0)
);
```

### Manual Drive Control
```java
swerve.applyRequest(() ->
new SwerveRequest.FieldCentric()
.withVelocityX(joystickX)
.withVelocityY(joystickY)
.withRotation(joystickRotation)
);
```

## Best Practices

1. Module Configuration
- Calibrate encoder offsets with the robot elevated and wheels pointing forward
- Verify motor and encoder IDs match physical hardware
- Double-check gear ratios against physical hardware

2. PathPlanner Usage
- Keep path constraints within physical capabilities
- Test autonomous paths at reduced speeds first
- Use the PathPlanner GUI to visualize and verify paths

3. Performance Tuning
- Start with conservative speed limits
- Gradually increase limits while monitoring stability
- Test all performance modes thoroughly

4. Telemetry
- Monitor module states during testing
- Use field visualization to verify odometry
- Log relevant data for troubleshooting
Loading

0 comments on commit 898d5de

Please sign in to comment.