Class IntakeSimulation
- All Implemented Interfaces:
org.dyn4j.DataContainer
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:
- 1. The type of the game piece (
GamePieceOnFieldSimulation.type) matchestargetedGamePieceType. - 2. The
GamePieceOnFieldSimulationis in contact with the intake (and not other parts of the robot). - 3. The intake is turned on via
startIntake(). - 4. The number of game pieces in the intake (
gamePiecesInIntakeCount) is less thancapacity.
Note: This class simulates an idealized "touch it, get it" intake and does not model the actual functioning of an intake mechanism.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classTheContactListenerfor the Intake Simulation.static enum -
Field Summary
Fields inherited from class org.dyn4j.dynamics.BodyFixture
DEFAULT_DENSITY, DEFAULT_FRICTION, DEFAULT_RESTITUTION, DEFAULT_RESTITUTION_VELOCITY, density, friction, restitution, restitutionVelocityFields inherited from class org.dyn4j.collision.Fixture
filter, sensor, shape, userData -
Constructor Summary
ConstructorsConstructorDescriptionIntakeSimulation(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, org.dyn4j.geometry.Convex shape, int capacity) Creates an Intake Simulation with a Specific Shape. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds 1 game piece from the intake.Obtains a New Instance of theIntakeSimulation.GamePieceContactListenerfor This Intake.intGet the amount of game pieces in the intake.static IntakeSimulationInTheFrameIntake(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, Distance width, IntakeSimulation.IntakeSide side, int capacity) Creates an Intake Simulation that Tightly Attaches to One Side of the Chassis.booleanRemoves 1 game piece from the intake.static IntakeSimulationOverTheBumperIntake(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, Distance width, Distance lengthExtended, IntakeSimulation.IntakeSide side, int capacity) Creates an Intake Simulation that Extends Out of the Chassis Frame.voidregister()voidregister(SimulatedArena arena) voidClears the game pieces that have been obtained by the intake.intsetGamePiecesCount(int gamePiecesInIntakeCount) Sets the amount of game pieces in the intake.voidTurns the Intake On.voidTurns the Intake Off.Methods inherited from class org.dyn4j.dynamics.BodyFixture
createMass, getDensity, getFriction, getRestitution, getRestitutionVelocity, setDensity, setFriction, setRestitution, setRestitutionVelocity, toStringMethods inherited from class org.dyn4j.collision.Fixture
getFilter, getShape, getUserData, isSensor, setFilter, setSensor, setUserDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.dyn4j.DataContainer
getUserData, setUserData
-
Constructor Details
-
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 collectdriveTrainSimulation- the chassis to which this intake is attachedshape- the shape of the intake when fully extended, represented as aConvexobjectcapacity- the maximum number of game pieces that the intake can hold
-
-
Method Details
-
InTheFrameIntake
public static IntakeSimulation InTheFrameIntake(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, Distance width, IntakeSimulation.IntakeSide side, int capacity) Creates an Intake Simulation that Tightly Attaches to One Side of the Chassis.
This typically represents an In-The-Frame (ITF) Intake.
- Parameters:
targetedGamePieceType- the type of game pieces that this intake can collectdriveTrainSimulation- the chassis to which this intake is attachedwidth- the width of the intakeside- the side of the chassis where the intake is attachedcapacity- the maximum number of game pieces that the intake can hold
-
OverTheBumperIntake
public static IntakeSimulation OverTheBumperIntake(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, Distance width, Distance lengthExtended, IntakeSimulation.IntakeSide side, int capacity) Creates an Intake Simulation that Extends Out of the Chassis Frame.
This typically represents an Over-The-Bumper (OTB) Intake.
- Parameters:
targetedGamePieceType- the type of game pieces that this intake can collectdriveTrainSimulation- the chassis to which this intake is attachedwidth- the valid width of the intakelengthExtended- the length the intake extends out from the chassis when activatedside- the side of the chassis where the intake is attachedcapacity- the maximum number of game pieces that the intake can hold- Returns:
- a new instance of
IntakeSimulationthat extends over the bumper
-
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
GamePieceOnFieldSimulationinstances, 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
GamePieceOnFieldSimulationinstances. -
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.
- Returns:
- if there is game piece(s) remaining, and therefore retrieved
-
addGamePieceToIntake
public boolean addGamePieceToIntake()Adds 1 game piece from the intake.
Increases the
getGamePiecesAmount()} by 1, if there is still space.- Returns:
- if there is still space in the intake to perform this action
-
setGamePiecesCount
public int setGamePiecesCount(int gamePiecesInIntakeCount) Sets the amount of game pieces in the intake.
Sets the
getGamePiecesAmount()} to a given amount.Will make sure that the amount is non-negative and does not exceed the capacity
- Returns:
- the actual (clamped) game piece count after performing this action
-
getGamePieceContactListener
Obtains a New Instance of the
IntakeSimulation.GamePieceContactListenerfor This Intake.- Returns:
- a new
IntakeSimulation.GamePieceContactListenerfor this intake
-
removeObtainedGamePieces
Clears the game pieces that have been obtained by the intake.
This method is called from
SimulatedArena.simulationPeriodic()to remove theGamePieceOnFieldSimulationinstances that have been obtained by the intake from the field.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. -
register
public void register() -
register
-