Maple-sim Alpha: Bringing Robot Simulations to the Next Level with Physics Engines

Extending work described in this post, Iron Maple proudly presents our latest simulation library, maple -sim!

team logo project logo

maple-sim is a physics-based simulation library designed to elevate FRC Java robot simulations by introducing real-world dynamics into your testing process. Built on the powerful dyn4j engine, maple-sim models robot interactions with the field, game pieces, and even opponent robots, providing a highly realistic environment for testing and optimizing your code.

From simulating swerve-drive dynamics to practicing auto paths and testing intake mechanisms, maple-sim brings your robot’s functionality to life in a virtual space. It’s designed to help teams refine their strategies, improve autonomous routines, and fine-tune systems—all without needing a physical robot.

Key Features:

  • Swerve-Drive Simulation: Model drivetrain forces and interactions with field obstacles and game pieces.

    View GIF
  • Odometry & Vision Simulation: Simulate real-world odometry errors and integrate with vision systems like photonlib.

    View GIF
  • Game Pieces & Intake Simulation: Test intake mechanisms and robot interactions with game pieces.

    View GIF
  • Projectiles Simulation: Model the physics of launched game pieces and optimize shooter controls.

    View GIF
  • Opponent Robot Simulation: Practice defensive and offensive strategies against simulated opponents.

    View GIF

Demo Video 1

Ready to take your robot simulation to the next level? Check out the full project here:

Quick Start

Please see the following guides:

  1. Hardware Abstractions
  2. Installing maple-sim
  3. Using the Simulated Arena
  4. Simulating Swerve Drivetrain
  5. Simulating Intake
  6. Simulating Projectiles
  7. Simulating Opponent Robots

Example & Templates

  1. Maple-Swerve-Skeleton: Our custom swerve drive project based on Advanced Swerve Drive Project with drivetrain simulation, vision simulation and some convenient controlling features.
  2. 5516-2024-OffSeason-RobotCode: The “video game” showed in the video above, which also runs on the physical hardware of our 2024 off-season robot “11:59”

:warning: Limitations

Currently, maple-sim is developed and maintained by a single student, so bugs and glitches are to be expected, particularly in this alpha version.

While maple-sim offers a unique and interesting approach to simulation, it may not be suitable for every team. Implementing it requires significant changes to the low-level code of your drivetrain, which could demand considerable effort.

:x: YAGSL

At present, maple-sim does not support YAGSL (Yet Another Generic Swerve Library), as YAGSL already includes its own simulation features.

However, we are excited about the possibility of collaborating with the YAGSL developer to integrate support in the future.

47 Likes

Oooh you have my interest. Very cool

4 Likes

This looks interesting. :eyes:

I’ll be happy to help w/ development if you need!

Btw, I think it would probably be a better idea to architect the library in a way that doesn’t enforce any requirements on the subsystem/io structuring itself. Reading from the docs, it seems like using GyroSimulation and SwerveModuleSimulation are requirements to have the simulation working, and I’m wondering if there’s a more hands-off approach to this(like having a generic DriveSim class that instead accepts module states and gyro heading, and have GyroSimulation, SwerveModuleSimulation and BrushlessMotorSimulation be utility classes that the user can optionally implement).

Finally, I believe that the library should either choose to use inheritance or subclassing and shouldn’t intermix the two(rn, IntakeSimulation seems to use inheritance while GyroSimulation and SwerveModuleSimulation use subclassing instead).

3 Likes

Your suggestions are really helpful, and I’m excited to collaborate with you on the project!

I’ll definitely explore the choice between inheritance and subclassing more carefully, as you’re right—mixing the two is not a good practice. I’ll also set up a Discord group soon to make collaboration easier.

This is my first time building a library as a high school student, so I understand that some parts of the code are rough or buggy. If you spot any areas that could be improved, I would greatly appreciate any feedback or suggestions. :smiley:

3 Likes

Woah! Great work

1 Like

nice work :ok_hand:

1 Like

Honestly it’s amazing that you’ve created this alone so far! The amount of people using AdvantageKit this year was mind-boggling! I am very proud that many teams were able to successfully use it! Your work will inevitably become crucial to help all of FRC (and hopefully be upstreamed at some point) and I would love to collaborate and work on some integration of this into YAGSL!

2 Likes

Once or twice a week I go “hm wonder what Catrix from Iron Maple is up to” and then i check their chiefdelphi account and they’re always up to something 3 times cooler than what they were doing the week before. This is amazing work! Super excited to see where this goes :slight_smile:

2 Likes

It too love this project and have been keeping my eye on it for a while. I also would love to help this project. Yesterday I actually implemented it into my 2025 AdvantageKit advanced swerve drive. I will open (and try to fix) issues for any bugs I find. I you need me to write any code for this, ill do my best!

1 Like

This is so cool, I have been looking for a tool that does something like this and am so happy that one is being made. If you are looking for more devs please lmk, I would love to work on this.

1 Like

I’m genuinely touched by the willingness many of you have shown to help with development. Your kindness and support are greatly appreciated.

I have a few plans for future developments, and we could certainly use some assistance.

Easy Swerve Simulation (Top Priority)

Based on feedback, I understand that the current “hardware abstraction” style may be too complex for some teams. Many might prefer a simpler approach, so we’re planning to create an EasySwerveDriveSimulation instance that teams can easily integrate into their drive subsystems to handle all simulations. Meanwhile, ModuleSimulation and GyroSimulation will remain available for teams seeking highly accurate and realistic simulations.

Restructuring the IntakeSimulation

:pray: Big thanks to @Daniel1464 for pointing this out.

After revisiting the codebase, I realized that using inheritance for IntakeSimulation and subclassing for other classes wasn’t the best approach. I’ll refactor the current code of `IntakeSimulation’ and follow a universal pattern of using subclassing throughout the project.

Setting Up a GitHub Issue Template

Since I’m new to maintaining public projects, I’ve heard that having an issue template can streamline bug reports and make fixes more efficient. If anyone knows how to set this up, your help would be immensely appreciated!

Publishing the Library

Currently, maple-sim is hosted on GitHub packages, which requires manually adding the repository in build.gradle. There’s likely a more efficient way to publish it, but I’m not familiar with Java packaging. Any guidance here would be fantastic.

Helping YAGSL with Potential Integration of maple-sim

I had a brief discussion with @nstrike about integrating maple-sim into the amazing YAGSL project. I’ve outlined a rough plan, but I would love to hear feedback from the YAGSL user community on this potential integration.


PS: These are just my thoughts and ideas. Feel free to debate or suggest alternatives!


Join Our Discord Server

For further discussion on development or to get help, please join our Discord community:

13 Likes

I’ve also been looking over your library to figure out the best way to integrate it into PurpleLib.

6 Likes

hey, i’d love to help with this, feel free to message me! this seems like a great project, and i’m gonna try my best to implement it next year on my team

1 Like

Hopefully we can get a good release of YAGSL with IronMaple out soon! Lmk if you need anymore help with the vendordep.

4 Likes

Thank you so much for all your help! In just three days, you’ve managed to accomplish what I couldn’t finish in the past three months! :hugs:

2 Likes

No problem! I learned alot about gradle and the wpilib vendordeps in the process. I need to redo parts of my gradle config for YAGSL soon now.

I can’t wait to see how many teams use Maple-Sim this year!

3 Likes

Under Swerve drive simulation you have

public enum DRIVE_WHEEL_TYPE {
        RUBBER,
        TIRE
    }
    private static double getWheelGripping(DRIVE_WHEEL_TYPE type) {
        return switch (type) {
            case RUBBER -> 1.25;
            case TIRE -> 1.15;
        };
    }

How are the values of the Rubber and Tire calculated? How did you come to get 1.25 and 1.15?

Unrelated to how this is calculated but you can improve this code by adding fields to the enums instead of using a switch case

public enum DRIVE_WHEEL_TYPE {
public final double wheelGrip;

    RUBBER(1.15),
    TIRE(1.25);

    public DRIVE_WHEEL_TYPE(double wheelGrip) { 
  this.wheelGrip = wheelGrip;
 }
}
1 Like

It’s just a guess. :rofl: I opened up two driver practice log files with the two types of wheels and tuned the numbers until the simulation looked “realistic.”