Auto Aiming Mini Tank
Overview
For the 2025–2026 FTC & FRC season, I programmed a projectile-motion inspired shooting system to allow our robot to launch balls from anywhere on the field.
This project consists of 5 main components:
- Use the goal position, robot position, and a desired impact angle to calculate a 3D launch vector that will launch the ball into the goal
- Offset the launch vector by the robot velocity to allow shooting while moving
- Calculate a target turret and hood angle to compensate for deviations in actual exit speed
- Iteratively test the algorithm in simulation
- Design responsive & accurate control systems for the shooter, turret, and hood
1 Computing desired 3D launch vector of ball
The parabolic curve of a projectile can be defined with 3 data points: a starting position, an ending position, and the angle of its velocity vector when at the ending position (this is a tunable constant which I call the impact angle). Using these 3 pieces of data, one can calculate the launch vector of the ball at any given robot position.
Show the math Hide the math
- desired exit speed of the artifact
- hood angle, measured from horizontal
- turret angle
- desired impact angle — the angle of the ball’s velocity when it reaches the goal
- goal height minus exit height
- horizontal distance from the exit position to the goal
Let
Projectile motion equations tell us that:
Position
Velocity
Substituting the time of flight into the velocity relation, then folding in the position result:
Ideal hood angle
With the hood angle known, the same position result gives the speed it has to be fired at:
Ideal exit speed
Ideal turret angle
Constructing the 3D ball launch vector
2 Accounting for robot velocity
We also need a way to counteract the robot’s movement, because it will alter the trajectory of the ball. To do this, we can use vector subtraction and offset the previous 3D launch vector by the velocity at the ball’s exit position. Note: because the ball’s launch position is not guaranteed to be aligned with the robot’s axis of rotation, we also need to account for the tangential velocity created by rotation.
Show the math Hide the math
- robot velocity at center of mass (assumed axis of rotation)
- robot angular velocity
- ball exit position relative to robot position
- robot velocity at exit position of ball
- desired 3D launch vector of ball
- the actual launch vector we want to aim at
Assuming
Constructing the desired launch vector
Finally, your target launch speed equals the length of this launch vector.
Target launch speed
3 Compensating for deviation in exit speed
The Law of Conservation of Energy states that energy cannot be created. Therefore, when the shooter contacts the ball and the ball speeds up, the shooter wheel must slow down. Since the shooter wheel has lost some of its energy, it will transfer less energy to the next ball that is shot, decreasing shot accuracy.
To mitigate this problem, we can alter our hood angle — changing the arc of the trajectory — to compensate for the lower exit speed; and we can also alter our turret angle to ensure that we can still shoot on the move.
a: Deriving time of flight polynomial
- possible launch vector
- current exit speed
Assuming
We already know that:
By component
Displacement over the flight
And assuming that you cannot instantaneously change your shooter speed:
Clearing the denominator:
Collecting by power of leaves a quartic whose unknown is no longer the exit speed, but the time of flight:
Quartic in time of flight
b: Approximating the “best” flight time
Finding zeroes of time of flight polynomial
We want to find this function’s zeroes, because they represent all of the possible trajectories that we could take to compensate for an inaccurate launch speed. So I approximated the zeros using a two-stage search. First, the flight-time domain is discretized into low-resolution intervals to identify regions where the function crossed zero. These intervals were then refined with bisection, which repeatedly halves the interval until the root estimate achieved a maximum error of seconds. At a maximum, the code could return 2 flight times (a low arc & a high arc shot). Returning 1 time of flight means the high and low arc shot converged (this trajectory minimizes launch speed). Returning 0 flight times signifies that the launch speed just dropped too much and there are no valid trajectories.
Recalculating the new launch vector
Let be a list containing all real zeroes of that polynomial. For each candidate time :
Then pick the time of flight whose impact angle is closest to the desired impact angle.
c: Calculating compensated hood and turret angles
Plugging the time of flight into the launch vector equations
Compensated hood angle
Compensated turret angle
4 Custom AdvantageScope Sim
The purpose of this simulation is to visualize 3D poses and trajectories, allowing me to extensively test my physics equations as well as robot behavior before deploying to the robot.
- To visualize the shot arcs, I converted the launch vector into a parabolic equation, then generated points along the equation and drew lines connecting them.
- To model the balls, I implemented Euler’s method and applied gravity to simulate a projectile.
5 Control System Design & Testing
For both FTC and FRC, our shooting system consists of 3 hardware components allowing us to accurately launch balls.
Control System
Like all good things, I started with a PID. Then, to counteract the backEMF and friction in the motor, I added a feedforward velocity regression. And to communicate with the physics algorithm, I modeled a launch velocity to motor velocity conversion (see right). I also applied a time-invariant low pass filter to remove high frequency sensor noise.
System Identification
This regression relates a given motor velocity (x axis) to the ball’s launch velocity (y axis). Interestingly, a logarithmic curve best fit this data, showing that at higher speeds, more energy is lost in the shooter wheel-ball collision.
Control System
Similarly to the shooter, I also started with just a PID. Then I added a distance-based trapezoidal motion profiler using this equation:
The output of the motion profiler is fed into a feedforward velocity regression, similar to that in the shooter (see right). And finally, because the shooter’s center of mass is not aligned with the turret’s axis of rotation, any robot acceleration will exert a torque on the turret. So I countered the external torque with this physics model:
= applied voltage, = a tunable constant, = robot acceleration, = turret axis relative to robot axis
System Identification
Below is the feedforward turret velocity regression. The x axis is angular velocity (rad/s), and the y axis is applied voltage. The slope corresponds to kV and intercept corresponds to kS.
Control System
The hood control system is pretty simple; a PID with gravity feedforward modeled by
= applied voltage, = tunable constant, = hood angle from horizontal
System Identification
This regression maps hood encoder values to the actual angle from the horizontal. The x axis is encoders, and the y axis is angle (degrees).