Package frc.robot.sim

Class FuelSim

java.lang.Object
frc.robot.sim.FuelSim

public class FuelSim extends Object
Simulator for fuel by FRC Team 5000.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Hub Goal
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the field of fuel
    static FuelSim
    Returns a singleton instance of FuelSim
    void
    Adds array of `Translation3d`'s to NetworkTables at "AdvantageKit/RealOutputs/Fuel Simulation/Fuels"
    void
    registerIntake(double xMin, double xMax, double yMin, double yMax)
    Registers an intake with the fuel simulator.
    void
    registerIntake(double xMin, double xMax, double yMin, double yMax, Runnable intakeCallback)
    Registers an intake with the fuel simulator.
    void
    registerIntake(double xMin, double xMax, double yMin, double yMax, BooleanSupplier ableToIntake)
    Registers an intake with the fuel simulator.
    void
    registerIntake(double xMin, double xMax, double yMin, double yMax, BooleanSupplier ableToIntake, Runnable intakeCallback)
    Registers an intake with the fuel simulator.
    void
    registerRobot(double width, double length, double bumperHeight, Supplier<Pose2d> poseSupplier, Supplier<ChassisSpeeds> fieldSpeedsSupplier)
    Registers a robot with the fuel simulator
    void
    setSubticks(int subticks)
    Sets the number of physics iterations per loop (0.02s)
    void
    Adds a fuel onto the field
    void
    Spawns fuel in the neutral zone and depots
    void
    Start the simulation.
    void
    Run the simulation forward 1 time step (0.02s)
    void
    Pause the simulation.
    void
    To be called periodically Will do nothing if sim is not running

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      public static FuelSim 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 pose
      fieldSpeedsSupplier - 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

      public void spawnFuel(Translation3d pos, Translation3d vel)
      Adds a fuel onto the field
      Parameters:
      pos - Position to spawn at
      vel - 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 box
      xMax - Maximum x position for the bounding box
      yMin - Minimum y position for the bounding box
      yMax - Maximum y position for the bounding box
      ableToIntake - Should a return a boolean whether the intake is active
      intakeCallback - 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 box
      xMax - Maximum x position for the bounding box
      yMin - Minimum y position for the bounding box
      yMax - Maximum y position for the bounding box
      ableToIntake - 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 box
      xMax - Maximum x position for the bounding box
      yMin - Minimum y position for the bounding box
      yMax - Maximum y position for the bounding box
      intakeCallback - 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 box
      xMax - Maximum x position for the bounding box
      yMin - Minimum y position for the bounding box
      yMax - Maximum y position for the bounding box