Skip to main content

Object Oriented Programming and WPILib

In this module we will cover the basics of Object Oriented Programming. This will include creating classes, methods, and using objects. We will then cover some of the WPILib classes used for controlling a differential drive robot, including kinematics and odometry. Finally, we will cover how to simulate a differential drive robot using WPILib's simulation tools.


Presentation​


Exercises​

Classes​

  • Create an abstract OI class
    • Add a getter for a joystick Y axis
    • Add a getter for a joystick X axis
  • Update your code to use the OI class methods and remove the XboxController from Robot.java

Objects​

  • Create a Drivetrain Class
    • Create the class in a new folder called β€œsubsystems”
    • Move all content related to your drivetrain and its methods to the new class
    • Your readInputs and writeOutputs should now be your primary methods
    • Add a new method to reset wheel encoders
    • Add a new helper method to convert from ticks to meters
  • Create a Drivetrain Object in Robot
    • Use it to call readInputs and writeOutputs in robotPeriodic
    • Use it to call arcadeDrive in teleopPeriodic and autonomousPeriodic
    • Use it to call getDistance in autonomous

WPILib​

Simulation​


Software​

Software Tools​

  • VSCode: Our primary Integrated Development Environment (IDE) for programming.

  • Driver Station: Software used to control and monitor the robot during competitions.

  • Advantage Scope: Tool for analyzing robot performance data.

  • Elastic: Tool for logging and visualizing robot data.