Making the shot

Now that we have the robot positioned at the right angle, we are ready to make the shot. Of course, in order to shoot the ball we will need to spin up the shooter motors.  Since it takes time for the motors to reach the proper speed, we don’t want to wait until we have aligned with the target to start them, so we will turn them on before we start the alignment process by adding the following line to the initialize() function:

When the Nudge process is complete, we don’t want to stop, but rather prepare for the shot which means waiting for the spinner motors to reach full speed.  To accomplish this goal, we will need a function in the SpinnerSubsystem that we can call that will tell us that the motors have reached the designated speed.  Add the following function to your SpinnerSubsystem class:

This function will return true if both spinner motors are withing a specified tolerance of their set speed. Your SpinnerSubsystem.java file should now look like

Now back in our AutoShootCommand class, add two new states, PrepareShot, and Shoot:

In the StartNudge function we currently check to see if the robot is aligned correctly and then enter the Done state if it is.  We want to change this so that we stop the turning and enter the PrepareShot state instead:

Now add a new case in the execute() function to handle the PrepareShot case:

Once again we call a function PreparingShot to handle this state which we declare as follows:

Here we wait until the speed of the motors are withing 5 RPS of the target and then call the function Shoot() which will activate the shooting mechanism and place us in the Shoot state.  The Shoot() function is declared as follows:

We activate the shooter mechanism, start a timer, and set the state to Shoot.  We use a timer here because we need to leave the shooter mechanism active for a short time to allow the ball to be grabbed by the spinning wheels.  When the timer expires, we will then release the shooting mechanism.  We check for this condition by adding the last Shoot case to our execute() function as follows:

And we declare the Shooting() function as follows

Once the elapsed time exceeds k_shootTime we enter the Done state. The k_shootTime constant is defined as:

We need to do one last thing.  When the end() or interrupted() functions are called, we need to ensure that the spinner motors are turned off and the shooter mechanism is in the release position as follows:

Your AutoShootCommand.java file should now look like:

Now deploy and run your program and test it out.  Position your robot so that it is at the correct shooting distance, but rotate it so that it is not aligned with the target.  Then press button 3 on the joystick and the robot should turn to the correct position and shoot the ball.

Next: Getting the distance right

Pierre Pierre, who replica handbag 185cm tall, gucci replica handbags the "Diamond King" in his hermes replica handbags . He has been selected as one of the handbag replica most beautiful 50 people in the "People" magazine. It is also known as replica handbags most elegant and quiet in the world. Unforgettable prince.