|
JSim 2026.06.01-p(1)
|
Resolves robot-ball contact response. projectiles. More...
#include <ball_gamepiece_sim.hpp>
Classes | |
| struct | FieldConfig |
| Global field and contact tuning parameters. More... | |
| struct | RobotState |
| Per-robot state used by game piece interaction and collision routines. More... | |
| struct | ExitTrajectoryParameters |
| Exit trajectory and metadata used when launching a carried ball or a projectile. More... | |
| struct | GamePieceInfo |
| Registration record for a named game piece type. More... | |
| struct | ProjectileEntity |
| In-flight entity not currently represented by BallPhysicsSim3D. More... | |
| struct | GoalZone |
| Goal capture region and validation logic. More... | |
| struct | BallEntity |
| Grounded game piece entity with its own ball physics instance. More... | |
Public Types | |
| enum class | GamePieceType { kBall , kFuel2026 , kCustom1 , kCustom2 , kCustom3 , kCustom4 } |
| using | FireCommand = ExitTrajectoryParameters |
| Backward-compatible alias for older call sites. | |
| using | RobotAddedCallback |
| Callback type invoked when a robot is added to this simulator. | |
Public Member Functions | |
| BallGamepieceSim ()=default | |
| Constructs a simulator with default evergreen field bounds and contact tuning. | |
| BallGamepieceSim (const FieldConfig &field) | |
| Constructs a simulator with the provided field configuration. | |
| void | setFieldConfig (const FieldConfig &field) |
| Replaces field configuration while preserving dynamic simulation entities. | |
| std::size_t | addRobot (const RobotState &robot) |
| Adds a robot and returns its index. | |
| void | setRobotAddedCallback (const RobotAddedCallback &callback) |
| Sets a callback invoked whenever addRobot inserts a robot. | |
| std::size_t | addBall (const BallPhysicsSim3D::BallState &state, const BallPhysicsSim3D::Config &config, const BallPhysicsSim3D::BallProperties &properties) |
| Adds a grounded ball with explicit physics configuration. | |
| std::size_t | addProjectile (const ProjectileEntity &projectile) |
| Adds a projectile entity and returns its index. | |
| GoalZone & | addGoalZone (const GoalZone &goal_zone) |
| Adds a goal zone and returns a mutable reference to the stored copy. | |
| GamePieceInfo & | registerGamePieceType (const GamePieceInfo &info) |
| Registers or replaces a named game piece type. | |
| void | clearGamePieceTypes () |
| Clears all registered game piece type definitions. | |
| EnvironmentalBoundary & | addFieldElement (const EnvironmentalBoundary &boundary) |
| Adds a field element and returns a mutable reference to the stored copy. | |
| std::vector< RobotState > & | robots () |
| Mutable robot state list. | |
| const std::vector< RobotState > & | robots () const |
| Immutable robot state list. | |
| std::vector< BallEntity > & | balls () |
| Mutable grounded-ball list. | |
| const std::vector< BallEntity > & | balls () const |
| Immutable grounded-ball list. | |
| std::vector< BallEntity > & | gamepieces () |
| const std::vector< BallEntity > & | gamepieces () const |
| GamePieceType | gamepieceType (std::size_t idx) const |
| std::string | gamepieceTypeName (std::size_t idx) const |
| bool | setGamepieceType (std::size_t idx, GamePieceType t) |
| bool | setGamepieceType (std::size_t idx, const std::string &n) |
| bool | removeGamepiece (std::size_t idx) |
| std::size_t | countGamepieces () const |
| GamePieceType | ballType (std::size_t ball_index) const |
| Returns the registered type for a ball index. | |
| std::string | ballTypeName (std::size_t ball_index) const |
| Returns the registered type label for a ball index, or empty string if out of range. | |
| bool | setBallType (std::size_t ball_index, GamePieceType type) |
| Updates the type for an existing ball. | |
| bool | setBallType (std::size_t ball_index, const std::string &type_name) |
| Backward-compatible setter that accepts a type name. | |
| bool | removeBall (std::size_t ball_index) |
| Removes a ball by index and remaps carried-ball indices accordingly. | |
| std::vector< ProjectileEntity > & | projectiles () |
| Mutable projectile list. | |
| const std::vector< ProjectileEntity > & | projectiles () const |
| Immutable projectile list. | |
| std::vector< GoalZone > & | goals () |
| Mutable goal-zone list. | |
| const std::vector< GoalZone > & | goals () const |
| Immutable goal-zone list. | |
| std::vector< EnvironmentalBoundary > & | fieldElements () |
| Mutable field-element list. | |
| const std::vector< EnvironmentalBoundary > & | fieldElements () const |
| Immutable field-element list. | |
| std::size_t | countBalls () const |
| Returns total grounded ball count (including scored-in-net balls). | |
| std::size_t | countProjectiles () const |
| Returns count of currently active projectiles. | |
| std::size_t | countScoredBalls () const |
| Returns count of grounded balls marked as scored in configured net volume(s). | |
| std::size_t | fireProjectile (std::size_t robot_index, const ExitTrajectoryParameters &command, bool spawn_on_ground_after_touch=true, const std::function< void()> &hit_target_callback={}) |
| Spawns a projectile using robot pose and exit trajectory parameters. | |
| void | step (double dt_s) |
| Advances simulation by dt using configured internal substep count. | |
| void | setSimulationSubsteps (int simulation_substeps) |
| Sets simulation substeps per external step; values below 1 clamp to 1. | |
| int | simulationSubsteps () const |
| Returns current simulation substeps-per-step value. | |
Static Public Attributes | |
| static constexpr std::size_t | kNoBall = static_cast<std::size_t>(-1) |
| static constexpr std::size_t | kNoGamepiece = kNoBall |
Resolves robot-ball contact response. projectiles.
Seasonal field/gamepiece presets are intentionally defined outside this class so this simulator remains reusable for custom games and offseason field variants.
Backward-compatible alias for older call sites.
Callback type invoked when a robot is added to this simulator.
|
strong |
|
default |
Constructs a simulator with default evergreen field bounds and contact tuning.
|
inlineexplicit |
Constructs a simulator with the provided field configuration.
| field | Initial field configuration. |
|
inline |
|
inline |
Adds a field element and returns a mutable reference to the stored copy.
| boundary | Boundary to append. |
Adds a goal zone and returns a mutable reference to the stored copy.
| goal_zone | Goal zone definition to append. |
|
inline |
Adds a projectile entity and returns its index.
| projectile | Projectile to append. |
|
inline |
Adds a robot and returns its index.
| robot | Robot state to insert. |
|
inline |
Mutable grounded-ball list.
|
inline |
Immutable grounded-ball list.
|
inline |
Returns the registered type for a ball index.
| ball_index | Ball index to query. |
|
inline |
Returns the registered type label for a ball index, or empty string if out of range.
|
inline |
Clears all registered game piece type definitions.
|
inline |
Returns total grounded ball count (including scored-in-net balls).
|
inline |
Returns total grounded gamepiece count.
|
inline |
Returns count of currently active projectiles.
|
inline |
Returns count of grounded balls marked as scored in configured net volume(s).
|
inline |
Mutable field-element list.
|
inline |
Immutable field-element list.
|
inline |
Spawns a projectile using robot pose and exit trajectory parameters.
| robot_index | Robot index used as launch source. |
| command | Launch parameters. |
| spawn_on_ground_after_touch | If true, touchdown spawns a grounded ball. |
| hit_target_callback | Callback fired on goal hit. |
|
inline |
Backwards-compatible gamepiece aliases to aid migration. Mutable gamepiece list.
|
inline |
Immutable gamepiece list.
|
inline |
Returns the registered type for a gamepiece index.
|
inline |
Returns the registered type label for a gamepiece index.
|
inline |
Mutable goal-zone list.
|
inline |
Immutable goal-zone list.
|
inline |
Mutable projectile list.
|
inline |
Immutable projectile list.
|
inline |
Registers or replaces a named game piece type.
| info | Type definition to insert or overwrite. |
|
inline |
Removes a ball by index and remaps carried-ball indices accordingly.
| ball_index | Ball index to remove. |
|
inline |
Removes a gamepiece by index.
|
inline |
Mutable robot state list.
|
inline |
Immutable robot state list.
|
inline |
Backward-compatible setter that accepts a type name.
| ball_index | Ball index to modify. |
| type_name | Type label ("Ball" supported). |
|
inline |
Updates the type for an existing ball.
| ball_index | Ball index to modify. |
| type | Replacement type. |
|
inline |
Replaces field configuration while preserving dynamic simulation entities.
| field | New field configuration. |
|
inline |
Backward-compatible setter that accepts a type name for a gamepiece.
|
inline |
Updates the type for an existing gamepiece.
|
inline |
Sets a callback invoked whenever addRobot inserts a robot.
| callback | Callback invoked after insertion. |
|
inline |
Sets simulation substeps per external step; values below 1 clamp to 1.
| simulation_substeps | Requested substep count. |
|
inline |
Returns current simulation substeps-per-step value.
|
inline |
Advances simulation by dt using configured internal substep count.
| dt_s | External timestep in seconds. |
|
staticconstexpr |
Sentinel index representing no carried ball.
|
staticconstexpr |
Sentinel index representing no carried gamepiece.