generated from Team488/FRCRobotTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make SimpleNote serializable for AScope (#280)
* Make SimpleNote serializable for AScope * Remove unintended import --------- Co-authored-by: Alex Schokking <[email protected]>
- Loading branch information
1 parent
108ef70
commit 3c15c1c
Showing
3 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/competition/subsystems/vision/SimpleNoteStruct.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters