Package frc.robot.sim
Class FuelSim
java.lang.Object
frc.robot.sim.FuelSim
Simulator for fuel by FRC Team 5000.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the field of fuelstatic FuelSimReturns a singleton instance of FuelSimvoidlogFuels()Adds array of `Translation3d`'s to NetworkTables at "AdvantageKit/RealOutputs/Fuel Simulation/Fuels"voidregisterIntake(double xMin, double xMax, double yMin, double yMax) Registers an intake with the fuel simulator.voidregisterIntake(double xMin, double xMax, double yMin, double yMax, Runnable intakeCallback) Registers an intake with the fuel simulator.voidregisterIntake(double xMin, double xMax, double yMin, double yMax, BooleanSupplier ableToIntake) Registers an intake with the fuel simulator.voidregisterIntake(double xMin, double xMax, double yMin, double yMax, BooleanSupplier ableToIntake, Runnable intakeCallback) Registers an intake with the fuel simulator.voidregisterRobot(double width, double length, double bumperHeight, Supplier<Pose2d> poseSupplier, Supplier<ChassisSpeeds> fieldSpeedsSupplier) Registers a robot with the fuel simulatorvoidsetSubticks(int subticks) Sets the number of physics iterations per loop (0.02s)voidspawnFuel(Translation3d pos, Translation3d vel) Adds a fuel onto the fieldvoidSpawns fuel in the neutral zone and depotsvoidstart()Start the simulation.voidstepSim()Run the simulation forward 1 time step (0.02s)voidstop()Pause the simulation.voidTo be called periodically Will do nothing if sim is not running
-
Method Details
-
getInstance
Returns a singleton instance of FuelSim -
clearFuel
public void clearFuel()Clears the field of fuel -
spawnStartingFuel
public void spawnStartingFuel()Spawns fuel in the neutral zone and depots -
logFuels
public void logFuels()Adds array of `Translation3d`'s to NetworkTables at "AdvantageKit/RealOutputs/Fuel Simulation/Fuels" -
start
public void start()Start the simulation. `updateSim` must still be called every loop -
stop
public void stop()Pause the simulation. -
setSubticks
public void setSubticks(int subticks) Sets the number of physics iterations per loop (0.02s)- Parameters:
subticks- number of iterations
-
registerRobot
public void registerRobot(double width, double length, double bumperHeight, Supplier<Pose2d> poseSupplier, Supplier<ChassisSpeeds> fieldSpeedsSupplier) Registers a robot with the fuel simulator- Parameters:
width- from left to right (y-axis)length- from front to back (x-axis)bumperHeight- bumper height in meters (z-axis)poseSupplier- robot posefieldSpeedsSupplier- field-relative `ChassisSpeeds` supplier
-
updateSim
public void updateSim()To be called periodically Will do nothing if sim is not running -
stepSim
public void stepSim()Run the simulation forward 1 time step (0.02s) -
spawnFuel
Adds a fuel onto the field- Parameters:
pos- Position to spawn atvel- Initial velocity vector
-
registerIntake
public void registerIntake(double xMin, double xMax, double yMin, double yMax, BooleanSupplier ableToIntake, Runnable intakeCallback) Registers an intake with the fuel simulator. This intake will remove fuel from the field based on the `ableToIntake` parameter.- Parameters:
xMin- Minimum x position for the bounding boxxMax- Maximum x position for the bounding boxyMin- Minimum y position for the bounding boxyMax- Maximum y position for the bounding boxableToIntake- Should a return a boolean whether the intake is activeintakeCallback- Function to call when a fuel is intaked
-
registerIntake
public void registerIntake(double xMin, double xMax, double yMin, double yMax, BooleanSupplier ableToIntake) Registers an intake with the fuel simulator. This intake will remove fuel from the field based on the `ableToIntake` parameter.- Parameters:
xMin- Minimum x position for the bounding boxxMax- Maximum x position for the bounding boxyMin- Minimum y position for the bounding boxyMax- Maximum y position for the bounding boxableToIntake- Should a return a boolean whether the intake is active
-
registerIntake
public void registerIntake(double xMin, double xMax, double yMin, double yMax, Runnable intakeCallback) Registers an intake with the fuel simulator. This intake will always remove fuel from the field.- Parameters:
xMin- Minimum x position for the bounding boxxMax- Maximum x position for the bounding boxyMin- Minimum y position for the bounding boxyMax- Maximum y position for the bounding boxintakeCallback- Function to call when a fuel is intaked
-
registerIntake
public void registerIntake(double xMin, double xMax, double yMin, double yMax) Registers an intake with the fuel simulator. This intake will always remove fuel from the field.- Parameters:
xMin- Minimum x position for the bounding boxxMax- Maximum x position for the bounding boxyMin- Minimum y position for the bounding boxyMax- Maximum y position for the bounding box
-