Skip to content

Core Architecture

MARSLib is designed with a strict zero-allocation abstraction layer. The framework shields deterministic physics processing and automated logging from the hardware implementations to guarantee consistency across physical and simulated robots.

graph TD
Z["User Project<br><i>RobotContainer.java</i>"] -->|Depends On| A("MARSLib Framework<br><i>Vendor Dependency</i>")
A --> C[Swerve Subsystem]
A --> D[Mechanisms]
A --> E[System Utilities]
C <--> F{"IO Abstraction Layer"}
D <--> F
E <--> F
F <-->|Hardware Mode| G["IOReal<br><i>TalonFX, Pigeon2</i>"]
F <-->|Simulation Mode| H["IOSim<br><i>Dyn4j Physics</i>"]
G --> I[("(AdvantageKit Log)")]
H --> I
style Z fill:#0a0a0a,stroke:#2a2a2a,stroke-width:2px,color:#e8e8e8
style A fill:#141414,stroke:#B32416,stroke-width:2px,color:#e8e8e8
style C fill:#1a1a1a,stroke:#2a2a2a,stroke-width:1px,color:#e8e8e8
style D fill:#1a1a1a,stroke:#2a2a2a,stroke-width:1px,color:#e8e8e8
style E fill:#1a1a1a,stroke:#2a2a2a,stroke-width:1px,color:#e8e8e8
style F fill:#B32416,stroke:#d42e1e,stroke-width:2px,color:#fff
style G fill:#2a2a2a,stroke:#1a1a1a,stroke-width:1px,color:#29b6f6
style H fill:#2a2a2a,stroke:#1a1a1a,stroke-width:1px,color:#9c7bcc
style I fill:#0a0a0a,stroke:#6ba3d6,stroke-width:2px,color:#6ba3d6

Core framework packages and their responsibilities.

PackageDescriptionKey Classes
com.marslib.swerve250Hz odometry, swerve kinematics, traction controlSwerveDrive, SwerveModule, PhoenixOdometryThread
com.marslib.visionAprilTag localization with MegaTag 2.0 fusionMARSVision, VisionIO
com.marslib.mechanismsGeneric IO abstractionsRotaryMechanismIO, LinearMechanismIO
com.marslib.faultsThread-safe fault reportingMARSFaultManager, Alert
com.marslib.simulationDyn4j physics world, game piece spawningMARSPhysicsWorld, GamePieceBody
com.marslib.powerVoltage load-shedding and stator monitoringMARSPowerManager
com.marslib.utilState machines, tunable numbers, shot mathMARSStateMachine, EliteShooterMath
com.marslib.autoPathPlanner integration, alignment commandsMARSAutoBuilder
frc.robotCompetition logic: RobotContainer, commandsRobotContainer, MARSSuperstructure




?? Further Reading & External Resources