I had some autonomous code but haven’t had the chance to try it out on our robot yet and was wondering if it would work. I saw RobotPy’s drivetrain physics simulation and was wondering if I could do something similar. I used simulated wheel speeds to keep track of left and right wheel cumulative distances to feed into odometry, and used DifferentialDriveKinematics to figure out rotation rate and then multiplied by a constant to slow it down (not sure how to simulate our robot’s weight). I also simulated the Limelight target x and y by doing some trig calculations. The funny thing is that the angles are still properly reported even if the Limelight wouldn’t normally be able to see the target. It works so much better than I expected!
Drive Train simulation code: https://github.com/FRC-4277/2020InfiniteRecharge/blob/simulate-autonomous/src/main/java/frc/robot/subsystems/DriveTrain.java#L314-L352
Limelight simulation code: https://github.com/FRC-4277/2020InfiniteRecharge/blob/simulate-autonomous/src/main/java/frc/robot/util/limelight/Limelight.java#L57-L109
Two autonomous commands simulated:
I was wondering if anyone had any suggestion on how to properly simulate the drive train, considering robot weight.