ok so this gets very complicated, very fast. I don’t think you can use an ultrasonic because the goal is net, and it will probably just eat the ultrasonic.

you have 2 options as I see it, 1, you use pre-determined spots on the field, so you might use a line follower to line up on a line and shoot at a pre-set power

option 2 - this is the one I am trying to get working, you make a “robot gps” how you do this is you put an encoder on your wheels and use a gyro, the encoder on your wheels tells you how far you have moved, and the gyro gives you an angle, a little trig can tell you how far you moved in X and Y coordinates, and if you know where you started you can track the bot as it moves around the field, there is a a whole thread that goes very in depth on this subject

now if you know where your robot is and you know where the goal is, you can figure how far you are from the goal, then you need to use some physics equations to determine how fast you need to shoot

the equation you are looking for is this

Vo = 1/((( Y- (Sin(LaunchAngle )* (x/Cos(launchAngle)+LA))/-16) * (Cos(LaunchAngle)/X))

LA = launch altitude

Y = height of the goal

X = distance to the goal

Vo = required launch velocity of the ball

finaly you write some code to set your fly wheel shooter to a certain velocity, to do this you need an encoder on your flywheel to measure velocity, note, the velocity of the wheel does not = velocity the ball launches at, but it will get you close, the code you need for setting the fly wheel velocity will look like this

```
float ShooterVelocity
task getWheelVel(){
float wheelCirc = 5*3.14159265
float distPerTic = wheelCirc/360
While(true){
int Distance = 0
SensorValue[ShooterEncoder] = 0
wait1msec(20)
Distance = SensorValue[ShooterEncoder}
float inPerSec = Distance*5
ShooterVelocity = inPerSec/12 ///this is the velocity of the outer edge of the wheel in Feet Per Second
}
}
void setShooter(int targerVel){
float power = TargetVel * 4
While(Difference >/= 1){
motor[shooter] = power
wait1msec(10)
float difference = targetVel - ShooterVelocity
float P = .25
power = power + (Difference * P)
motor[shooter] = power
If(power < 0){
power = 0
}
if(power > 127){
power = 127
}
}
}
```

note I have not tested this code, it’s something I just threw together, and I know I did not use proper syntax, if you want to use this code you will need to add semicolons and what not