Drive Subsystem

The Drive Subsystem performs the same function as its counterpart in the Minibot tutorial, namely it will control the two drive motors. In fact you may want to refer to your code for that previous robot as an aid.

The motors for this new robot will use the same PWMMotor class that you used previously.

You are, of course, going to need the pin numbers to use:

With this information, you should now be able to create your Drive Subsystem class. Once you have done that, create an Arcade Drive command and get your robot driving with a joystick. Remember to set your Arcade Drive command as the Drive Subsystem’s default command.

Once you have your robot driving you will want to use the wheel encoders to calibrate the speed as we did in the MiniBot tutorial. For this robot however, we are using a different kind of encoder called a Quadrature Encoder. We will still use the Encoder class, but we will set the type to EncoderType.Quadrature. These encoders use this constructor:

You will need the pin numbers:

Once you have created instances of your encoders, remember to set them as the feedback devices for your motors.

Finally, create setPower and setSpeed functions to control the two motors. You can look back at the Robot Java tutorial if you need help in remembering how to do this.

You should now be ready to tune the speed of your drive motors.  Again, you can look back at the Minibot tutorial to refresh your memory of how to do this but the following are the basic steps involved:

  1. You should create a Calibrate Drive command and tie it to a button.
  2. Using this command, drive the motors at full power (using setPower) and log the speed for the left and right wheels. This will tell you the maximum possible speed for each of the motors.
  3. First set the F term of the PID controller for each of the motors so that they are running at about 75% of the maximum speed (using setSpeed).
  4. Next add a P term and increase it until you see the speeds become unstable, and then back off a bit.
  5. Finally add an I term and increase it until you see the speeds become unstable, and then back off a bit. Remember to set an appropriate IZone.
  6. Once you have it tuned for 75% speed, check the tuning at 50% and 25%. Since it is not possible to have ideal F, P and I terms at all speeds, only change the P and I terms if there are significant problems at those speeds.

In my case, I found that the max speed was around 2500 and the final calibration graphs appeared as follows:

Once you have your drive motors calibrated, you can change your Arcade Drive command to use speed instead of power if you like.

Next: Shooter Subsystem