Simple Driving DRYerer - Dutton-Christian-Robotics/Learning-to-Code GitHub Wiki

Now that you understand how mecanum wheels work, code methods in the robot class for:

  • turn right
  • turn left
  • strafe right
  • strafe left

Note that now that we have seven methods for driving in different directions, we're using 4 motor power statements for each. Seems like a case for DRY!

How about we write one method that will set power for all the motors; we'll pass each motor's power as an argument to the method.

Rewrite your driving methods to use the setPower method. Note that we save three whole lines per driving method!