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
GamePieceOnFieldSimulation
is 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
Modifier and TypeClassDescriptionfinal class
TheContactListener
for 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, restitutionVelocity
Fields inherited from class org.dyn4j.collision.Fixture
filter, sensor, shape, userData
-
Constructor Summary
ConstructorDescriptionIntakeSimulation
(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.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.IntakeSimulation
(String targetedGamePieceType, AbstractDriveTrainSimulation driveTrainSimulation, org.dyn4j.geometry.Convex shape, int capacity) Creates an Intake Simulation with a Specific Shape. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the Game Pieces Marked for Removal.Obtains a New Instance of theIntakeSimulation.GamePieceContactListener
for This Intake.int
Get the amount of game pieces in the intake.Obtains theGamePieceOnFieldSimulation
Instances to Be Removed from the Field.boolean
Removes 1 game piece from the intake.void
register()
void
register
(SimulatedArena arena) void
Turns the Intake On.void
Turns the Intake Off.Methods inherited from class org.dyn4j.dynamics.BodyFixture
createMass, getDensity, getFriction, getRestitution, getRestitutionVelocity, setDensity, setFriction, setRestitution, setRestitutionVelocity, toString
Methods inherited from class org.dyn4j.collision.Fixture
getFilter, getShape, getUserData, isSensor, setFilter, setSensor, setUserData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.dyn4j.DataContainer
getUserData, setUserData
-
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 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
-
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 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
-
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 aConvex
objectcapacity
- 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
Obtains a New Instance of the
IntakeSimulation.GamePieceContactListener
for This Intake.- Returns:
- a new
IntakeSimulation.GamePieceContactListener
for this intake
-
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
-