Disclaimer: Although other teams are able to use this, I don’t believe that there is enough documentation yet for me to encourage others to use this.
For the past three months, I’ve been working on a LibGDX simulation of our ALL of our robot code. This allows us to simulate our drive train and will allow us to simulate our autonomous without a robot and without the driver station!
Note: The recording software I used didn’t record my mouse
Don’t read the rest of this if you aren’t a programmer (fair warning)
RoboSim works by abstracting just about every possible thing that WPI does even further. This means that the
core module for robot2019 doesn’t import ANY WPI code (this might change in the future, I haven’t decided yet). RoboSim has zero global state, the entire project is driven by simple dependency injection, making it easy to abstract the code and alter behavior. There is a
wpi submodule and
gdx submodule that both utilize the
The program supports “Practice” and “Real” modes. Practice to quickly test code and real to fully simulate a real match, just like a real driver station. You can easily switch between them by pressing exit. While creating this, there were a few bugs when testing it with shuffleboard code because of the global state, so I decided to abstract that too with abstract-dashboard! I did have a valid reason for that: When re-initializing a new program, Shuffleboard would throw errors when I add something with the same name as last time it was initialized (this is why I hate global state that you cannot reset.)
You can see in the video that the small dashes represent our Swerve Drive wheels, which is accurate to how our swerve modules move. Because LibGDX has Box2D support, I was able to easily set the velocities of each wheel and fully simulate the Swerve Drive without trying to figure out the math to make the constraints work on the wheels and make the robot move accurately. If we decide to go with tank in 2020, we’ll be able to change the simulation to support tank drive as well.
However, somethings I decided not to simulate: The lift, picking up cargo, placing hatch panels and PID loops for these things. (Basically everything that makes driving the robot for real fun).
Before kickoff or during the season, I want to create another part of the program that receives the absolute position of our robot and shows the robot on the field.
Feel free to ask questions or call me crazy for abstracting the entirety of WPILib.