Why does this shoot badly?

flywheel.spinFor(forward, 25, turns);
  flywheel.spinFor(forward, 15, turns, false);
  wait(1, msec);
  shooterthing.set(false);
  wait(1, msec);
  flywheel.spinFor(forward, 5, turns, false);
  wait(1, msec);
  shooterthing.set(true);
  wait(1, msec);
  flywheel.spinFor(forward, 5, turns, false);
  wait(1, msec);
  shooterthing.set(false);
  wait(1, msec);
  flywheel.spinFor(forward, 5, turns, false);
  wait(1, msec);
  shooterthing.set(true);
  wait(1, msec);
  flywheel.spinFor(forward, 5, turns, false);
  wait(1, msec);
  shooterthing.set(false);
  wait(1, msec);

Does anyone know why this code shoots so badly in autonomous?
It shoots about 2 inches, not near far or high enough to make a goal, and it goes very slowly (shooterthing is the indexer)
Also, the indexer will go up at (false) but doesn’t go down at (true) unless I make it wait and/or it will take absolutely forever.

Even with the wait thing, the indexer takes forever to go back down and back up.

Also, adding false to the end of a motor spin/drive makes it so that it doesn’t wait to start the next function (as in, it launches the indexer WHILE it is spinning the flywheel?)

Default spinFor does not spin at 100% velocity.

Try flywheel.spin(forward, 80, percent); then do your waits and indexer code. The motor will try and stay at 80% the whole time, and the waits can let it recover after each shot.

You could get a little fancy and use a for loop to repeat the indexing.

It’s probably due to not setting a speed. I recommend you use motor.spin(fwd, 12, volt) at the very beginning. This will keep the flywheel running the entire time. Also, 1 msec is a very short amount of time (1/1000 of a sec) for the indexer to fire.

It doesn’t look like your flywheel has enough time to spin up before you shoot. Try leaving the flywheel on the whole match if possible, or at least give it more time to get up to speed. Also, I wouldn’t recommend using the spinFor function to spin your flywheel. Use the spin function instead, which will just spin your flywheel until you tell it to stop instead of trying to spin to a specific rotation.

As for the indexer problem, remember that pneumatics aren’t instant, you will need to put a bit of a delay whenever you activate them to make sure they fully extend. Right now you are changing the state of your pneumatics 5 times in 10 milliseconds (there are 1000 msec per sec). If changing this doesn’t fix it it is provably a build problem.

1 Like

I forgot to mention that I have the velocity set at 65%, which is the best for our driver control (tested several times) and shoots strongest and farthest for our flywheel, generally.

Speed is set. Also, how do volts work? I don’t quite understand them, I use percent.

However, I will use .spin, and change “1 msec” to 3 seconds.

Thanks a lot! Will give details on if this helped or not.

This worked really well!

Volts spin the motor directly without a built in middleman (automatic built in pid), and as such are usually more consistent for flywheel applications. (Noticeable in a lack of oscillation sometimes caused by using rpm and velocity control on flywheels) They spin the motor using a voltage value ranging from 12 volts to -12, -12 being backwards from whatever direction you chose. If you want to convert velocity to voltage directly without doing any math just multiply the velocity by 0.12:
image

1 Like

image
See image.

After checking the docs, you can see that setVelocity doesn’t accept volts as a unit. You need to use motor.spin, like this:

Motor.spin(forward, 12, volts);

image

Still doesn’t work

I put it in wrong on my response, it’s volt and not volts.

By the way, what is the minimum time needed to retract the indexer? I have it at 2 seconds per indexer action, but I feel like it wastes too much time.

A lot of figuring that out will be trial and error. Just keep reducing the time until you find the right balance between cycle time and flywheel consistency. If possible, you might consider ramping the flywheel up faster as you index, thus lowering your cycle time. If done properly, the faster flywheel motor speed and the added torque requirements of a disc passing through should cancel each other, with the only added result being quicker shooting and a motor that overheats slightly quicker.

My team uses a reverse intake with a pivoting tensioner to solve the indexing issue… After we have discs to shoot, we rotate the stack onto reverse geared intake motors and fire it into a small flex wheel chained to our flywheel. The secondary wheel helps the discs get up to speed quickly, thus keeping the flywheel at a stable rpm. Our firing rate, ignoring in taking, is just about 3 discs per 1.25 seconds.

Hope this helps! Good luck!

1 Like