Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
tap::algorithms::ballistics Namespace Reference

Classes

struct  AbstractKinematicState
 
struct  SecondOrderKinematicState
 

Functions

bool computeTravelTime (const modm::Vector3f &targetPosition, float bulletVelocity, float *travelTime, float *turretPitch, const float pitchAxisOffset)
 
bool findTargetProjectileIntersection (const AbstractKinematicState &targetInitialState, float bulletVelocity, uint8_t numIterations, float *turretPitch, float *turretYaw, float *projectedTravelTime, const float pitchAxisOffset)
 

Function Documentation

◆ computeTravelTime()

bool tap::algorithms::ballistics::computeTravelTime ( const modm::Vector3f &  targetPosition,
float  bulletVelocity,
float *  travelTime,
float *  turretPitch,
const float  pitchAxisOffset = 0 
)

Computes an iterative numerical approximation of the pitch angle to aim the turret in order to hit a given target and the time it will take for that target to be hit, given the velocity of a bullet out of the turret and the position of the target relative to the turret.

Parameters
[in]targetPositionThe 3D position of a target in m. Frame requirements: RELATIVE TO PROJECTILE RELEASE POSITION, Z IS OPPOSITE TO GRAVITY.
[in]bulletVelocityThe velocity of the projectile to be fired in m/s.
[out]travelTimeThe expected travel time of a turret shot to hit a target from this object's position.
[out]turretPitchThe pitch angle of the turret to hit the target at the given travel time.
[in]pitchAxisOffsetThe distance between the pitch and yaw axes (in meters) as seen from a plane parallel to the ground. A positive offset indicates that the pitch axis is located behind the yaw axis.
Returns
Whether or not a valid travel time was found.

◆ findTargetProjectileIntersection()

bool tap::algorithms::ballistics::findTargetProjectileIntersection ( const AbstractKinematicState targetInitialState,
float  bulletVelocity,
uint8_t  numIterations,
float *  turretPitch,
float *  turretYaw,
float *  projectedTravelTime,
const float  pitchAxisOffset = 0 
)
Parameters
[in]targetInitialStateThe initial 3D kinematic state of a target. Frame requirements: RELATIVE TO PROJECTILE RELEASE POSITION, Z IS OPPOSITE TO GRAVITY.
[in]bulletVelocityThe velocity of the projectile to be fired in m/s.
[in]numIterationsThe number of times to project the kinematics forward. Guidelines on choosing this parameter:
  • If the target is moving very slow relative to bulletVelocity, 1 is probably enough.
  • For higher target speeds, 2-3 is probably a good estimate.
  • If the target is approaching the projectile speed, this algorithm may have a difficult time converging (but it may be possible with enough iterations).
  • If the target is moving faster than the projectile, this algorithm will diverge.
[out]turretPitchThe world-relative turret pitch (in radians above level) at which our robot should aim to hit the given target, taking into account the path a projectile takes to hit the target.
[out]turretYawAnalogue of turret pitch
[out]projectedTravelTimeThe expected time between projectile launch and impact with the target, in seconds.
[in]pitchAxisOffsetThe distance between the pitch and yaw axes (in meters) as seen from a plane parallel to the ground. A positive offset indicates that the pitch axis is located behind the yaw axis.
Returns
Whether or not a valid aiming solution was found. Out parameters only valid if true.