RLD 0: WPILib - TEAM1771/Crash-Course GitHub Wiki
Libraries and WPILib
"Libraries" are a concept of writing code for programmers to reuse. These could be functions to simplify math (such as an absolute value function, or a function which deals with exponents), format text (capitalize words, remove spaces, etc.), or even connect with the operating system through common libraries. WPILib is a collection of common libraries to allow us as programmers to access the various electronics (motor controllers, sensors, lights, etc.) connected to the RoboRio (robot's computer). WPILib also ships a version of the NI robot operating system which can run C++, Java, or LabVIEW code written with WPILib.
Here's what WPILib has to say: https://docs.wpilib.org/en/stable/docs/software/what-is-wpilib.html
Why do we need WPILib?
Without a set of common libraries like WPILib, you would have to write code from scratch to communicate with the robot's operating system and its electronics. WPILib also provides a variety of libraries to help make programming easier. For example, they include a "units" library that helps us programmers identify which units we use in our code (meters per second vs feet per second, degrees vs radians, etc.). It even does the conversions between the types of variables automatically! This is just one example from the many benefits common libraries provide.
What about documentation?
Thankfully, WPILib does come with a few types of documentation to help us understand all the features included.
-
The WPILib wiki/main docs are slightly fragmented, but contain a plethora of guides for programming all types of devices. They also include tutorials on everything from downloading/installing WPILib, to writing your first code, all the way to advanced autonomous functionality. These docs are a great place to start, but they don't always contain the answers, and you'll often have to look around to find the complete pictures as the organization isn't the best.
-
The WPILib C++ API documentation is much more straightforward. This is essentially a breakdown of everything in the WPILib API with explanations as to what each item is used for, what it does, and how it is used. This documentation is available inside VSCode by highlighting over a class, function, constructor, etc. For example, the frc::Joystick class is explained here.
-
In addition, you will often find other community documentation and answers to questions on the internet. A great place to look or ask if you have a specific question is the FRC Forum page, ChiefDelphi.