Class IntakeSimulation

java.lang.Object
org.dyn4j.collision.Fixture
org.dyn4j.dynamics.BodyFixture
org.ironmaple.simulation.IntakeSimulation
All Implemented Interfaces:
org.dyn4j.DataContainer

public class IntakeSimulation extends org.dyn4j.dynamics.BodyFixture

Simulates an Intake Mechanism on the Robot.

CheckOnline Documentation

The intake is a 2D component attached to one side of the robot's chassis. It is rectangular in shape and extends from the robot when activated.

The intake can be turned on through startIntake(), which causes it to extend, expanding the collision space of the robot's chassis. When turned off via stopIntake(), the intake retracts.

The intake can "collect" GamePieceOnFieldSimulation instances from the field, removing them and incrementing the gamePiecesInIntakeCount.

A game piece is collected if the following conditions are met:

Note: This class simulates an idealized "touch it, get it" intake and does not model the actual functioning of an intake mechanism.

  • Constructor Details

    • IntakeSimulation

      public IntakeSimulation(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, edu.wpi.first.units.measure.Distance width, IntakeSimulation.IntakeSide side, int capacity)

      Creates an Intake Simulation that Tightly Attaches to One Side of the Chassis.

      Parameters:
      targetedGamePieceType - the type of game pieces that this intake can collect
      driveTrainSimulation - the chassis to which this intake is attached
      width - the width of the intake
      side - the side of the chassis where the intake is attached
      capacity - the maximum number of game pieces that the intake can hold
    • IntakeSimulation

      public IntakeSimulation(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, edu.wpi.first.units.measure.Distance width, edu.wpi.first.units.measure.Distance lengthExtended, IntakeSimulation.IntakeSide side, int capacity)

      Creates an Intake Simulation that Extends Out of the Chassis Frame.

      Parameters:
      targetedGamePieceType - the type of game pieces that this intake can collect
      driveTrainSimulation - the chassis to which this intake is attached
      width - the valid width of the intake
      lengthExtended - the length the intake extends out from the chassis when activated
      side - the side of the chassis where the intake is attached
      capacity - the maximum number of game pieces that the intake can hold
    • IntakeSimulation

      public IntakeSimulation(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, org.dyn4j.geometry.Convex shape, int capacity)

      Creates an Intake Simulation with a Specific Shape.

      This constructor initializes an intake with a custom shape that is used when the intake is fully extended.

      Parameters:
      targetedGamePieceType - the type of game pieces that this intake can collect
      driveTrainSimulation - the chassis to which this intake is attached
      shape - the shape of the intake when fully extended, represented as a Convex object
      capacity - the maximum number of game pieces that the intake can hold
  • Method Details

    • startIntake

      public void startIntake()

      Turns the Intake On.

      Extends the intake out from the chassis, making it part of the chassis's collision space.

      Once activated, the intake is considered running and will listen for contact with GamePieceOnFieldSimulation instances, allowing it to collect game pieces.

    • stopIntake

      public void stopIntake()

      Turns the Intake Off.

      Retracts the intake into the chassis, removing it from the chassis's collision space.

      Once turned off, the intake will no longer listen for or respond to contacts with GamePieceOnFieldSimulation instances.

    • getGamePiecesAmount

      public int getGamePiecesAmount()

      Get the amount of game pieces in the intake.

      Returns:
      the amount of game pieces stored in the intake
    • obtainGamePieceFromIntake

      public boolean obtainGamePieceFromIntake()

      Removes 1 game piece from the intake.

      Deducts the getGamePiecesAmount()} by 1, if there is any remaining.

      This is used to obtain a game piece from the intake and move it a feeder/shooter.

    • getGamePieceContactListener

      public IntakeSimulation.GamePieceContactListener getGamePieceContactListener()

      Obtains a New Instance of the IntakeSimulation.GamePieceContactListener for This Intake.

      Returns:
      a new IntakeSimulation.GamePieceContactListener for this intake
    • getGamePiecesToRemove

      public Queue<GamePieceOnFieldSimulation> getGamePiecesToRemove()

      Obtains the GamePieceOnFieldSimulation Instances to Be Removed from the Field.

      This method is called from SimulatedArena.simulationPeriodic() to retrieve game pieces that have been marked for removal.

      Game pieces are marked for removal if they have come into contact with the intake during the last SimulatedArena.getSimulationSubTicksIn1Period() sub-ticks. These game pieces should be removed from the field to reflect their interaction with the intake.

      Returns:
      a Queue of game pieces to be removed from the field
    • clearGamePiecesToRemoveQueue

      public void clearGamePiecesToRemoveQueue()

      Clears the Game Pieces Marked for Removal.

      This method is called from SimulatedArena.simulationPeriodic() after the game pieces marked for removal have been processed and removed from the field.

      It clears the queue of game pieces marked for removal

    • register

      public void register()
    • register

      public void register(SimulatedArena arena)