Class GamePieceOnFieldSimulation

java.lang.Object
org.dyn4j.collision.AbstractCollisionBody<org.dyn4j.dynamics.BodyFixture>
org.dyn4j.dynamics.AbstractPhysicsBody
org.dyn4j.dynamics.Body
org.ironmaple.simulation.gamepieces.GamePieceOnFieldSimulation
All Implemented Interfaces:
org.dyn4j.collision.CollisionBody<org.dyn4j.dynamics.BodyFixture>, org.dyn4j.DataContainer, org.dyn4j.dynamics.PhysicsBody, org.dyn4j.geometry.Rotatable, org.dyn4j.geometry.Shiftable, org.dyn4j.geometry.Transformable, org.dyn4j.geometry.Translatable, org.dyn4j.Ownable, GamePiece
Direct Known Subclasses:
CrescendoNoteOnField, RebuiltFuelOnField, ReefscapeAlgaeOnField, ReefscapeCoralAlgaeStack, ReefscapeCoralOnField

public class GamePieceOnFieldSimulation extends org.dyn4j.dynamics.Body implements GamePiece

Simulates a Game Piece on the Field.

This class simulates a game piece on the field, which has a collision space and interacts with other objects.

Game pieces can be "grabbed" by an IntakeSimulation.

For the simulation to actually run, every instance must be added to a SimulatedArena through SimulatedArena.addGamePiece(GamePieceOnFieldSimulation).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Stores the info of a type of game piece
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     
    static final double
     
    final String
    The Type of the Game Piece.

    Fields inherited from class org.dyn4j.dynamics.AbstractPhysicsBody

    angularDamping, angularVelocity, atRest, atRestDetectionEnabled, atRestTime, bullet, force, forces, gravityScale, linearDamping, linearVelocity, mass, torque, torques

    Fields inherited from class org.dyn4j.collision.AbstractCollisionBody

    enabled, fixtureModificationHandler, fixtures, fixturesUnmodifiable, owner, radius, transform, transform0, userData

    Fields inherited from interface org.dyn4j.collision.CollisionBody

    TYPICAL_FIXTURE_COUNT

    Fields inherited from interface org.dyn4j.dynamics.PhysicsBody

    DEFAULT_ANGULAR_DAMPING, DEFAULT_LINEAR_DAMPING
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a Game Piece on the Field with Fixed Height.
    GamePieceOnFieldSimulation(GamePieceOnFieldSimulation.GamePieceInfo info, DoubleSupplier zPositionSupplier, Pose2d initialPose, Translation2d initialVelocityMPS)
    Creates a Game Piece on the Field with Custom Height Supplier and Initial Velocity.
  • Method Summary

    Modifier and Type
    Method
    Description
    Obtains a 3d pose of the game piece.
    Obtains the 2d position of the game piece
    Gives the string type of the current game piece.
    Gives the velocity of the game piece.
    boolean
    Gives wether or not the piece is "grounded".
    void
    onIntake(String intakeTargetGamePieceType)
     
    void
    setVelocity(ChassisSpeeds chassisSpeedsWorldFrame)
    Sets the world velocity of this game piece.
    void
    Internal function called to trigger a callback whenever this game piece is scored in a goal

    Methods inherited from class org.dyn4j.dynamics.AbstractPhysicsBody

    accumulate, addFixture, addFixture, addFixture, applyForce, applyForce, applyForce, applyImpulse, applyImpulse, applyImpulse, applyTorque, applyTorque, clearAccumulatedForce, clearAccumulatedTorque, clearForce, clearTorque, computeSweptAABB, computeSweptAABB, createSweptAABB, createSweptAABB, getAccumulatedForce, getAccumulatedTorque, getAngularDamping, getAngularVelocity, getChangeInOrientation, getChangeInPosition, getForce, getGravityScale, getLinearDamping, getLinearVelocity, getLinearVelocity, getLocalCenter, getMass, getTorque, getWorldCenter, integratePosition, integrateVelocity, isAtRest, isAtRestDetectionEnabled, isBullet, isDynamic, isKinematic, isStatic, removeAllFixtures, removeFixture, removeFixture, removeFixture, removeFixtures, setAngularDamping, setAngularVelocity, setAtRest, setAtRestDetectionEnabled, setBullet, setEnabled, setGravityScale, setLinearDamping, setLinearVelocity, setLinearVelocity, setMass, setMass, setMassType, toString, updateAtRestTime, updateMass

    Methods inherited from class org.dyn4j.collision.AbstractCollisionBody

    addFixture, computeAABB, computeAABB, contains, containsFixture, createAABB, createAABB, getFixture, getFixture, getFixtureCount, getFixtureIterator, getFixtureModificationHandler, getFixtures, getFixtures, getLocalPoint, getLocalVector, getOwner, getPreviousTransform, getRotationDiscRadius, getTransform, getUserData, getWorldPoint, getWorldVector, isEnabled, rotate, rotate, rotate, rotate, rotate, rotate, rotateAboutCenter, setFixtureModificationHandler, setOwner, setRotationDiscRadius, setTransform, setUserData, shift, translate, translate, translateToOrigin

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.dyn4j.collision.CollisionBody

    addFixture, addFixture, computeAABB, computeAABB, contains, containsFixture, createAABB, createAABB, getFixture, getFixture, getFixtureCount, getFixtureIterator, getFixtureModificationHandler, getFixtures, getFixtures, getLocalCenter, getLocalPoint, getLocalVector, getPreviousTransform, getRotationDiscRadius, getTransform, getWorldCenter, getWorldPoint, getWorldVector, isEnabled, removeAllFixtures, removeFixture, removeFixture, removeFixture, removeFixtures, rotateAboutCenter, setEnabled, setFixtureModificationHandler, setTransform, translateToOrigin

    Methods inherited from interface org.dyn4j.DataContainer

    getUserData, setUserData

    Methods inherited from interface org.dyn4j.Ownable

    getOwner, setOwner

    Methods inherited from interface org.dyn4j.dynamics.PhysicsBody

    addFixture, addFixture, applyForce, applyForce, applyForce, applyImpulse, applyImpulse, applyImpulse, applyTorque, applyTorque, clearAccumulatedForce, clearAccumulatedTorque, clearForce, clearTorque, computeSweptAABB, computeSweptAABB, createSweptAABB, createSweptAABB, getAccumulatedForce, getAccumulatedTorque, getAngularDamping, getAngularVelocity, getChangeInOrientation, getChangeInPosition, getForce, getGravityScale, getLinearDamping, getLinearVelocity, getLinearVelocity, getMass, getTorque, integratePosition, integrateVelocity, isAtRest, isAtRestDetectionEnabled, isBullet, isDynamic, isKinematic, isStatic, setAngularDamping, setAngularVelocity, setAtRest, setAtRestDetectionEnabled, setBullet, setGravityScale, setLinearDamping, setLinearVelocity, setLinearVelocity, setMass, setMass, setMassType, updateAtRestTime, updateMass

    Methods inherited from interface org.dyn4j.geometry.Rotatable

    rotate, rotate, rotate, rotate, rotate, rotate

    Methods inherited from interface org.dyn4j.geometry.Shiftable

    shift

    Methods inherited from interface org.dyn4j.geometry.Translatable

    translate, translate
  • Field Details

  • Constructor Details

    • GamePieceOnFieldSimulation

      public GamePieceOnFieldSimulation(GamePieceOnFieldSimulation.GamePieceInfo info, Pose2d initialPose)

      Creates a Game Piece on the Field with Fixed Height.

      Parameters:
      info - info about the game piece type
      initialPose - the initial position of the game piece on the field
    • GamePieceOnFieldSimulation

      public GamePieceOnFieldSimulation(GamePieceOnFieldSimulation.GamePieceInfo info, DoubleSupplier zPositionSupplier, Pose2d initialPose, Translation2d initialVelocityMPS)

      Creates a Game Piece on the Field with Custom Height Supplier and Initial Velocity.

      Parameters:
      info - info about the game piece type
      zPositionSupplier - a supplier that provides the current Z-height of the game piece
      initialPose - the initial position of the game piece on the field
      initialVelocityMPS - the initial velocity of the game piece, in meters per second
  • Method Details

    • setVelocity

      public void setVelocity(ChassisSpeeds chassisSpeedsWorldFrame)

      Sets the world velocity of this game piece.

      Parameters:
      chassisSpeedsWorldFrame - the speeds of the game piece
    • getPoseOnField

      public Pose2d getPoseOnField()

      Obtains the 2d position of the game piece

      Returns:
      the 2d position of the game piece
    • getPose3d

      public Pose3d getPose3d()

      Obtains a 3d pose of the game piece.

      The 3d position is calculated from both the getPoseOnField() and zPositionSupplier

      Specified by:
      getPose3d in interface GamePiece
      Returns:
      the 3d position of the game piece
    • onIntake

      public void onIntake(String intakeTargetGamePieceType)
    • getType

      public String getType()
      Description copied from interface: GamePiece

      Gives the string type of the current game piece.

      Specified by:
      getType in interface GamePiece
      Returns:
      The game piece string type (ex "Coral", "Algae", "Note").
    • getVelocity3dMPS

      public Translation3d getVelocity3dMPS()
      Description copied from interface: GamePiece

      Gives the velocity of the game piece.

      For grounded game pieces the z access velocity does not exist and so will be set to 0 automatically.
      Specified by:
      getVelocity3dMPS in interface GamePiece
      Returns:
      The velocity of the game piece as a Translation3d.
    • isGrounded

      public boolean isGrounded()
      Description copied from interface: GamePiece

      Gives wether or not the piece is "grounded".

      A grounded piece is likely a child of GamePieceOnFieldSimulation while a non grounded piece is likely a child ofGamePieceProjectile.
      Specified by:
      isGrounded in interface GamePiece
      Returns:
      wether or not the piece is grounded.
    • triggerHitTargeCallBack

      public void triggerHitTargeCallBack()
      Description copied from interface: GamePiece

      Internal function called to trigger a callback whenever this game piece is scored in a goal

      Specified by:
      triggerHitTargeCallBack in interface GamePiece