You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/programming/driving_robot.md
+90-72Lines changed: 90 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,8 +28,11 @@ In the Drivetrain class we will tell the subsystem what type of components it wi
28
28
- If you are using other motor controllers, replace SparkMax with Talon, TalonSRX, Victor, or VictorSP in the code you write depending on the type you use.
29
29
- You can use 2 motors (left and right), but for this tutorial we will use 4.
30
30
31
-
!!! Tip
32
-
Be sure to read [Visual Studio Code Tips](../basics/vscode_tips.md){target=_blank} before getting started! It will make your life a lot easier.
31
+
/// note | More Info
32
+
33
+
Be sure to read [Visual Studio Code Tips](../basics/vscode_tips.md){target=_blank} before getting started! It will make your life a lot easier.
34
+
35
+
///
33
36
34
37
### Creating the SparkMax Variables
35
38
@@ -48,50 +51,56 @@ In the Drivetrain class we will tell the subsystem what type of components it wi
Now that we have created the SparkMaxes and the Drive Constants we must initialize them and tell them what port on the roboRIO they are on.
76
81
77
82
**1)** Initialize (set value of) `leftLeader` to `#!java new SparkMax(LEFT_LEADER_ID, MotorType.kBrushless)`.
83
+
78
84
- This initializes a new SparkMax, `leftLeader`, in a new piece of memory and states it is on the port defined by `LEFT_LEADER_ID`.
79
85
- This should be done within the constructor `#!java Drivetrain()`
80
86
- This calls the constructor `#!java SparkMax(int, MotorType)` in the SparkMax class.
81
87
- The constructor `#!java SparkMax(int, MotorType)` takes a variable of type `#!java int` for the CAN ID and `MotorType` for brushless or brushed. In this case the `#!java int` (integer) refers to the CAN ID on the roboRIO.
See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete constructor implementation.
@@ -108,50 +117,56 @@ Since each subsystem has its own components with their own ports, it is easy to
108
117
- Names should follow the pattern SUBSYSTEM_NAME_OF_COMPONENT
109
118
- The name is all caps since it is a **constant** ([more info on constants](../basics/java_basics.md#constants){target=_blank}).
110
119
111
-
!!! summary ""
112
-
**1)**
113
-
Before we initalize the SparkMax objects we are going to create constants to hold the CAN ID's of the motors. This will happen in constants.java
114
-
- Inside the constants class, create a new class called `public static DriveConstants`.
115
-
- Inside `DriveConstants` class, create for constants called `LEFT_LEADER_ID`, `LEFT_FOLLOWER_ID`, `RIGHT_LEADER_ID`, and `RIGHT_FOLLOWER_ID`.
116
-
- Back in your `DriveTrain` class in `drivetrain.java`, import the `DriveConstants` class as follows: `Import frc.robot.Constants.DriveConstants;`.
117
-
118
-
!!! Tip
119
-
Make sure to declare constants with `public static final` so they cannot be changed at runtime.
120
-
121
-
!!! Danger
122
-
***If you set this to the wrong value, you could damage your robot when it tries to move!***
123
-
!!! summary ""
124
-
**1)** To use Constants, instead of putting `0` for the port in the SparkMax type:
125
-
```Java
126
-
DriveConstants.LEFT_LEADER_ID
127
-
```
128
-
129
-
!!! summary ""
130
-
**2)** Replace the remaining numbers with constants.
131
120
132
-
!!! Tip
133
-
Remember to save both **Drivetrain.java** and **Constants.java**
Before we initalize the SparkMax objects we are going to create constants to hold the CAN ID's of the motors. This will happen in constants.java
123
+
124
+
- Inside the constants class, create a new class called `public static DriveConstants`.
125
+
- Inside `DriveConstants` class, create for constants called `LEFT_LEADER_ID`, `LEFT_FOLLOWER_ID`, `RIGHT_LEADER_ID`, and `RIGHT_FOLLOWER_ID`.
126
+
- Back in your `DriveTrain` class in `drivetrain.java`, import the `DriveConstants` class as follows: `Import frc.robot.Constants.DriveConstants;`.
127
+
128
+
/// tip | Declaring Constants
129
+
Make sure to declare constants with `public static final` so they cannot be changed at runtime.
130
+
///
131
+
132
+
/// danger
133
+
***If you set this to the wrong value, you could damage your robot when it tries to move!***
134
+
///
135
+
/// note
136
+
To use Constants, instead of putting `0` for the port in the SparkMax type:
137
+
138
+
```java title="constants.java"
139
+
publicstaticfinalintLEFT_LEADER_ID=1;
140
+
```
141
+
///
142
+
143
+
/// note
144
+
Replace the remaining numbers with constants.
145
+
146
+
///
147
+
148
+
///Tip
149
+
150
+
Remember to save both **Drivetrain.java** and **Constants.java**
151
+
152
+
///
153
+
154
+
/// details | DriveConstants Example
136
155
137
156
**Drive Constants Definition:**
138
157
139
-
```Java
140
-
publicstaticfinalclassDriveConstants {
141
-
publicstaticfinalintLEFT_LEADER_ID=1;
142
-
publicstaticfinalintLEFT_FOLLOWER_ID=2;
143
-
publicstaticfinalintRIGHT_LEADER_ID=3;
144
-
publicstaticfinalintRIGHT_FOLLOWER_ID=4;
145
-
}
158
+
```java
159
+
--8<--"2026KitBotInline/Contants.java:constants"
146
160
```
147
161
162
+
///
163
+
148
164
**Full Constants.java with all Robot Constants:**
149
165
150
166
See [Constants.java](../code_examples/2026KitBotInline/Constants.java) for the complete constants file including OperatorConstants and other subsystem constants.
151
167
152
-
!!! Warning
153
-
Remember to use the values for **YOUR** specific robot or you could risk damaging it!
154
-
</details>
168
+
!!! Warning
169
+
Remember to use the values for **YOUR** specific robot or you could risk damaging it!
155
170
156
171
### Configuring the SparkMaxes
157
172
@@ -216,7 +231,7 @@ See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/subsystems/CANDri
216
231
!!! Warning
217
232
You should only group motors that are spinning the same direction physically when positive power is being applied otherwise you could damage your robot.
218
233
219
-
!!! summary ""
234
+
/// note
220
235
**2)** In order to configure the motors to drive correctly, we need to configure one on each side as the leader and one as the follower.
221
236
In the constructor we are going to set the follower motors and link them to the leader motors. To do this we will need to include a couple more classes from the REV Library:
222
237
```Java
@@ -245,15 +260,19 @@ See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/subsystems/CANDri
/// details | Full Drive Subsystem Example</summary>
266
+
267
+
See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete implementation with all motor configuration and initialization.
249
268
250
-
See [CANDriveSubsystem.java](../../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete implementation with all motor configuration and initialization.</details>
269
+
///
251
270
252
271
### Creating the arcadeDrive method
253
272
254
273
Now it’s time to make an arcadeDrive from our differentialDrive!
255
274
256
-
!!! summary ""
275
+
!!! abstract
257
276
**1)** Let’s create a public void method called “arcadeDrive” with type “double” parameters moveSpeed and rotateSpeed.
258
277
259
278
Below the `periodic` method create a new method called `arcadeDrive`. This method will be called from our Drive command to actually move the robot.
@@ -267,7 +286,7 @@ Now it’s time to make an arcadeDrive from our differentialDrive!
267
286
!!! Tip
268
287
By putting something in the parentheses it makes the method require a parameter when it is used. When the method gets used and parameters are passed, they will be store in moveSpeed and rotateSpeed (in that order). See [parameters](../basics/java_basics.md#parameters){target=_blank} for more info.
269
288
270
-
!!! summary ""
289
+
!!! abstract ""
271
290
**2)** Now lets make our method call the differentialDrive's arcadeDrive method.
272
291
273
292
Inside our method type:
@@ -287,7 +306,7 @@ Now it’s time to make an arcadeDrive from our differentialDrive!
287
306
288
307
You may want to do this for initial testing to make sure everything is going the right direction.
See [CANDriveSubsystem.java](../../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete implementation using the command factory pattern.
330
+
See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete implementation using the command factory pattern.
312
331
313
-
</details>
332
+
///
314
333
315
334
### Making our robot controllable
316
335
@@ -362,8 +381,8 @@ Before we begin we must create the class file for the DriveArcade command. See [
362
381
```
363
382
364
383
- The 3 lines starting with `this` set the global variables we defined at the top of our class file to the values being passed into the consturctor.
365
-
!!! Tip
366
-
`this` is how the class instance `object` refers to itself in code.
384
+
!!! Tip
385
+
`this` is how the class instance `object` refers to itself in code.
367
386
368
387
!!! summary ""
369
388
- `addRequirements` means this command will end all other commands currently using drivetrain and will run instead when executed.
@@ -417,17 +436,16 @@ Since we will be using this command to control the robot we want it to run indef
417
436
418
437
**Full Constants.java:**
419
438
420
-
See [Constants.java](../../code_examples/2026KitBotInline/src/main/java/frc/robot/Constants.java) for the complete constants file with all required constant definitions.
439
+
See [Constants.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/Constants.java) for the complete constants file with all required constant definitions.
421
440
422
441
**Full RobotContainer.java:**
423
442
424
-
See [RobotContainer.java](../../code_examples/2026KitBotInline/src/main/java/frc/robot/RobotContainer.java) for the complete RobotContainer implementation including all command bindings.
443
+
See [RobotContainer.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/RobotContainer.java) for the complete RobotContainer implementation including all command bindings.
425
444
426
445
**Full Drive Subsystem:**
427
446
428
-
See [CANDriveSubsystem.java](../../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete drive subsystem with all motor initialization and configuration.
447
+
See [CANDriveSubsystem.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/subsystems/CANDriveSubsystem.java) for the complete drive subsystem with all motor initialization and configuration.
429
448
430
-
</details>
431
449
432
450
## Finishing Up in RobotContainer
433
451
@@ -475,9 +493,9 @@ In order to drive our robot, it needs to know what will be controlling it. To do
475
493
!!! Tip
476
494
The `New` keyword creates a new instance of a class (object)
See [RobotContainer.java](../../code_examples/2026KitBotInline/src/main/java/frc/robot/RobotContainer.java) for the complete RobotContainer implementation.
498
+
See [RobotContainer.java](../code_examples/2026KitBotInline/src/main/java/frc/robot/RobotContainer.java) for the complete RobotContainer implementation.
481
499
482
500
The key part for drive configuration is in `configureBindings()`:
Copy file name to clipboardExpand all lines: docs/setup/install_software.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ Before we can start programing a robot we must install the necessary software fo
12
12
**See table of contents for a breakdown of this section.**
13
13
14
14
!!! tip
15
+
15
16
You can install both the **Development Tools** and the **FRC Game Tools** on the same computer or separate computers. However many teams (3255 included) have a development laptop (with both) and a dedicated driverstation laptop (with only the FRC Game Tools) that often stays disconnected from the internet.
0 commit comments