Skip to content

MARSProgramming/MARSLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

441 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸͺ MARSLib

FRC AdvantageKit Abstraction & Physics Template

CI Build Coverage Branches Spotless Team AdvantageKit Dyn4j Docs

A championship-tier software template for Mountaineer Area RoboticS β€” FRC Team 2614.


Welcome to MARSLib, an aggressively hardened framework that enables pure, deterministic AdvantageKit logging while bridging seamless 2D physics simulations via dyn4j.

This architecture is built so that students can develop completely offline. Our simulation logic doesn't just run mathematical encodersβ€”it simulates hexagonal REBUILT obstacles, voltage sag limits, and bounding box superstructure collisions.

πŸš€ Key Features

  • 100% Simulated Logic: Run ./gradlew simulateJava and visualize your robot mathematically navigating the REBUILT field before you even touch a real battery.
  • Time-Of-Flight Aiming: Native quadratic kinematic intersections mean the robot shoots accurately while pulling full-speed swerve maneuvers.
  • Voltage Load-Shedding: A native Stator Current allocation daemon statically bounds TalonFX modules to actively prevent robotic brownouts when pushing against defense.
  • Continuous Automation: Every push to GitHub runs a spotless lint check and validates physics-backed JUnit tests against the dyn4j simulation engine before compiling and logging an uploadable JAR.

πŸ“– Documentation

Full API documentation is available at MARSProgramming.github.io/MARSLib

To generate documentation locally:

./gradlew generateDocs
# Open docs/index.html in your browser

🧬 Architecture Diagram

The codebase strictly enforces the AdvantageKit Dependency Injection pattern, isolating the logical robot from the physical/simulated hardware.

graph TD
    classDef io fill:#2b66a2,stroke:#1f4a76,stroke-width:2px,color:white;
    classDef logic fill:#003f00,stroke:#002900,stroke-width:2px,color:white;
    classDef ext fill:#4a4a4a,stroke:#333333,stroke-width:2px,color:white;

    Subsystem[Subsystem Logic / State Machines]:::logic
    IO[SubsystemIO Interface]:::io
    Real[SubsystemIOReal: TalonFX / Limelight / QuestNav]:::ext
    Sim[SubsystemIOSim: Dyn4j Physics Engine]:::ext
    Log[(AdvantageKit Logger)]:::ext

    Subsystem -->|Injects| IO
    IO -.->|Physical Robot| Real
    IO -.->|Desktop Sim| Sim
    Subsystem -->|Records State| Log
Loading

πŸ“‚ Repository Layout

MARSLib/
β”œβ”€β”€ .github/                 # CI Pipelines, Dependabot, and PR Templates
β”œβ”€β”€ .wpilib/                 # FRC 2614 Team Radio Configurations
β”œβ”€β”€ docs/                    # Generated documentation site (GitHub Pages)
β”œβ”€β”€ com.marslib/             # Inner Architecture (Do Not Edit Routine Logic Here)
β”‚   β”œβ”€β”€ auto/                # PathPlanner Integration & Diagnostic Checks
β”‚   β”œβ”€β”€ faults/              # MARSFaultManager & Alert System
β”‚   β”œβ”€β”€ mechanisms/          # Linear/Rotary/Flywheel IO Abstractions
β”‚   β”œβ”€β”€ power/               # MARSPowerManager Load-Shedding Daemon
β”‚   β”œβ”€β”€ simulation/          # Dyn4j World Bounds and Hexagonal Meshes
β”‚   β”œβ”€β”€ swerve/              # 250Hz Odometry Thread & Odometry Computations
β”‚   β”œβ”€β”€ util/                # Time-Of-Flight Interpolation, State Machines, Alliance Utils
β”‚   └── vision/              # AprilTag & SLAM Fusion Pipelines
└── frc.robot/               # Competition Logic (Edit Your Logic Here!)
    β”œβ”€β”€ commands/            # PathPlanner routines and Teleop Commands
    β”œβ”€β”€ constants/           # All tunable parameters (Vision, Field, Shooter, etc.)
    β”œβ”€β”€ simulation/          # Game Piece Physics Bodies
    β”œβ”€β”€ subsystems/          # Implementations of your Superstructure/Arm
    └── RobotContainer.java  # Controller Mapping and Subsystem bindings

πŸ›  Usage & Setup

1. Developer Formatting

To ensure your code never gets rejected by GitHub's automated CI, run the included batch script to initialize a spotless Git Hook!

# Windows
.\install-git-hooks.bat

(This forces your VS Code to auto-format build.gradle structures before you push!)

2. Creating Subsystems

MARSLib abstracts the Real hardware from the Sim hardware using pure Dependency Injection interfaces.

  1. SubsystemIO - The Interface (What data does this mechanism need?)
  2. SubsystemIOReal - The Hardware (TalonFX / CANSparkMax / NavX)
  3. SubsystemIOSim - The Physics (Dyn4j wrappers, friction calculations)

3. Firing up AdvantageScope

Want to analyze a bug or replay a match?

  1. Open AdvantageScope
  2. Click File > Open Layout and select the advantagescope_layout.json located at the root of this repository!
  3. You now have a fully operational 3D Dashboard monitoring battery voltage limits alongside Hexagonal Field boundaries.

πŸ› Found a Bug?

Use our customized GitHub Issue Templates to let the software leads know exactly what went wrong in your simulation or physical robot code! Whether it's a new PathPlanner routine request or an odometry jitter bug, the templates will automatically guide you through attaching your .wpilog telemetry data.

βš–οΈ Open Source Acknowledgements

MARSLib stands upon the shoulders of giants. We extend our deepest gratitude to the MapleSim project for their groundbreaking simulation patterns, and to the following open-source maintainers and vendors who make modern FRC possible:

WPILib AdvantageKit Dyn4j PathPlanner PhotonVision CTRE REV MapleSim

About

No description, website, or topics provided.

Resources

License

MIT and 2 other licenses found

Licenses found

MIT
LICENSE
MIT
Dyn4j-License.md
MIT
PathPlanner-License.md

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors