-
Notifications
You must be signed in to change notification settings - Fork 0
/
0001-Drivetrain-motors-and-other.patch
378 lines (375 loc) · 12.5 KB
/
0001-Drivetrain-motors-and-other.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
From 3061171738ed9d654af9ced917c48f2348fad0ba Mon Sep 17 00:00:00 2001
From: Julianna Dukart <[email protected]>
Date: Thu, 23 Jan 2020 19:05:31 -0600
Subject: [PATCH] Drivetrain motors and other
percent output, motors, velocity, drivetrain basic stuff and constants encoders stuff
---
src/main/java/frc/robot/Constants.java | 14 ++
.../java/frc/robot/subsystems/Drivetrain.java | 102 ++++++++++
vendordeps/Phoenix.json | 180 ++++++++++++++++++
vendordeps/navx_frc.json | 34 ++++
4 files changed, 330 insertions(+)
create mode 100644 src/main/java/frc/robot/subsystems/Drivetrain.java
create mode 100644 vendordeps/Phoenix.json
create mode 100644 vendordeps/navx_frc.json
diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java
index cf0c82e..c036327 100644
--- a/src/main/java/frc/robot/Constants.java
+++ b/src/main/java/frc/robot/Constants.java
@@ -16,4 +16,18 @@ package com.frc2491.clank;
* constants are needed, to reduce verbosity.
*/
public final class Constants {
+ //drive
+ public final static int driveTalonLeftMotor1 = 0;
+ public final static int driveTalonLeftMotor2 = 0;
+ public final static int driveTalonRightMotor1 = 0;
+ public final static int driveTalonRightMotor2 = 0; //0 should be replaced
+
+ //encoders
+ public final static double encoderTicks = 2048.0; //encoder ticks per wheel rotation is 2048
+ public final static double wheelDiameter = 6.0;
+ public final static double driveEncoderToInches = 1 / wheelDiameter * Math.PI / encoderTicks; //makes number inches
+ public final static double speedModeRPSToTalonOutput = encoderTicks / 10.0;
+ public final static double driveEncoderVelocityToRPS = 1.0 / encoderTicks * 10;
+ public final static double driveMaxSpeedRPS = 8.0;
}
+
diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java
new file mode 100644
index 0000000..944f769
--- /dev/null
+++ b/src/main/java/frc/robot/subsystems/Drivetrain.java
@@ -0,0 +1,102 @@
+
+/*----------------------------------------------------------------------------*/
+/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* Open Source Software - may be modified and shared by FRC teams. The code */
+/* must be accompanied by the FIRST BSD license file in the root directory of */
+/* the project. */
+/*----------------------------------------------------------------------------*/
+
+package com.frc2491.clank.subsystems;
+
+import edu.wpi.first.wpilibj2.command.SubsystemBase;
+import com.frc2491.clank.Constants;
+import com.ctre.phoenix.motorcontrol.ControlMode;
+import com.ctre.phoenix.motorcontrol.can.TalonFX;
+
+public class Drivetrain extends SubsystemBase {
+ private TalonFX driveLeftMotor1,driveLeftMotor2,driveRightMotor1,driveRightMotor2;
+
+ public Drivetrain() {
+
+ //creating motors
+ driveLeftMotor1 = new TalonFX(Constants.driveTalonLeftMotor1);
+ driveLeftMotor2 = new TalonFX(Constants.driveTalonLeftMotor2);
+ driveRightMotor1 = new TalonFX(Constants.driveTalonRightMotor1);
+ driveRightMotor2 = new TalonFX(Constants.driveTalonRightMotor2);
+
+ //making right motors go right
+ driveRightMotor1.setInverted(true);
+ driveRightMotor2.setInverted(true);
+ driveLeftMotor1.setInverted(false);
+ driveLeftMotor2.setInverted(false);
+ }
+
+
+
+ //creating percent output for both right and left
+ public void drivePercentOutput(double speed){
+ drivePercentOutput(speed, speed);
+ }
+ public void drivePercentOutput(double leftSpeed, double rightSpeed){
+ driveLeftPercentOutput(leftSpeed);
+ driveRightPercentOutput(rightSpeed);
+ }
+ public void driveLeftPercentOutput(double speed){
+ driveLeftMotor1.set(ControlMode.PercentOutput, speed);
+ }
+ public void driveRightPercentOutput(double speed){
+ driveRightMotor1.set(ControlMode.PercentOutput, speed);
+ }
+
+ //creating drive velocity for both right and left
+ public void driveVelocity(double speed){
+ driveVelocity(speed, speed);
+ }
+ public void driveVelocity(double leftSpeed, double rightSpeed){
+ driveLeftVelocity(leftSpeed);
+ driveRightVelocity(rightSpeed);
+ }
+ public void driveLeftVelocity(double speed){
+ driveLeftMotor1.set(ControlMode.Velocity, speed);
+ }
+ public void driveRightVelocity(double speed){
+ driveRightMotor1.set(ControlMode.Velocity, speed);
+
+ }
+
+ //robot can stop
+ public void stop(){
+ driveVelocity(0, 0);
+ }
+
+ //getting encoder distance and rate
+ public double getRightEncoderDistance() {
+ return driveRightMotor1.getSelectedSensorPosition(0) * Constants.driveEncoderToInches;
+ }
+ public double getLeftEncoderDistance() {
+ return driveLeftMotor1.getSelectedSensorPosition(0) * Constants.driveEncoderToInches;
+ }
+ public double getLeftEncoderDistanceRaw() {
+ return driveLeftMotor1.getSelectedSensorPosition(0);
+ }
+ public double getRightEncoderDistanceRaw() {
+ return driveRightMotor1.getSelectedSensorPosition(0);
+ }
+ public double getEncoderDistance() {
+ return ((getLeftEncoderDistance() + getRightEncoderDistance()) / 2);
+ }
+ public double getLeftEncoderRate() {
+ return driveLeftMotor1.getSelectedSensorVelocity(0) * Constants.driveEncoderVelocityToRPS;
+ }
+ public double getRightEncoderRate() {
+ return driveRightMotor1.getSelectedSensorVelocity(0) * Constants.driveEncoderVelocityToRPS;
+ }
+ public double getEncoderRate() {
+ return ((getRightEncoderRate() + getLeftEncoderRate()) / 2);
+ }
+
+ @Override
+ public void periodic() {
+ // This method will be called once per scheduler run
+ }
+}
diff --git a/vendordeps/Phoenix.json b/vendordeps/Phoenix.json
new file mode 100644
index 0000000..a633555
--- /dev/null
+++ b/vendordeps/Phoenix.json
@@ -0,0 +1,180 @@
+{
+ "fileName": "Phoenix.json",
+ "name": "CTRE-Phoenix",
+ "version": "5.17.4",
+ "uuid": "ab676553-b602-441f-a38d-f1296eff6537",
+ "mavenUrls": [
+ "http://devsite.ctr-electronics.com/maven/release/"
+ ],
+ "jsonUrl": "http://devsite.ctr-electronics.com/maven/release/com/ctre/phoenix/Phoenix-latest.json",
+ "javaDependencies": [
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "api-java",
+ "version": "5.17.4"
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "wpiapi-java",
+ "version": "5.17.4"
+ }
+ ],
+ "jniDependencies": [
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "cci",
+ "version": "5.17.4",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "diagnostics",
+ "version": "5.17.4",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "canutils",
+ "version": "5.17.4",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "platform-stub",
+ "version": "5.17.4",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "core",
+ "version": "5.17.4",
+ "isJar": false,
+ "skipInvalidPlatforms": true,
+ "validPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ }
+ ],
+ "cppDependencies": [
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "wpiapi-cpp",
+ "version": "5.17.4",
+ "libName": "CTRE_Phoenix_WPI",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "api-cpp",
+ "version": "5.17.4",
+ "libName": "CTRE_Phoenix",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "cci",
+ "version": "5.17.4",
+ "libName": "CTRE_PhoenixCCI",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "diagnostics",
+ "version": "5.17.4",
+ "libName": "CTRE_PhoenixDiagnostics",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "canutils",
+ "version": "5.17.4",
+ "libName": "CTRE_PhoenixCanutils",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "platform-stub",
+ "version": "5.17.4",
+ "libName": "CTRE_PhoenixPlatform",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ },
+ {
+ "groupId": "com.ctre.phoenix",
+ "artifactId": "core",
+ "version": "5.17.4",
+ "libName": "CTRE_PhoenixCore",
+ "headerClassifier": "headers",
+ "sharedLibrary": false,
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "linuxathena",
+ "windowsx86-64",
+ "linuxx86-64"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/vendordeps/navx_frc.json b/vendordeps/navx_frc.json
new file mode 100644
index 0000000..92f9c03
--- /dev/null
+++ b/vendordeps/navx_frc.json
@@ -0,0 +1,34 @@
+{
+ "fileName": "navx_frc.json",
+ "name": "KauaiLabs_navX_FRC",
+ "version": "3.1.391",
+ "uuid": "cb311d09-36e9-4143-a032-55bb2b94443b",
+ "mavenUrls": [
+ "https://repo1.maven.org/maven2/"
+ ],
+ "jsonUrl": "https://www.kauailabs.com/dist/frc/2020/navx_frc.json",
+ "javaDependencies": [
+ {
+ "groupId": "com.kauailabs.navx.frc",
+ "artifactId": "navx-java",
+ "version": "3.1.391"
+ }
+ ],
+ "jniDependencies": [],
+ "cppDependencies": [
+ {
+ "groupId": "com.kauailabs.navx.frc",
+ "artifactId": "navx-cpp",
+ "version": "3.1.391",
+ "headerClassifier": "headers",
+ "sourcesClassifier": "sources",
+ "sharedLibrary": false,
+ "libName": "navx_frc",
+ "skipInvalidPlatforms": true,
+ "binaryPlatforms": [
+ "linuxathena",
+ "linuxraspbian"
+ ]
+ }
+ ]
+}
\ No newline at end of file
--
2.25.0.windows.1