Skip to content

Commit 0289e69

Browse files
committed
Updated markdown errors with Claude's help.
1 parent 286dd45 commit 0289e69

19 files changed

Lines changed: 323 additions & 315 deletions

docs/basics/java_basics.md

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,26 @@ Learning What's What
88

99
- Objects, variables, and classes (in Java) make up our programs. We define, modify, and use these variables and objects to make our programs run.
1010
- Programs use key words to define characteristics of variables or objects. Basic keywords:
11-
- `#!java public` - an object accessible by other classes (files)
12-
- `#!java private` - an object only accessible by its containing class (file).
13-
- `#!java protected` - like private but can be seen by subclasses
14-
- `#!java return` - value to return or give back after method execution (run).
15-
- `#!java void` - a method that returns no value
16-
- `#!java null` - a value that means empty or nothing
17-
18-
!!! Warning "IMPORTANT NOTE"
11+
- `public` - an object accessible by other classes (files)
12+
- `private` - an object only accessible by its containing class (file).
13+
- `protected` - like private but can be seen by subclasses
14+
- `return` - value to return or give back after method execution (run).
15+
- `void` - a method that returns no value
16+
- `null` - a value that means empty or nothing
17+
18+
!!! warning "IMPORTANT NOTE"
1919
Java is case sensitive, meaning capitalization matters!
2020
***
2121

2222
## Classes
2323

2424
- Classes are the files that contain our programming
2525
- A program can be made up of one class but can also be made up of many classes
26-
- All programs run a main class that can optionally load additional classes either directly or indirectly
27-
- !!! example
28-
main loads class1, class1 loads class2
26+
- All programs run a main class that can optionally load additional classes either directly or indirectly
27+
28+
!!! example
29+
main loads class1, class1 loads class2
30+
2931
- Classes are made up of variables and methods and are often used to separate and organize your code.
3032
- Classes can also **call** (use) variables or methods of other classes if those have been set to public.
3133

@@ -37,8 +39,9 @@ Learning What's What
3739
- They can be called again if the class is programmed to be unloaded (destroyed) and reloaded.
3840
- Calls to methods, and assignment of values, within the constructor will run as soon as the class is called (loaded) in the code.
3941
- The **new** operator creates an object of a type of class using a constructor
40-
- !!! example
41-
classObject = new className();
42+
43+
!!! example
44+
classObject = new className();
4245

4346
***
4447

@@ -82,25 +85,28 @@ Learning What's What
8285
- Variables are assigned names and data types on creation
8386
- Names can be anything with the exception of pre-existing keywords such as `public` or `int`
8487
- Data types define what type of data is being stored in the variables:
85-
- `#!java int` - integers (whole numbers)
86-
- `#!java double` - double precision floating point (fractional/decimal values)
87-
- `#!java boolean` - true or false (true = 1 or false = 0) values.
88-
- `#!java string` - text values contained in parentheses
89-
- !!! Example "Example: `#!java int sum;`"
90-
A variable that can hold whole number values
91-
- !!! Example "Example: `#!java boolean isFull = true;`"
92-
A variable can either hold a true or false value and is being assigned a true value
88+
- `int` - integers (whole numbers)
89+
- `double` - double precision floating point (fractional/decimal values)
90+
- `boolean` - true or false (true = 1 or false = 0) values.
91+
- `string` - text values contained in parentheses
92+
93+
!!! example "Example: `int sum;`"
94+
A variable that can hold whole number values
95+
96+
!!! example "Example: `boolean isFull = true;`"
97+
A variable can either hold a true or false value and is being assigned a true value
9398

9499
### Constants
95100

96101
Most variables can have their values assigned or reassigned at any point elsewhere in your program. To avoid having a variable change its value during runtime you can make it a **constant**
97102

98-
- In Java you can create constants using the `#!java static final` keywords together in front of the data type of the variable
99-
- The static modifier causes the variable to be available without loading the class where it is defined.
103+
- In Java you can create constants using the `static final` keywords together in front of the data type of the variable
104+
- The static modifier causes the variable to be available without loading the class where it is defined.
100105
- The final modifier causes the variable to be unchangeable.
101106
- Java constants are normally declared in ALL CAPS. Words in Java constants are normally separated by underscores.
102-
- !!! Example "Example: `#!java public static final double PI_VALUE = 3.14159;`"
103-
A variable that cannot be modified during code run time.
107+
108+
!!! example "Example: `public static final double PI_VALUE = 3.14159;`"
109+
A variable that cannot be modified during code run time.
104110

105111
### Scope
106112

@@ -171,9 +177,10 @@ Most variables can have their values assigned or reassigned at any point elsewhe
171177
- There are also many different conventions when programming, this ensures that programs are readable between different people.
172178
- A common naming convention:
173179
- Programming is often done in CamelCase or lowerCamelCase
174-
- Instead of adding spaces, capitalize the first letter of each word
175-
- !!! example
176-
ThreeMotorDrive, driveForward, setSpeed
180+
- Instead of adding spaces, capitalize the first letter of each word
181+
182+
!!! example
183+
ThreeMotorDrive, driveForward, setSpeed
177184

178-
!!! info
185+
!!! info
179186
There are other naming conventions, but for this tutorial we will use the camel cases

docs/basics/wpilib.md

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Making FRC Programming Easy
99
- The WPI Robotics library (WPILib) is a set of software classes that interfaces with the hardware and software in your FRC RoboRIO.
1010
- There are classes to handle sensors, motor speed controllers, the driver station, and a number of other utility functions.
1111
- Documentation is available at <http://first.wpi.edu/FRC/roborio/release/docs/java>
12-
- WPILib adds those sensors and controllers as additional data types (like `#!java int` or `#!java double`) and classes.
12+
- WPILib adds those sensors and controllers as additional data types (like `int` or `double`) and classes.
1313

14-
/// details | Examples
15-
`Talon`, `Solenoid`, `Encoder`...
14+
??? example "Examples"
15+
`Talon`, `Solenoid`, `Encoder`...
1616

1717
***
1818

@@ -41,13 +41,14 @@ Making FRC Programming Easy
4141
- Some variables (parts) would be: **leftEye**, **rightEye**, **nose**, **leftEar**, **rightEar**.
4242
- Some example methods would be **closeEyes** or **openEyes** since these are things the dog are capable of.
4343
- These methods would use both the **leftEye** and **rightEye** and close them.
44-
- /// details | example
45-
```java
46-
//This method closes the dog eyes
44+
45+
??? example
46+
```java
47+
//This method closes the dog eyes
4748
public void closeEyes(){
48-
leftEye.close();
49-
rightEye.close();
50-
```
49+
leftEye.close();
50+
rightEye.close();
51+
```
5152
- A robot example of a **Drivetrain** subsystem would have **leftMotor**, and **rightMotor** as variables and **setSpeed** as a method telling it how to set the speed of those motor controllers.
5253
- Having the **setSpeed** method tells our program that our **Drivetrain** subsystem can set its speed.
5354
- ??? example
@@ -68,48 +69,56 @@ Making FRC Programming Easy
6869
- A **command** is an action a **subsystem(s)** performs.
6970
- For example you may want your robot to drive full speed forward so you make a command class called **DriveForward**.
7071
- Since a robot uses a **Drivetrain** subsystem to control its motors, this command would call our previously created **setSpeed** method from that subsystem.
71-
- !!! Tip
72-
**Subsystems** define what the robot is made of and what it can do while **commands** actually tell the robot to do those things
72+
73+
!!! tip
74+
**Subsystems** define what the robot is made of and what it can do while **commands** actually tell the robot to do those things
75+
7376
- Using a dog as an example we can tell the dog to blink by creating a **BlinkEyes** command
7477
- The command would call the method, **closeEyes()** then the method **openEyes()**
75-
- ??? example "BlinkEyes Command"
76-
```java
78+
79+
??? example "BlinkEyes Command"
80+
```java
7781
//This command will continuously run the two methods in execute
7882
protected void execute() {
79-
dog.head.closeEyes();
80-
dog.head.openEyes();
83+
dog.head.closeEyes();
84+
dog.head.openEyes();
8185
}
82-
```
86+
```
87+
8388
- A robot example of a **DriveForward** command would call (use) the **setSpeed** methods that we created in the **Drivetrain** subsystem
8489
- **DriveForward**, when executed, will tell our robot to drive forward using the **Drivetrain** subsystem
85-
- ??? example "DriveForward Command"
86-
```java
90+
91+
??? example "DriveForward Command"
92+
```java
8793
//This command tells the robot to drive forward full speed
88-
protected void initialize(){
89-
robot.drivetrain.setSpeed(1.0);
90-
}
91-
```
94+
protected void initialize(){
95+
robot.drivetrain.setSpeed(1.0);
96+
}
97+
```
9298

9399
#### Default Command Structure
94100

95101
- The template for FRC commands actually come with some pre-defined methods that have special properties for FRC robots, they are:
96-
- `#!java void initialize()` - Methods in here are called just before this Command runs the first time.
97-
- `#!java void execute()` - Methods in here are called repeatedly when this Command is scheduled to run
98-
- `#!java boolean isFinished()` - When this returns true, the Command stops running execute()
99-
- `#!java void end()` - Methods in here are called once after isFinished returns true
100-
- `#!java void interrupted()` - Methods in here are called when another command which requires one or more of the same subsystems is scheduled to run
101-
- !!! Tip
102-
It is good practice to call `end()` in `interrupted()`
102+
- `void initialize()` - Methods in here are called just before this Command runs the first time.
103+
- `void execute()` - Methods in here are called repeatedly when this Command is scheduled to run
104+
- `boolean isFinished()` - When this returns true, the Command stops running execute()
105+
- `void end()` - Methods in here are called once after isFinished returns true
106+
- `void interrupted()` - Methods in here are called when another command which requires one or more of the same subsystems is scheduled to run
107+
108+
!!! tip
109+
It is good practice to call `end()` in `interrupted()`
103110

104111
***
105112

106113
### Overview of execution
107114

108-
- In FRC programming our main class is **Robot.java** and all other classes (command files and subsystem files) must be loaded from **Robot.java** either directly or indirectly
109-
- !!! Example
110-
**Robot.java** loads **RobotContainer.java**, **RobotContainer.java** loads **DriveForward.java**.
115+
- In FRC programming our main class is **Robot.java** and all other classes (command files and subsystem files) must be loaded from **Robot.java** either directly or indirectly
116+
117+
!!! example
118+
**Robot.java** loads **RobotContainer.java**, **RobotContainer.java** loads **DriveForward.java**.
119+
111120
- All **subsystem** files must be added to **RobotContainer.java**.
112-
- This loads our **subsystems** into the code and allow its public methods to be useable by other files such as commands later by typing `#!java RobotContainer.nameOfSubsystem.desiredMethod();`
121+
- This loads our **subsystems** into the code and allow its public methods to be useable by other files such as commands later by typing `RobotContainer.nameOfSubsystem.desiredMethod();`
113122

114123
***
115124

@@ -125,5 +134,5 @@ See [Default Project Contents](../programming/new_project.md#default-project-con
125134
- **Subsystems** define what the robot is made of and what it can do while **commands** actually tell the robot to do those things
126135
- All classes must directly or indirectly connect to **Robot.java**.
127136
- All **Subsystems** must be added to **RobotContainer.java**
128-
- **RobotMap.java** holds port numbers and IDs accessible throughout the program by typing: `#!java RobotMap.NameOfMotor()`
137+
- **RobotMap.java** holds port numbers and IDs accessible throughout the program by typing: `RobotMap.NameOfMotor()`
129138
- **RobotContainer.java** contains our publicly accessible instances of our subsystems. It also connects our commands to physical controllers.

docs/code_examples/2026KitBotInline/RobotContainer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ private void configureBindings() {
8484
// value). The X-axis is also inverted so a positive value (stick to the right)
8585
// results in clockwise rotation (front of the robot turning right). Both axes
8686
// are also scaled down so the rotation is more easily controllable.
87+
// --8<-- [start: drive-config]
8788
driveSubsystem.setDefaultCommand(
8889
driveSubsystem.driveArcade(
8990
() -> -driverController.getLeftY() * DRIVE_SCALING,
9091
() -> -driverController.getRightX() * ROTATION_SCALING));
92+
// --8<-- [end: drive-config]
9193
}
9294

9395
/**
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands;
6+
7+
import java.util.function.DoubleSupplier;
8+
9+
import edu.wpi.first.wpilibj2.command.Command;
10+
import frc.robot.subsystems.CANDriveSubsystem;
11+
12+
/**
13+
* An example command that uses an arcade drive subsystem. This command demonstrates
14+
* how to create a command that gets input from joystick axes and drives the robot.
15+
*/
16+
public class DriveArcadeCommand extends Command {
17+
// --8<-- [start: class-variables]
18+
private final DoubleSupplier xSpeed;
19+
private final DoubleSupplier zRotation;
20+
private final CANDriveSubsystem driveSubsystem;
21+
// --8<-- [end: class-variables]
22+
23+
/**
24+
* Creates a new DriveArcadeCommand.
25+
*
26+
* @param xSpeed the input for movement speed as a DoubleSupplier (a function that returns a double)
27+
* @param zRotation the input for rotation speed as a DoubleSupplier
28+
* @param driveSubsystem the subsystem that this command requires
29+
*/
30+
// --8<-- [start: constructor-signature]
31+
public DriveArcadeCommand(
32+
DoubleSupplier xSpeed, DoubleSupplier zRotation, CANDriveSubsystem driveSubsystem) {
33+
// --8<-- [end: constructor-signature]
34+
// --8<-- [start: constructor-body]
35+
this.xSpeed = xSpeed;
36+
this.zRotation = zRotation;
37+
this.driveSubsystem = driveSubsystem;
38+
// Use addRequirements() here to declare subsystem dependencies.
39+
addRequirements(driveSubsystem);
40+
// --8<-- [end: constructor-body]
41+
}
42+
43+
// Called when the command is initially scheduled.
44+
@Override
45+
public void initialize() {}
46+
47+
// Called every time the scheduler runs while the command is scheduled.
48+
// --8<-- [start: execute-method]
49+
@Override
50+
public void execute() {
51+
driveSubsystem.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble());
52+
}
53+
// --8<-- [end: execute-method]
54+
55+
// Called once the command ends or is interrupted.
56+
// --8<-- [start: end-method]
57+
@Override
58+
public void end(boolean interrupted) {
59+
driveSubsystem.arcadeDrive(0, 0);
60+
}
61+
// --8<-- [end: end-method]
62+
63+
// Returns true when the command should end.
64+
// --8<-- [start: is-finished-method]
65+
@Override
66+
public boolean isFinished() {
67+
return false; // This command never finishes on its own; it runs continuously
68+
}
69+
// --8<-- [end: is-finished-method]
70+
}

docs/code_examples/2026KitBotInline/subsystems/CANDriveSubsystem.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ public class CANDriveSubsystem extends SubsystemBase {
2727
private final SparkMax rightFollower;
2828

2929
// --8<-- [end: motors]
30+
31+
// --8<-- [start: differential-drive-variable]
3032
private final DifferentialDrive drive;
33+
// --8<-- [end: differential-drive-variable]
3134

3235
// --8<-- [start: constructor]
3336

@@ -44,35 +47,45 @@ public CANDriveSubsystem() {
4447
// Set can timeout. Because this project only sets parameters once on
4548
// construction, the timeout can be long without blocking robot operation. Code
4649
// which sets or gets parameters during operation may need a shorter timeout.
50+
// --8<-- [start: can-timeout]
4751
leftLeader.setCANTimeout(250);
4852
rightLeader.setCANTimeout(250);
4953
leftFollower.setCANTimeout(250);
5054
rightFollower.setCANTimeout(250);
55+
// --8<-- [end: can-timeout]
5156

5257
// Create the configuration to apply to motors. Voltage compensation
5358
// helps the robot perform more similarly on different
5459
// battery voltages (at the cost of a little bit of top speed on a fully charged
5560
// battery). The current limit helps prevent tripping
5661
// breakers.
62+
// --8<-- [start: voltage-compensation]
5763
SparkMaxConfig config = new SparkMaxConfig();
5864
config.voltageCompensation(12);
5965
config.smartCurrentLimit(DRIVE_MOTOR_CURRENT_LIMIT);
66+
// --8<-- [end: voltage-compensation]
6067

6168
// Set configuration to follow each leader and then apply it to corresponding
6269
// follower. Resetting in case a new controller is swapped
6370
// in and persisting in case of a controller reset due to breaker trip
71+
// --8<-- [start: follower-config]
6472
config.follow(leftLeader);
6573
leftFollower.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
6674
config.follow(rightLeader);
6775
rightFollower.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
76+
// --8<-- [end: follower-config]
6877

6978
// Remove following, then apply config to right leader
79+
// --8<-- [start: right-leader-config]
7080
config.disableFollowerMode();
7181
rightLeader.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
82+
// --8<-- [end: right-leader-config]
7283
// Set config to inverted and then apply to left leader. Set Left side inverted
7384
// so that postive values drive both sides forward
85+
// --8<-- [start: left-inversion]
7486
config.inverted(true);
7587
leftLeader.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
88+
// --8<-- [end: left-inversion]
7689
}
7790

7891
// --8<-- [end: constructor]
@@ -82,8 +95,10 @@ public void periodic() {
8295
}
8396

8497
// Command factory to create command to drive the robot with joystick inputs.
98+
// --8<-- [start: drive-arcade-method]
8599
public Command driveArcade(DoubleSupplier xSpeed, DoubleSupplier zRotation) {
86100
return this.run(
87101
() -> drive.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble()));
88102
}
103+
// --8<-- [end: drive-arcade-method]
89104
}

0 commit comments

Comments
 (0)