Skip to content

Commit 98895a1

Browse files
committed
adding ki to velocity
1 parent e617923 commit 98895a1

4 files changed

Lines changed: 26 additions & 19 deletions

File tree

build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ version '1.0-SNAPSHOT'
2525
repositories {
2626
mavenCentral()
2727
maven { url 'https://oss.sonatype.org/content/repositories/staging/' }
28-
//com.neuronrobotics hosting point
29-
maven { url 'https://oss.sonatype.org/content/repositories/staging/' }
3028
}
3129

3230
dependencies {

src/main/java/edu/wpi/rbe/rbe2001/fieldsimulator/gui/InterfaceController.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ public class InterfaceController {
105105

106106
@FXML
107107
private TextField kdVel;
108-
108+
109+
@FXML
110+
private TextField velKiField;
109111
@FXML
110112
private Button pidConstUpdateVelocity;
111113

@@ -551,7 +553,7 @@ private void setFieldSim(ISimplePIDRobot r) {
551553
System.out.print("\r\nPID config update for axis " + currentIndex + " values ");
552554

553555
Platform.runLater(() -> kpVel.setText(formatter.format(robot.getVKp(currentIndex))));
554-
556+
Platform.runLater(() -> velKiField.setText(formatter.format(robot.getVKi(currentIndex))));
555557
Platform.runLater(() -> kdVel.setText(formatter.format(robot.getVKd(currentIndex))));
556558

557559
} catch (Exception ex) {
@@ -629,8 +631,9 @@ void onSetVelocity() {
629631
@FXML
630632
void onSetGainsVelocity() {
631633
double kpv = Double.parseDouble(kpVel.getText());
634+
double kiv = Double.parseDouble(velKiField.getText());
632635
double kdv = Double.parseDouble(kdVel.getText());
633-
robot.setVelocityGains(currentIndex, kpv, kdv);
636+
robot.setVelocityGains(currentIndex, kpv, kiv,kdv);
634637
}
635638

636639
@FXML

src/main/java/edu/wpi/rbe/rbe2001/fieldsimulator/robot/ISimplePIDRobot.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,13 @@ default public double getVKd(int index) {
162162
readFloats(GetPDVelocityConstants.idOfCommand, pidVelConfigData);
163163
return pidVelConfigData[(3 * index) + 2];
164164
}
165-
166-
default public void setVelocityGains(int index, double kp, double kd) {
165+
default public double getVKi(int index) {
166+
readFloats(GetPDVelocityConstants.idOfCommand, pidVelConfigData);
167+
return pidVelConfigData[(3 * index) + 1];
168+
}
169+
default public void setVelocityGains(int index, double kp, double ki,double kd) {
167170
pidVelConfigData[3 * index + 0] = kp;
168-
pidVelConfigData[3 * index + 1] = 0;
171+
pidVelConfigData[3 * index + 1] = ki;
169172
pidVelConfigData[3 * index + 2] = kd;
170173
writeFloats(SetPDVelocityConstants.idOfCommand, pidVelConfigData);
171174
SetPDVelocityConstants.oneShotMode();

src/main/resources/fxml/MainScreen.fxml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<rowConstraints>
121121
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
122122
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
123+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
123124
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
124125
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
125126
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
@@ -129,28 +130,30 @@
129130
</rowConstraints>
130131
<children>
131132
<Label text="Kp" GridPane.rowIndex="1" />
132-
<Label text="Kd" GridPane.rowIndex="2" />
133+
<Label text="Kd" GridPane.rowIndex="3" />
133134
<TextField fx:id="kpVel" onAction="#onSetGainsVelocity" text="1.0" GridPane.columnIndex="2" GridPane.rowIndex="1" />
134-
<TextField fx:id="kdVel" onAction="#onSetGainsVelocity" text="0.0" GridPane.columnIndex="2" GridPane.rowIndex="2" />
135-
<Button fx:id="pidConstUpdateVelocity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#onSetGainsVelocity" prefHeight="25.0" prefWidth="89.0" text="Set Gains" GridPane.columnIndex="3" GridPane.rowIndex="3" />
135+
<TextField fx:id="kdVel" onAction="#onSetGainsVelocity" text="0.0" GridPane.columnIndex="2" GridPane.rowIndex="3" />
136+
<Button fx:id="pidConstUpdateVelocity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onAction="#onSetGainsVelocity" prefHeight="25.0" prefWidth="89.0" text="Set Gains" GridPane.columnIndex="3" GridPane.rowIndex="4" />
136137
<ChoiceBox fx:id="pidChannelVelocity" prefWidth="150.0" GridPane.columnIndex="2" />
137-
<TextField fx:id="setpointVelocity" text="0.0" GridPane.columnIndex="2" GridPane.rowIndex="4" />
138-
<Button fx:id="setSetpointVelocity" mnemonicParsing="false" onAction="#onSetVelocity" text="Set" GridPane.columnIndex="3" GridPane.rowIndex="4" />
138+
<TextField fx:id="setpointVelocity" text="0.0" GridPane.columnIndex="2" GridPane.rowIndex="5" />
139+
<Button fx:id="setSetpointVelocity" mnemonicParsing="false" onAction="#onSetVelocity" text="Set" GridPane.columnIndex="3" GridPane.rowIndex="5" />
139140
<Label prefHeight="17.0" prefWidth="67.0" text="Channel" />
140-
<Label text="Set Velocity" GridPane.rowIndex="4" />
141-
<Label text="Velocity" GridPane.rowIndex="5" />
142-
<Label fx:id="velocityVal" text="0.0" GridPane.columnIndex="2" GridPane.halignment="LEFT" GridPane.rowIndex="5">
141+
<Label text="Set Velocity" GridPane.rowIndex="5" />
142+
<Label text="Velocity" GridPane.rowIndex="6" />
143+
<Label fx:id="velocityVal" text="0.0" GridPane.columnIndex="2" GridPane.halignment="LEFT" GridPane.rowIndex="6">
143144
<padding>
144145
<Insets left="9.0" />
145146
</padding>
146147
</Label>
147-
<Label text="Hardware Value" GridPane.rowIndex="6" />
148-
<Label fx:id="hardwareOut" text="0.0" GridPane.columnIndex="2" GridPane.halignment="LEFT" GridPane.rowIndex="6">
148+
<Label text="Hardware Value" GridPane.rowIndex="7" />
149+
<Label fx:id="hardwareOut" text="0.0" GridPane.columnIndex="2" GridPane.halignment="LEFT" GridPane.rowIndex="7">
149150
<padding>
150151
<Insets left="9.0" />
151152
</padding>
152153
</Label>
153-
<Button fx:id="velExport" mnemonicParsing="false" onAction="#onVelExport" text="Export CSV..." GridPane.columnIndex="3" GridPane.rowIndex="7" />
154+
<Button fx:id="velExport" mnemonicParsing="false" onAction="#onVelExport" text="Export CSV..." GridPane.columnIndex="3" GridPane.rowIndex="8" />
155+
<Label text="Ki" GridPane.rowIndex="2" />
156+
<TextField fx:id="velKiField" text="0.0" GridPane.columnIndex="2" GridPane.rowIndex="2" />
154157
</children>
155158
</GridPane>
156159
</children>

0 commit comments

Comments
 (0)