Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit 5b2bb52

Browse files
fudge factor
1 parent 255ca24 commit 5b2bb52

4 files changed

Lines changed: 83 additions & 7 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/RobotMap.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,8 @@ private double convertNtokG(double newtons) {
285285
// weight / accel due to grav = kg
286286
return newtons / 9.81;
287287
}
288+
289+
public double convertMtoIn(double meters) {
290+
return meters * 39.37;
291+
}
288292
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDMove.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ protected double calculateFeedForward() {
6161
double originalFF = super.calculateFeedForward();
6262
double feedForwardConst = dt.getPIDMoveConstant();
6363
double error = getError();
64-
return Math.signum(error) * feedForwardConst * Math.sqrt(Math.abs(error)) + originalFF;
64+
return (Math.signum(error) * feedForwardConst * Math.sqrt(Math.abs(error)) + originalFF)
65+
/ dt.getCurrentMaxSpeed();
6566
}
6667
};
6768
sd.putData("Move PID", moveController);
@@ -109,7 +110,8 @@ protected double calculateFeedForward() {
109110
double originalFF = super.calculateFeedForward();
110111
double feedForwardConst = dt.getPIDMoveConstant();
111112
double error = getError();
112-
return Math.signum(error) * feedForwardConst * Math.sqrt(Math.abs(error)) + originalFF;
113+
return (Math.signum(error) * feedForwardConst * Math.sqrt(Math.abs(error)) + originalFF)
114+
/ dt.getCurrentMaxSpeed();
113115
}
114116
};
115117
sd.putData("Move PID", moveController);

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/Drivetrain.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,17 +420,21 @@ public void putVelocityControllersToDashboard() {
420420
public double getPIDMoveConstant() {
421421
double G = Robot.rmap.getGearRatio();
422422
double T = Robot.rmap.getStallTorque();
423+
double fudge = Robot.getConst("PID Move Fudge Factor", 0.25);
424+
T *= fudge;
423425
double R = Robot.rmap.getRadius();
424426
double M = Robot.rmap.getWeight();
425-
return Math.sqrt((8 * T * G) / (R * M));
427+
M = convertNtokG(M);
428+
return Math.sqrt(Robot.rmap.convertMtoIn((8 * T * G) / (R * M)));
426429
}
427430

428431
public double getPIDTurnConstant() {
429432
double G = Robot.rmap.getGearRatio();
430433
double T = Robot.rmap.getStallTorque();
431434
double R = Robot.rmap.getRadius();
432435
double M = Robot.rmap.getWeight();
433-
return 4 * Math.sqrt((T * G) / (R * M));
436+
M = convertNtokG(M);
437+
return 4 * Math.sqrt(Robot.rmap.convertMtoIn((T * G) / (R * M)));
434438
}
435439

436440
private double convertNtokG(double newtons) {

shuffleboard.json

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"dividerPosition": 0.45234604105571846,
2+
"dividerPosition": 0.4530791788856305,
33
"tabPane": [
44
{
55
"title": "PID Testing",
@@ -541,7 +541,7 @@
541541
}
542542
},
543543
{
544-
"title": "Tab 5",
544+
"title": "PID Constants",
545545
"autoPopulate": false,
546546
"autoPopulatePrefix": "",
547547
"widgetPane": {
@@ -583,7 +583,7 @@
583583
"_title": "Preferences/Const/TurnkP"
584584
}
585585
},
586-
"1,0": {
586+
"4,0": {
587587
"size": [
588588
1,
589589
1
@@ -593,6 +593,72 @@
593593
"_source0": "network_table:///Preferences/Const/Output",
594594
"_title": "Preferences/Const/Output"
595595
}
596+
},
597+
"2,0": {
598+
"size": [
599+
1,
600+
1
601+
],
602+
"content": {
603+
"_type": "Text View",
604+
"_source0": "network_table:///Preferences/Const/MovekP",
605+
"_title": "Preferences/Const/MovekP"
606+
}
607+
},
608+
"2,1": {
609+
"size": [
610+
1,
611+
1
612+
],
613+
"content": {
614+
"_type": "Text View",
615+
"_source0": "network_table:///Preferences/Const/MovekI",
616+
"_title": "Preferences/Const/MovekI"
617+
}
618+
},
619+
"2,2": {
620+
"size": [
621+
1,
622+
1
623+
],
624+
"content": {
625+
"_type": "Text View",
626+
"_source0": "network_table:///Preferences/Const/MovekD",
627+
"_title": "/Preferences/Const/MovekD"
628+
}
629+
},
630+
"2,3": {
631+
"size": [
632+
1,
633+
1
634+
],
635+
"content": {
636+
"_type": "Text View",
637+
"_source0": "network_table:///Preferences/Const/MoveTolerance",
638+
"_title": "Preferences/Const/MoveTolerance"
639+
}
640+
},
641+
"0,3": {
642+
"size": [
643+
1,
644+
1
645+
],
646+
"content": {
647+
"_type": "Text View",
648+
"_source0": "network_table:///Preferences/Const/TurnTolerance",
649+
"_title": "Preferences/Const/TurnTolerance"
650+
}
651+
},
652+
"4,1": {
653+
"size": [
654+
1,
655+
1
656+
],
657+
"content": {
658+
"_type": "Text View",
659+
"_source0": "network_table:///Preferences/Const/Weight of Robot",
660+
"_title": "Preferences/Const/Weight of Robot"
661+
}
596662
}
597663
}
598664
}

0 commit comments

Comments
 (0)