JSim 2026.06.01-p(1)
Loading...
Searching...
No Matches
frcsim::TurretFlywheelSim Class Reference

Integrated turret + flywheel + carried-ball simulator for aiming, pickup, and firing flows. More...

#include <turret_shooter_sim.hpp>

Classes

struct  Config
 Configuration for differential kinematics, ball model, and local mount geometry. More...

Public Member Functions

 TurretFlywheelSim ()=default
 TurretFlywheelSim (const Config &config)
 Constructs simulator from explicit configuration.
const Configconfig () const
 Returns current simulator configuration.
void setTurretMountPosition (const Vector3 &mount_position_m)
 Updates turret mount origin in world frame.
void setBaseVelocity (const Vector3 &base_velocity_mps)
 Sets base/chassis linear velocity used during carry and shot composition.
void setMotorState (const DoubleDifferentialMechanism::MotorState &motor_state)
 Sets differential motor state directly.
const DoubleDifferentialMechanism::MotorStatemotorState () const
 Returns current differential motor state.
DoubleDifferentialMechanism::InverseResult solveMotorStateForAim (double yaw_rad, double pitch_rad, double yaw_velocity_radps=0.0, double pitch_velocity_radps=0.0) const
 Solves inverse differential mapping for desired aim state.
bool applyAim (double yaw_rad, double pitch_rad, double yaw_velocity_radps=0.0, double pitch_velocity_radps=0.0)
 Applies desired aim by solving and storing motor state.
DoubleDifferentialMechanism::JointState jointState () const
 Computes current turret joint state from motor state.
Vector3 muzzlePositionWorld () const
 Computes current muzzle origin in world coordinates.
Vector3 intakePositionWorld () const
 Computes current intake center position in world coordinates.
Vector3 muzzleDirectionWorld () const
 Computes the muzzle forward firing direction in world frame.
bool pickupBallNearby ()
 Attempts to pick up the internal ball if near intake location.
void shoot (double muzzle_speed_mps, const Vector3 &spin_radps=Vector3::zero())
 Fires the ball using an explicit muzzle speed.
void shootWithWheel (const FlywheelWheelSim &wheel, const Vector3 &spin_radps=Vector3::zero())
 Fires the ball using wheel-estimated exit velocity.
void step (double dt_s)
 Advances carry/ball simulation one step.
BallPhysicsSim3Dball ()
 Mutable access to internal ball simulator.
const BallPhysicsSim3Dball () const
 Immutable access to internal ball simulator.

Detailed Description

Integrated turret + flywheel + carried-ball simulator for aiming, pickup, and firing flows.

Constructor & Destructor Documentation

◆ TurretFlywheelSim() [1/2]

frcsim::TurretFlywheelSim::TurretFlywheelSim ( )
default

◆ TurretFlywheelSim() [2/2]

frcsim::TurretFlywheelSim::TurretFlywheelSim ( const Config & config)
inlineexplicit

Constructs simulator from explicit configuration.

Parameters
configInitial turret/flywheel/ball configuration.

Member Function Documentation

◆ applyAim()

bool frcsim::TurretFlywheelSim::applyAim ( double yaw_rad,
double pitch_rad,
double yaw_velocity_radps = 0.0,
double pitch_velocity_radps = 0.0 )
inline

Applies desired aim by solving and storing motor state.

Parameters
yaw_radDesired yaw angle in radians.
pitch_radDesired pitch angle in radians.
yaw_velocity_radpsDesired yaw rate in rad/s.
pitch_velocity_radpsDesired pitch rate in rad/s.
Returns
True when inverse solve succeeded.

◆ ball() [1/2]

BallPhysicsSim3D & frcsim::TurretFlywheelSim::ball ( )
inline

Mutable access to internal ball simulator.

◆ ball() [2/2]

const BallPhysicsSim3D & frcsim::TurretFlywheelSim::ball ( ) const
inline

Immutable access to internal ball simulator.

◆ config()

const Config & frcsim::TurretFlywheelSim::config ( ) const
inline

Returns current simulator configuration.

Returns
Immutable config reference.

◆ intakePositionWorld()

Vector3 frcsim::TurretFlywheelSim::intakePositionWorld ( ) const
inline

Computes current intake center position in world coordinates.

Returns
World position of the intake center in meters.

◆ jointState()

DoubleDifferentialMechanism::JointState frcsim::TurretFlywheelSim::jointState ( ) const
inline

Computes current turret joint state from motor state.

Returns
JointState with yaw/pitch and rates.

◆ motorState()

const DoubleDifferentialMechanism::MotorState & frcsim::TurretFlywheelSim::motorState ( ) const
inline

Returns current differential motor state.

Returns
Immutable motor state reference.

◆ muzzleDirectionWorld()

Vector3 frcsim::TurretFlywheelSim::muzzleDirectionWorld ( ) const
inline

Computes the muzzle forward firing direction in world frame.

Returns
Normalized unit direction vector for projectile launch.

◆ muzzlePositionWorld()

Vector3 frcsim::TurretFlywheelSim::muzzlePositionWorld ( ) const
inline

Computes current muzzle origin in world coordinates.

Returns
World position of the muzzle in meters.

◆ pickupBallNearby()

bool frcsim::TurretFlywheelSim::pickupBallNearby ( )
inline

Attempts to pick up the internal ball if near intake location.

Returns
True if pickup succeeds.

◆ setBaseVelocity()

void frcsim::TurretFlywheelSim::setBaseVelocity ( const Vector3 & base_velocity_mps)
inline

Sets base/chassis linear velocity used during carry and shot composition.

Parameters
base_velocity_mpsWorld velocity.

◆ setMotorState()

void frcsim::TurretFlywheelSim::setMotorState ( const DoubleDifferentialMechanism::MotorState & motor_state)
inline

Sets differential motor state directly.

Parameters
motor_stateMotor positions/velocities.

◆ setTurretMountPosition()

void frcsim::TurretFlywheelSim::setTurretMountPosition ( const Vector3 & mount_position_m)
inline

Updates turret mount origin in world frame.

Parameters
mount_position_mMount position in meters.

◆ shoot()

void frcsim::TurretFlywheelSim::shoot ( double muzzle_speed_mps,
const Vector3 & spin_radps = Vector3::zero() )
inline

Fires the ball using an explicit muzzle speed.

Parameters
muzzle_speed_mpsLaunch speed in m/s.
spin_radpsLaunch spin vector in rad/s.

◆ shootWithWheel()

void frcsim::TurretFlywheelSim::shootWithWheel ( const FlywheelWheelSim & wheel,
const Vector3 & spin_radps = Vector3::zero() )
inline

Fires the ball using wheel-estimated exit velocity.

Parameters
wheelFlywheel wheel model used for speed estimate.
spin_radpsLaunch spin vector in rad/s.

◆ solveMotorStateForAim()

DoubleDifferentialMechanism::InverseResult frcsim::TurretFlywheelSim::solveMotorStateForAim ( double yaw_rad,
double pitch_rad,
double yaw_velocity_radps = 0.0,
double pitch_velocity_radps = 0.0 ) const
inline

Solves inverse differential mapping for desired aim state.

Parameters
yaw_radDesired yaw angle in radians.
pitch_radDesired pitch angle in radians.
yaw_velocity_radpsDesired yaw rate in rad/s.
pitch_velocity_radpsDesired pitch rate in rad/s.
Returns
InverseResult containing motor command and validity flag.

◆ step()

void frcsim::TurretFlywheelSim::step ( double dt_s)
inline

Advances carry/ball simulation one step.

Parameters
dt_sTimestep in seconds.

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