2024 Robot Code featuring swerve drive, autonomous path following, vision tracking, and automated game piece handling.
This codebase features:
- Advanced swerve drive control with field-centric and robot-centric modes
- Vision-based target tracking and autonomous alignment
- Automated game piece intake, indexing, and launching
- Path planning and autonomous navigation
- Comprehensive telemetry and diagnostics
- Support for both competition and practice robots
.
├── src/main/java/ # Main source code directory
│ ├── com/team254/lib/ # Core libraries from Team 254
│ │ ├── control/ # Control system components
│ │ ├── geometry/ # Geometric calculations and transforms
│ │ ├── motion/ # Motion profiling and path generation
│ │ ├── swerve/ # Swerve drive kinematics and control
│ │ └── vision/ # Vision processing utilities
│ └── net/teamrush27/frc2024/ # Team-specific robot code
│ ├── autonomous/ # Autonomous routines and commands
│ ├── controlboard/ # Driver interface and controls
│ ├── subsystems/ # Robot subsystems (drive, launcher, etc.)
│ └── util/ # Utility classes
├── build.gradle # Gradle build configuration
└── vendordeps/ # Third-party library dependencies
- WPILib 2024.3.2 or later
- Java Development Kit (JDK) 17
- Phoenix 6 library for CTRE motor controllers
- REVLib for REV Robotics hardware
- PathPlanner library for autonomous path planning
- Clone the repository:
git clone <repository-url>
cd frc2024
- Install dependencies:
./gradlew vendordep
- Build the project:
./gradlew build
-
Configure robot type in
Constants.java
(COMPETITION or PRACTICE) -
Deploy to the robot:
./gradlew deploy
- Basic operation:
- Driver controls use field-centric swerve drive by default
- Operator controls manage game piece handling and shooting
- Autonomous routines can be selected via SmartDashboard
- Swerve Drive Control:
// Field-centric drive
drivetrain.setWantedState(WantedState.FIELD_CENTRIC);
drivetrain.drive(xSpeed, ySpeed, rotation);
// Target tracking
drivetrain.setWantedState(WantedState.SPEAKER_ALIGN);
- Game Piece Handling:
// Intake and shoot sequence
supervisor.setWantedState(SupervisorWantedState.INTAKE);
supervisor.setLauncherShotType(ShotType.SPEAKER);
supervisor.setWantedState(SupervisorWantedState.FIRE);
Common issues:
-
CAN Bus Communication Issues
- Check Phoenix Tuner for device connectivity
- Verify CAN IDs match configuration
- Check CAN termination resistors
-
Swerve Module Calibration
- Use Phoenix Tuner to verify encoder offsets
- Check module alignment in robot characterization
- Verify motor controller configurations
-
Vision Tracking Problems
- Check camera exposure settings
- Verify AprilTag positions in field configuration
- Monitor network latency and packet loss
The robot control system follows a hierarchical data flow architecture:
Driver Input -> ControlBoard -> Subsystem Manager
| | |
v v v
Drivetrain <-> PoseEstimator <-> Vision
| | |
v v v
Motion Planning -> Supervisor -> Subsystems
Key interactions:
- ControlBoard processes driver inputs and maps to robot commands
- PoseEstimator fuses odometry and vision data for robot localization
- Supervisor coordinates subsystem states for game piece handling
- Drivetrain handles low-level motor control and kinematics
- Vision system provides target tracking and field localization
- TalonFX drive motors (CAN IDs 10-17)
- CANcoder absolute encoders (CAN IDs 18-21)
- Pigeon2 IMU (CAN ID 3)
- SparkFlex controllers for auxiliary mechanisms
- Through-bore encoders for position feedback
- CANFD bus for motor controllers
- Standard CAN for auxiliary devices
- NetworkTables for dashboard communication