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
+27-22Lines changed: 27 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,24 +23,26 @@ Before we begin we must create the class file for the drivetrain subsystem. See
23
23
24
24
In the Drivetrain class we will tell the subsystem what type of components it will be using.
25
25
26
-
- A Drivetrain needs motor controllers. In our case we will use 4 Talon SRs (a brand of controller for motors).
27
-
- You could use other motor controllers such as Victor SPs or Talon SRXs but we will be using Talon SRs
28
-
- If you are using other motor controllers, replace Talon with TalonSRX, Victor, or VictorSP in the code you write depending on the type you use.
29
-
- You can use 2 motors (left and right), but for this tutorial we will use 4.
26
+
- A Drivetrain needs motor controllers. In our case we will use 4 SparkMax Neos (a brand of controller for motors made by Rev Robotics).
27
+
- You could use other motor controllers such as Victor SPs or Talon SRXs but we will be using SparkMax Neos.
28
+
- If you are using other motor controllers, replace SparkMax with TalonSRX, Victor, or VictorSP in the code you write depending on the type you use.
29
+
- You can use 2 motors (left and right), but for this tutorial we will use 4 since that is what the base Kitbot uses.
30
30
31
31
!!! Tip
32
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.
33
33
34
-
### Creating the Talon Variables
34
+
### Creating the Motor Variables
35
35
36
36
!!! summary ""
37
-
**1)**Create 4 global variables of data type **Talon** and name them: `leftFrontTalon`, `rightFrontTalon`, `leftBackTalon`, `rightBackTalon`
37
+
**1)** At the top of the DriveTrainSubSystem class, create 4 global variables of data type **SparkMax** and name them: `leftLeader`, `rightLeader`, `leftFollower`, `rightFollower`
38
38
39
-
- To get started type the word Talon followed by the name i.e. `#!java Talon leftFrontTalon;`
40
-
- These will eventually hold the object values for Talons and their port numbers.
39
+
- To get started type private final SparkMax followed by the name i.e. `#!java private final SparkMax leftLeader;`
40
+
- These are declared at private and final because they will not be used outside of the drivetrain class, and will not be changing once assigned.
41
+
- These will eventually hold the object values for Neos and their port numbers.
41
42
42
43
!!! summary ""
43
-
**2)** Next assign their values to `#!java null` ([more info on `null`](../basics/java_basics.md#overview){target=_blank}).
44
+
<!--**2)** Next assign their values to `#!java null` ([more info on `null`](../basics/java_basics.md#overview){target=_blank}).-->
45
+
**2)** These will not be Assigned values here.
44
46
45
47
- We do this to make sure it is empty at this point.
46
48
- When we assign these variables a value, we will be getting the motor controller's port numbers out of Constants
@@ -51,10 +53,10 @@ In the Drivetrain class we will tell the subsystem what type of components it wi
51
53
The code you typed should be this:
52
54
53
55
```java
54
-
Talon leftFrontTalon = null;
55
-
Talon leftBackTalon = null;
56
-
Talon rightFrontTalon = null;
57
-
Talon rightBackTalon = null;
56
+
private final SparkMax leftLeader;
57
+
private final SparkMax leftFollower;
58
+
private final SparkMax rightLeader;
59
+
private final SparkMax rightFollower;
58
60
```
59
61
60
62
Your full **Drivetrain.java** should look like this:
@@ -68,14 +70,17 @@ In the Drivetrain class we will tell the subsystem what type of components it wi
68
70
/**
69
71
* Add your docs here.
70
72
*/
71
-
public class Drivetrain extends Subsystem {
72
-
// Put methods for controlling this subsystem
73
-
// here. Call these from Commands.
73
+
public class CANDriveSubsystem extends SubsystemBase {
74
+
private final SparkMax leftLeader;
75
+
private final SparkMax leftLeader;
76
+
private final SparkMax leftFollower;
77
+
private final SparkMax rightLeader;
78
+
private final SparkMax rightFollower;
74
79
75
-
Talon leftFrontTalon = null;
76
-
Talon leftBackTalon = null;
77
-
Talon rightFrontTalon = null;
78
-
Talon rightBackTalon = null;
80
+
81
+
public CANDriveSubsystem() {
82
+
83
+
}
79
84
80
85
@Override
81
86
public void periodic() {
@@ -86,11 +91,11 @@ In the Drivetrain class we will tell the subsystem what type of components it wi
0 commit comments