Package jsim.field
Class GamePieceGripper
java.lang.Object
jsim.field.GamePieceGripper
Attaches a
GamePiece to a robot body's intake point so it is carried
rigidly in robot-local space each tick.
While a game piece is held, its pose and linear velocity are overridden each
tick (by update()) to track the robot. The piece's physics body is not
removed from the world — it just gets corrected immediately after every physics
step so it always appears at the intake position.
Obtain instances from FieldSimulator.createGripper(jsim.api.SimBody, edu.wpi.first.math.geometry.Translation3d). update()
is called automatically by FieldSimulator.step(), so manual calls are
only needed when using the gripper with a raw SimWorld.
Example:
GamePieceGripper gripper = sim.createGripper(robot, new Translation3d(0.45, 0, 0.1));
// Robot drives up to a game piece and intakes it
gripper.grab(gamePiece);
// ... robot drives to the speaker, then shoots ...
gripper.eject(0, 0, 8); launch straight up at 8 m/s
-
Method Summary
-
Method Details
-
grab
Attach a game piece to this gripper. The piece is immediately snapped to the intake position and its velocity is matched to the robot's.Returns
false(no-op) if:- this gripper is already holding a piece, or
pieceis already held by another gripper.
- Parameters:
piece- the game piece to grab- Returns:
trueif the grab succeeded
-
release
public void release()Release the held piece, giving it the robot's current linear velocity. No-op if nothing is held. -
eject
public void eject(double vx, double vy, double vz) Eject the held piece with a custom world-frame velocity. Use this to model a shooter or roller that launches the piece at a specific velocity. No-op if nothing is held.- Parameters:
vx- ejection velocity X component (m/s)vy- ejection velocity Y component (m/s)vz- ejection velocity Z component (m/s)
-
getHeld
- Returns:
- the currently held game piece, or
nullif nothing is held
-
isHolding
public boolean isHolding()- Returns:
trueif this gripper is currently holding a piece
-