13#include "frcsim/mechanisms/flywheel_wheel.hpp"
53 differential_(
config.differential),
63 config_.turret_mount_position_m = mount_position_m;
69 base_velocity_mps_ = base_velocity_mps;
76 motor_state_ = motor_state;
94 double yaw_rad,
double pitch_rad,
double yaw_velocity_radps = 0.0,
95 double pitch_velocity_radps = 0.0)
const {
101 return differential_.inverse(desired);
113 double yaw_velocity_radps = 0.0,
114 double pitch_velocity_radps = 0.0) {
116 yaw_rad, pitch_rad, yaw_velocity_radps, pitch_velocity_radps);
120 motor_state_ = solved.motor_state;
127 return differential_.forward(motor_state_);
135 return config_.turret_mount_position_m +
136 turretOrientationWorld().rotate(config_.muzzle_offset_local_m);
144 return config_.turret_mount_position_m +
145 turretOrientationWorld().rotate(config_.intake_offset_local_m);
163 turretOrientationWorld().rotate(config_.carry_offset_local_m);
164 return ball_.requestPickup(request);
178 ball_.shoot(muzzle_position, shot_velocity, spin_radps);
197 ball_.setCarrierPose(carry_position, base_velocity_mps_);
217 DoubleDifferentialMechanism differential_{};
218 DoubleDifferentialMechanism::MotorState motor_state_{};
220 Vector3 base_velocity_mps_{};
221 BallPhysicsSim3D ball_{};
3D rigid-body style ball simulator with drag, Magnus lift, and ground contact.
Definition ball_physics.hpp:22
Single-wheel flywheel velocity model with optional closed-loop speed command behavior.
Definition shooter_wheel.hpp:14
double estimatedExitVelocityMps() const
Estimates ball exit speed from current surface speed and coupling factor.
Definition shooter_wheel.hpp:142
DoubleDifferentialMechanism::JointState jointState() const
Computes current turret joint state from motor state.
Definition turret_shooter_sim.hpp:126
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.
Definition turret_shooter_sim.hpp:112
void step(double dt_s)
Advances carry/ball simulation one step.
Definition turret_shooter_sim.hpp:195
Vector3 intakePositionWorld() const
Computes current intake center position in world coordinates.
Definition turret_shooter_sim.hpp:143
bool pickupBallNearby()
Attempts to pick up the internal ball if near intake location.
Definition turret_shooter_sim.hpp:158
Vector3 muzzleDirectionWorld() const
Computes the muzzle forward firing direction in world frame.
Definition turret_shooter_sim.hpp:152
TurretFlywheelSim()=default
Vector3 muzzlePositionWorld() const
Computes current muzzle origin in world coordinates.
Definition turret_shooter_sim.hpp:134
void shootWithWheel(const FlywheelWheelSim &wheel, const Vector3 &spin_radps=Vector3::zero())
Fires the ball using wheel-estimated exit velocity.
Definition turret_shooter_sim.hpp:186
BallPhysicsSim3D & ball()
Mutable access to internal ball simulator.
Definition turret_shooter_sim.hpp:202
void setBaseVelocity(const Vector3 &base_velocity_mps)
Sets base/chassis linear velocity used during carry and shot composition.
Definition turret_shooter_sim.hpp:68
const Config & config() const
Returns current simulator configuration.
Definition turret_shooter_sim.hpp:58
void setMotorState(const DoubleDifferentialMechanism::MotorState &motor_state)
Sets differential motor state directly.
Definition turret_shooter_sim.hpp:74
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.
Definition turret_shooter_sim.hpp:93
TurretFlywheelSim(const Config &config)
Constructs simulator from explicit configuration.
Definition turret_shooter_sim.hpp:51
void setTurretMountPosition(const Vector3 &mount_position_m)
Updates turret mount origin in world frame.
Definition turret_shooter_sim.hpp:62
void shoot(double muzzle_speed_mps, const Vector3 &spin_radps=Vector3::zero())
Fires the ball using an explicit muzzle speed.
Definition turret_shooter_sim.hpp:172
const DoubleDifferentialMechanism::MotorState & motorState() const
Returns current differential motor state.
Definition turret_shooter_sim.hpp:81
const BallPhysicsSim3D & ball() const
Immutable access to internal ball simulator.
Definition turret_shooter_sim.hpp:204
Physical parameters for the ball body.
Definition ball_physics.hpp:49
Runtime physics environment parameters.
Definition ball_physics.hpp:25
Request payload used to capture a ball into a carrier.
Definition ball_physics.hpp:78
Vector3 intake_position_m
Definition ball_physics.hpp:80
Vector3 carry_offset_m
Definition ball_physics.hpp:84
double capture_radius_m
Definition ball_physics.hpp:82
Mapping coefficients and inversion thresholds.
Definition double_differential.hpp:31
Result from inverse kinematics solve.
Definition double_differential.hpp:64
Output state for mechanism yaw/pitch joints.
Definition double_differential.hpp:56
double yaw_rad
Definition double_differential.hpp:57
double pitch_velocity_radps
Definition double_differential.hpp:60
double yaw_velocity_radps
Definition double_differential.hpp:59
double pitch_rad
Definition double_differential.hpp:58
Input state for the two drive motors.
Definition double_differential.hpp:48
Unit-quaternion rotation representation and rotation algebra helpers.
Definition quaternion.hpp:25
static Quaternion fromAxisAngle(const Vector3 &axis, double angleRad) noexcept
Definition quaternion.hpp:69
Configuration for differential kinematics, ball model, and local mount geometry.
Definition turret_shooter_sim.hpp:22
double intake_capture_radius_m
Radius around intake center for successful ball pickup (meters).
Definition turret_shooter_sim.hpp:40
Vector3 turret_mount_position_m
Position of the differential pivot in world frame (meters).
Definition turret_shooter_sim.hpp:31
DoubleDifferentialMechanism::Config differential
Double-differential (yaw/pitch) leg kinematics.
Definition turret_shooter_sim.hpp:24
Vector3 carry_offset_local_m
Offset from intake to carried ball rest position in local frame (meters).
Definition turret_shooter_sim.hpp:42
BallPhysicsSim3D::BallProperties ball_properties
Ball mass, radius, drag, and impact properties.
Definition turret_shooter_sim.hpp:28
Vector3 intake_offset_local_m
Intake center offset from the turret rotation origin in local turret frame (meters).
Definition turret_shooter_sim.hpp:37
Vector3 muzzle_offset_local_m
Muzzle origin offset in local turret frame (meters, before yaw/pitch rotation).
Definition turret_shooter_sim.hpp:34
BallPhysicsSim3D::Config ball_config
Ball physics environment and simulation behavior.
Definition turret_shooter_sim.hpp:26
3D vector utility used throughout JSim physics.
Definition vector.hpp:22
static constexpr Vector3 unitY() noexcept
Returns the +Y basis vector.
Definition vector.hpp:394
Vector3 normalized() const noexcept
Returns the normalized direction vector.
Definition vector.hpp:119
static constexpr Vector3 unitX() noexcept
Returns the +X basis vector.
Definition vector.hpp:392
static constexpr Vector3 unitZ() noexcept
Returns the +Z basis vector.
Definition vector.hpp:396
static constexpr Vector3 zero() noexcept
Returns the zero vector.
Definition vector.hpp:360