introduction_to_frc_programming
Table of Contents
Introduction to FRC Programming
Java
What is Java?
- Released by Sun Microsystems in 1995
- High-Level, Class-Based, Object Oriented programming language
- Code runs in a Virtual Machine
- Java is compiled to ByteCode
- Virtual machine converts ByteCode at runtime
- Syntax is based off of C/C++
- Strongly and Statically Typed
Why do we use Java?
- Managed Language
- Memory usage is tracked by Virtual Machine
- Memory that is no longer used is freed by the Garbage Collector
- Eliminates some common, and hard to debug, issues that can arise in code
- Very Well Supported Language
- Java is one of the most commonly used languages in the world
- Java is the most commonly used language in FRC
- Java is commonly taught in schools (including Birmingham)
Prerequisites
Here are links for the standard tool set for FRC programming
FRC Game Tools (Optional)
The WPILib Installer will install a number of utilities onto your computer including a specially configured instance of VSCode. This version of VSCode should be used, even if you have another instance installed, since it is configured to correctly build and deploy projects to FRC robots.
The FRC Game Tools are not required to program a robot, but are required if you want to control the robot from your programming computer.
Programming Concepts
Variables
Variables store information for your program including:
- Numbers
- Text
- References to hardware
Variable Examples
// CAN IDs public int lfDriveMotorID = 1; public int lrDriveMotorID = 2; public int rfDriveMotorID = 3; public int rrDriveMotorID = 4; // Drivetrain Constants public Distance wheelDiameter = Inches.of(3); public double driveRatio = 1.0/8.45;
Variable - Primitives
| Type | Description | |
| Boolean | bool | true or false, 0 or 1 |
| Integers | byte | Whole number from -128 to 127 |
| short | Whole number from -32,768 to 32,767 | |
| int | Whole number from -2,147,483,648 to 2,147,483,647 | |
| long | Whole number -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | |
| Floating Point | float | Fractional Number Significant to 6 to 7 decimal places |
| double | Fractional Number Significant to 15 decimal places | |
| Character | char | Stores a single character/letter or ASCII values |
Variable - Object
- An object is a collection of variables and methods.
- Used to logically group things together in programs.
- Example: The Drivetrain object includes all the drive motors
- Fundamental part of java
All variables in Java, except for primitive types, are an object.
introduction_to_frc_programming.txt · Last modified: by ztif33
