JSim 2026.06.01-p(1)
Loading...
Searching...
No Matches
jsim.api.StateManager Class Reference

Public Member Functions

synchronized void reset ()
void initializeField (FieldConfig config)
synchronized List< FieldElementgetFieldElements ()
SimRobot initializeRobot (RobotID id, Pose2d startingPose, Translation2d[] frameVertices)
synchronized SimRobot getRobot (RobotID id)
Map< RobotID, Pose2d > getRobotPoses ()
synchronized void setPhysicsWorld (PhysicsWorld physicsWorld)
synchronized PhysicsWorld getPhysicsWorld ()
synchronized void setRobotBody (RobotID id, PhysicsBody robotBody)
synchronized PhysicsBody getRobotBody (RobotID id)
synchronized void setPhysicsVelocity (RobotID id, ChassisSpeeds speeds)
synchronized void registerGamepieceZone (GamepieceZone gamepieceZone)
synchronized void stepPhysics ()

Static Public Member Functions

static StateManager getInstance ()

Detailed Description

System Rules:

  • Single source of truth for all simulation state.
  • Only system allowed to mutate FieldState<T>.
  • External APIs are read/write proxies ONLY through defined methods.

Member Function Documentation

◆ getFieldElements()

synchronized List< FieldElement > jsim.api.StateManager.getFieldElements ( )
inline

Returns an immutable view of the current field elements registered in the simulation.

Returns
unmodifiable list of field elements

◆ getInstance()

StateManager jsim.api.StateManager.getInstance ( )
inlinestatic

Gets the singleton instance of the StateManager.

Returns
the StateManager instance.

◆ getPhysicsWorld()

synchronized PhysicsWorld jsim.api.StateManager.getPhysicsWorld ( )
inline

Returns the active physics world used by the simulation layer.

Returns
the current physics world, or null if none is registered

◆ getRobot()

synchronized SimRobot jsim.api.StateManager.getRobot ( RobotID id)
inline

Returns the simulated robot registered for the given driver-station id.

Parameters
idthe robot identifier
Returns
the registered robot, or null if none exists

◆ getRobotBody()

synchronized PhysicsBody jsim.api.StateManager.getRobotBody ( RobotID id)
inline

Returns the physics body associated with the given robot id.

Parameters
idthe robot identifier
Returns
the tracked physics body, or null if none exists

◆ getRobotPoses()

Map< RobotID, Pose2d > jsim.api.StateManager.getRobotPoses ( )
inline

Returns a snapshot of all registered robot poses keyed by robot id.

Returns
immutable map of robot ids to poses

◆ initializeField()

void jsim.api.StateManager.initializeField ( FieldConfig config)
inline

Loads JSON field definition and builds all FieldElements and collision zones.

Parameters
configThe field configuration to initialize.

◆ initializeRobot()

SimRobot jsim.api.StateManager.initializeRobot ( RobotID id,
Pose2d startingPose,
Translation2d[] frameVertices )
inline

Creates a robot instance, assigns starting pose, and registers it in the simulation.

Parameters
idThe RobotID for the robot.
startingPoseThe initial pose of the robot.
frameVerticesThe vertices of the robot's frame.
Returns
the initialized SimRobot instance.

◆ registerGamepieceZone()

synchronized void jsim.api.StateManager.registerGamepieceZone ( GamepieceZone gamepieceZone)
inline

Registers a gamepiece zone to be refreshed on each simulation step.

Parameters
gamepieceZonethe zone to register

◆ reset()

synchronized void jsim.api.StateManager.reset ( )
inline

Clears all tracked simulation state and detaches the active physics world.

Primarily used by tests to ensure deterministic, isolated state between runs.

◆ setPhysicsVelocity()

synchronized void jsim.api.StateManager.setPhysicsVelocity ( RobotID id,
ChassisSpeeds speeds )
inline

Applies a chassis-speed command to the physics body registered for the given robot id.

Parameters
idthe robot identifier
speedsthe commanded chassis speeds

◆ setPhysicsWorld()

synchronized void jsim.api.StateManager.setPhysicsWorld ( PhysicsWorld physicsWorld)
inline

Stores the active physics world used by the simulation layer.

Parameters
physicsWorldthe physics world to store

◆ setRobotBody()

synchronized void jsim.api.StateManager.setRobotBody ( RobotID id,
PhysicsBody robotBody )
inline

Associates a native physics body with a robot id.

Parameters
idthe robot identifier
robotBodythe physics body to store, or null to clear the mapping

◆ stepPhysics()

synchronized void jsim.api.StateManager.stepPhysics ( )
inline

Advances the tracked physics world and refreshes gamepiece zones.


The documentation for this class was generated from the following file: