Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "Make SimpleNote serializable for AScope"" #286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class SimpleNote implements StructSerializable {
final double yaw;
final double pitch;

public static final SimpleNoteStruct struct = new SimpleNoteStruct();

public SimpleNote(double area, double yaw, double pitch) {
this.area = area;
this.yaw = yaw;
Expand All @@ -21,5 +23,7 @@ public double getYaw() {
return yaw;
}

public double getPitch() { return pitch; }
public double getPitch() {
return pitch;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package competition.subsystems.vision;

import edu.wpi.first.util.struct.Struct;

import java.nio.ByteBuffer;

public class SimpleNoteStruct implements Struct<SimpleNote> {
@Override
public Class<SimpleNote> getTypeClass() {
return SimpleNote.class;
}

@Override
public String getTypeString() {
return "struct:SimpleNote";
}

@Override
public int getSize() {
return kSizeDouble * 3;
}

@Override
public String getSchema() {
return "double area; double yaw; double pitch";
}

@Override
public SimpleNote unpack(ByteBuffer byteBuffer) {
var area = byteBuffer.getDouble();
var yaw = byteBuffer.getDouble();
var pitch = byteBuffer.getDouble();
return new SimpleNote(area, yaw, pitch);
}

@Override
public void pack(ByteBuffer byteBuffer, SimpleNote simpleNote) {
byteBuffer.putDouble(simpleNote.getArea());
byteBuffer.putDouble(simpleNote.getYaw());
byteBuffer.putDouble(simpleNote.getPitch());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ public void periodic() {
}, () -> {
aKitLog.record("CenterCamLargestTargetArea", -1.0);
aKitLog.record("CenterCamLargestTargetYaw", 0.0);
aKitLog.record("CenterCamLargestTargetPitch", 0);
aKitLog.record("CenterCamLargestTargetPitch", 0.0);
});

// aKitLog.record("CenterlineDetections", centerlineDetections);
aKitLog.record("CenterlineDetections", centerlineDetections);
aKitLog.record("DetectedNotes", detectedNotes);
aKitLog.record("PassiveDetectedNotes", passiveDetectedNotes);
}
Expand Down
Loading