Skip to content

Commit e9f75be

Browse files
committed
Merge pull request #238 from WPIRoboticsProjects/revert-222-nt
Revert "NetworkTables"
2 parents 03c36b8 + 666fd24 commit e9f75be

28 files changed

+50
-570
lines changed

build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ project(":core") {
9191
repositories {
9292
flatDir {
9393
dirs 'libs'
94-
maven {
95-
url = "http://first.wpi.edu/FRC/roborio/maven/development"
96-
}
9794
}
9895
}
9996

@@ -109,7 +106,6 @@ project(":core") {
109106
compile group: 'com.google.guava', name: 'guava', version: '18.0'
110107
compile group: 'com.google.inject', name: 'guice', version: '4.0'
111108
compile group: 'com.google.inject.extensions', name: 'guice-assistedinject', version: '4.0'
112-
compile group: 'edu.wpi.first.wpilib.networktables.java', name: 'NetworkTables', version: '3.0.0-SNAPSHOT', classifier: 'desktop'
113109
}
114110

115111
mainClassName = 'edu.wpi.grip.core.Main'

buildSrc/src/main/java/edu/wpi/gripgenerator/defaults/PrimitiveDefaultValue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,28 @@ public PrimitiveDefaultValue(PrimitiveType type) {
4545
);
4646
break;
4747
case Int:
48-
this.viewValue = "TEXT";
48+
this.viewValue = "SPINNER";
4949
this.domainValue = createDomainValueExpression(
5050
new IntegerLiteralExpr("Integer.MIN_VALUE"),
5151
new IntegerLiteralExpr("Integer.MAX_VALUE")
5252
);
5353
break;
5454
case Float:
55-
this.viewValue = "TEXT";
55+
this.viewValue = "SPINNER";
5656
this.domainValue = createDomainValueExpression(
5757
new DoubleLiteralExpr("-Float.MAX_VALUE"),
5858
new DoubleLiteralExpr("Float.MAX_VALUE")
5959
);
6060
break;
6161
case Double:
62-
this.viewValue = "TEXT";
62+
this.viewValue = "SPINNER";
6363
this.domainValue = createDomainValueExpression(
6464
new DoubleLiteralExpr("-Double.MAX_VALUE"),
6565
new DoubleLiteralExpr("Double.MAX_VALUE")
6666
);
6767
break;
6868
case Char:
69-
this.viewValue = "TEXT";
69+
this.viewValue = "SPINNER";
7070
this.domainValue = createDomainValueExpression(
7171
new CharLiteralExpr(Character.toString(Character.MIN_VALUE)),
7272
new CharLiteralExpr(Character.toString(Character.MAX_VALUE))

core/src/main/java/edu/wpi/grip/core/Operation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ default void perform(InputSocket<?>[] inputs, OutputSocket<?>[] outputs, Optiona
6161
perform(inputs, outputs);
6262
}
6363

64+
@Deprecated
6465
default void perform(InputSocket<?>[] inputs, OutputSocket<?>[] outputs) {
6566
throw new UnsupportedOperationException("Perform was not overridden");
6667
}

core/src/main/java/edu/wpi/grip/core/Pipeline.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,14 @@ public class Pipeline {
3232
private final List<Source> sources = new ArrayList<>();
3333
private final List<Step> steps = new ArrayList<>();
3434
private final Set<Connection> connections = new HashSet<>();
35-
private ProjectSettings settings = new ProjectSettings();
3635

3736
/**
3837
* Remove everything in the pipeline
3938
*/
4039
public void clear() {
4140
// These streams are both collected into lists because streams cannot modify their source. Sending a
4241
// StepRemovedEvent or SourceRemovedEvent modifies this.steps or this.sources.
43-
this.steps.stream()
44-
.map(StepRemovedEvent::new)
45-
.collect(Collectors.toList())
46-
.forEach(this.eventBus::post);
42+
this.steps.stream().collect(Collectors.toList()).forEach(this::removeStep);
4743

4844
this.sources.stream()
4945
.map(SourceRemovedEvent::new)
@@ -73,15 +69,6 @@ public Set<Connection> getConnections() {
7369
return Collections.unmodifiableSet(this.connections);
7470
}
7571

76-
/*
77-
* @return The current per-project settings. This object may become out of date if the settings are edited
78-
* by the user, so objects requiring a preference value should also subscribe to {@link ProjectSettingsChangedEvent}
79-
* to get updates.
80-
*/
81-
public ProjectSettings getProjectSettings() {
82-
return settings;
83-
}
84-
8572
/**
8673
* @return true if a connection can be made from the given output socket to the given input socket
8774
*/
@@ -196,9 +183,4 @@ public void onConnectionRemoved(ConnectionRemovedEvent event) {
196183
this.connections.remove(event.getConnection());
197184
this.eventBus.unregister(event.getConnection());
198185
}
199-
200-
@Subscribe
201-
public void onProjectSettingsChanged(ProjectSettingsChangedEvent event) {
202-
this.settings = event.getProjectSettings();
203-
}
204186
}

core/src/main/java/edu/wpi/grip/core/ProjectSettings.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

core/src/main/java/edu/wpi/grip/core/SocketHint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* interface to learn how to talk to <code>Algorithm</code>s.
1616
*/
1717
public class SocketHint<T> {
18-
public enum View {NONE, TEXT, SLIDER, RANGE, SELECT, CHECKBOX}
18+
public enum View {NONE, SPINNER, SLIDER, RANGE, SELECT, CHECKBOX}
1919

2020
private final String identifier;
2121
private final Class<T> type;

core/src/main/java/edu/wpi/grip/core/SocketHints.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,18 @@ public static SocketHint<Number> createNumberSliderSocketHint(final String ident
4343

4444
public static SocketHint<Number> createNumberSpinnerSocketHint(final String identifier, final Number number,
4545
final Number low, final Number high) {
46-
return createNumberSocketHintBuilder(identifier, number, new Number[]{low, high}).view(SocketHint.View.TEXT).build();
46+
return createNumberSocketHintBuilder(identifier, number, new Number[]{low, high}).view(SocketHint.View.SPINNER).build();
4747
}
4848

4949
public static SocketHint<Number> createNumberSpinnerSocketHint(final String identifier, final Number number) {
50-
return createNumberSocketHintBuilder(identifier, number).view(SocketHint.View.TEXT).build();
50+
return createNumberSocketHintBuilder(identifier, number).view(SocketHint.View.SPINNER).build();
5151
}
5252

5353
public static SocketHint<List> createNumberListRangeSocketHint(final String identifier, final Number low, final Number high) {
5454
return createNumberListSocketHintBuilder(identifier, new Number[]{low, high})
5555
.view(SocketHint.View.RANGE)
5656
.build();
5757
}
58-
59-
public static SocketHint<String> createTextSocketHint(final String identifier, final String str) {
60-
return new SocketHint.Builder<>(String.class)
61-
.identifier(identifier)
62-
.initialValue(str)
63-
.view(SocketHint.View.TEXT)
64-
.build();
65-
}
6658
}
6759

6860
/**
@@ -92,6 +84,7 @@ public static SocketHint<Number> createNumberSocketHint(final String identifier,
9284
}
9385
}
9486

87+
@SuppressWarnings("unchecked")
9588
public static <T extends Enum<T>> SocketHint<T> createEnumSocketHint(final String identifier,
9689
final T defaultValue) {
9790
return new SocketHint.Builder(defaultValue.getClass())

core/src/main/java/edu/wpi/grip/core/events/ProjectSettingsChangedEvent.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

core/src/main/java/edu/wpi/grip/core/operations/Operations.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package edu.wpi.grip.core.operations;
22

33
import com.google.common.eventbus.EventBus;
4-
import edu.wpi.grip.core.Operation;
54
import edu.wpi.grip.core.events.OperationAddedEvent;
65
import edu.wpi.grip.core.operations.composite.*;
7-
import edu.wpi.grip.core.operations.networktables.NTPublishOperation;
86
import edu.wpi.grip.core.operations.opencv.MatFieldAccessor;
97
import edu.wpi.grip.core.operations.opencv.MinMaxLoc;
108
import edu.wpi.grip.core.operations.opencv.NewPointOperation;
@@ -32,9 +30,5 @@ public static void addOperations(EventBus eventBus) {
3230
eventBus.post(new OperationAddedEvent(new NewPointOperation()));
3331
eventBus.post(new OperationAddedEvent(new NewSizeOperation()));
3432
eventBus.post(new OperationAddedEvent(new MatFieldAccessor()));
35-
36-
Operation publishContours = new NTPublishOperation<>(ContoursReport.class);
37-
eventBus.register(publishContours);
38-
eventBus.post(new OperationAddedEvent(publishContours));
3933
}
4034
}
Lines changed: 15 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,18 @@
11
package edu.wpi.grip.core.operations.composite;
22

3-
import edu.wpi.grip.core.operations.networktables.NTPublishable;
4-
import edu.wpi.grip.core.operations.networktables.NTValue;
5-
6-
import java.util.ArrayList;
7-
import java.util.List;
8-
import java.util.Optional;
9-
10-
import static org.bytedeco.javacpp.opencv_core.MatVector;
11-
import static org.bytedeco.javacpp.opencv_core.Rect;
12-
import static org.bytedeco.javacpp.opencv_imgproc.boundingRect;
13-
import static org.bytedeco.javacpp.opencv_imgproc.contourArea;
3+
import static org.bytedeco.javacpp.opencv_core.*;
144

155
/**
166
* The output of {@link FindContoursOperation}. This stores a list of contours (which is basically a list of points) in
177
* OpenCV objects, as well as the width and height of the image that the contours are from, to give context to the
188
* points.
199
*/
20-
public final class ContoursReport implements NTPublishable {
21-
private final int rows, cols;
22-
private final MatVector contours;
23-
private Optional<List<Rect>> boundingBoxes = Optional.empty();
10+
public final class ContoursReport {
11+
private int rows, cols;
12+
private MatVector contours = new MatVector();
2413

25-
/**
26-
* Construct an empty report. This is used as a default value for {@link edu.wpi.grip.core.Socket}s containing
27-
* ContoursReports.
28-
*/
2914
public ContoursReport() {
30-
this(new MatVector(), 0, 0);
15+
this(new MatVector(), -1, -1);
3116
}
3217

3318
public ContoursReport(MatVector contours, int rows, int cols) {
@@ -36,81 +21,27 @@ public ContoursReport(MatVector contours, int rows, int cols) {
3621
this.cols = cols;
3722
}
3823

39-
public int getRows() {
40-
return this.rows;
41-
}
42-
43-
public int getCols() {
44-
return this.cols;
24+
public void setContours(MatVector contours) {
25+
this.contours = contours;
4526
}
4627

4728
public MatVector getContours() {
4829
return this.contours;
4930
}
5031

51-
/**
52-
* Compute the bounding boxes of all contours (if they haven't already been computed). Bounding boxes are used
53-
* to compute several different properties, so it's probably not a good idea to compute them over and over again.
54-
*/
55-
private synchronized List<Rect> computeBoundingBoxes() {
56-
if (!boundingBoxes.isPresent()) {
57-
List<Rect> bb = new ArrayList<>();
58-
for (int i = 0; i < contours.size(); i++) {
59-
bb.add(boundingRect(contours.get(i)));
60-
}
61-
62-
boundingBoxes = Optional.of(bb);
63-
}
64-
65-
return boundingBoxes.get();
66-
}
67-
68-
@NTValue(key = "area")
69-
public double[] getArea() {
70-
final double[] areas = new double[(int) contours.size()];
71-
for (int i = 0; i < contours.size(); i++) {
72-
areas[i] = contourArea(contours.get(i));
73-
}
74-
return areas;
75-
}
76-
77-
@NTValue(key = "centerX")
78-
public double[] getCenterX() {
79-
final double[] centers = new double[(int) contours.size()];
80-
final List<Rect> boundingBoxes = computeBoundingBoxes();
81-
for (int i = 0; i < contours.size(); i++) {
82-
centers[i] = boundingBoxes.get(i).x() + boundingBoxes.get(i).width() / 2;
83-
}
84-
return centers;
32+
public void setRows(int rows) {
33+
this.rows = rows;
8534
}
8635

87-
@NTValue(key = "centerY")
88-
public double[] getCenterY() {
89-
final double[] centers = new double[(int) contours.size()];
90-
final List<Rect> boundingBoxes = computeBoundingBoxes();
91-
for (int i = 0; i < contours.size(); i++) {
92-
centers[i] = boundingBoxes.get(i).y() + boundingBoxes.get(i).height() / 2;
93-
}
94-
return centers;
36+
public void setCols(int cols) {
37+
this.cols = cols;
9538
}
9639

97-
@NTValue(key = "width")
98-
public synchronized double[] getWidth() {
99-
final double[] widths = new double[(int) contours.size()];
100-
final List<Rect> boundingBoxes = computeBoundingBoxes();
101-
for (int i = 0; i < contours.size(); i++) {
102-
widths[i] = boundingBoxes.get(i).width();
103-
}
104-
return widths;
40+
public int getRows() {
41+
return this.rows;
10542
}
10643

107-
@NTValue(key = "height")
108-
public synchronized double[] getHeights() {
109-
final double[] heights = new double[(int) contours.size()];
110-
final List<Rect> boundingBoxes = computeBoundingBoxes();
111-
for (int i = 0; i < contours.size(); i++) {
112-
heights[i] = boundingBoxes.get(i).height();
113-
}
114-
return heights;
44+
public int getCols() {
45+
return this.cols;
11546
}
11647
}

0 commit comments

Comments
 (0)