Skip to content

Commit

Permalink
parsejson edits (pt 1)
Browse files Browse the repository at this point in the history
also prepare for release
gonna frick this up
  • Loading branch information
mliang321cba committed May 24, 2024
1 parent 6641999 commit ca561f9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions 3128-Common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3128-common",
"version": "1.7.6",
"version": "1.7.7",
"uuid": "ae3fa5a2-78d9-47e8-921a-dba45b889445",
"frcYear": "2024",
"mavenUrls": [
Expand All @@ -12,7 +12,7 @@
{
"groupId": "com.github.Team3128",
"artifactId": "3128-common",
"version": "1.7.6"
"version": "1.7.7"
}
],
"jniDependencies": [],
Expand Down
4 changes: 2 additions & 2 deletions 3128-common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "3128-common",
"version": "1.7.6",
"version": "1.7.7",
"uuid": "ae3fa5a2-78d9-47e8-921a-dba45b889445",
"frcYear": "2024",
"mavenUrls": [
Expand All @@ -12,7 +12,7 @@
{
"groupId": "com.github.Team3128",
"artifactId": "3128-common",
"version": "1.7.6"
"version": "1.7.7"
}
],
"jniDependencies": [],
Expand Down
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h1 class="title">3128-common</h1>
</div>
<div class="block"><h1>FRC Team 3128 Robot Control Program Utility Library</h1>
<p>Provides utility classes and functions for FRC robot control programs.</p>
<p>Version 1.7.6 (May 14 2024)</p></div>
<p>Version 1.7.7 (May 24 2024)</p></div>
<div id="all-packages-table">
<div class="caption"><span>Packages</span></div>
<div class="summary-table two-column-summary">
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LibraryVersion=1.7.6
LibraryVersion=1.7.7
archivesGroup = com.github.Team3128
archivesBaseName = 3128-common
jsonFileName = 3128-common.json
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/common/hardware/camera/ParseJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class ParseJson {

HashMap<Integer, Pose3d> offseasonTags = new HashMap<Integer, Pose3d>();
HashMap<Integer, Pose3d> aprilTags = new HashMap<Integer, Pose3d>();
public ParseJson(String filepath){

Object obj = new Object();
Expand All @@ -37,31 +37,31 @@ public ParseJson(String filepath){
// typecasting obj to JSONObject
JSONObject jo = (JSONObject) obj;

JSONArray poses = ((JSONArray) jo.get("tags"));
JSONArray tags = ((JSONArray) jo.get("tags"));


for (int i = 0; i < poses.size(); i++) {
JSONObject tag = (JSONObject) poses.get(i);
for (int i = 0; i < tags.size(); i++) {
JSONObject tag = (JSONObject) tags.get(i);
JSONObject pose = (JSONObject) tag.get("pose");
JSONObject translation = (JSONObject) pose.get("translation");
JSONObject rotation = (JSONObject) pose.get("rotation");
double rotationW = Double.parseDouble(rotation.get("W").toString());
double rotationX = Double.parseDouble(rotation.get("X").toString());
double rotationY = Double.parseDouble(rotation.get("Y").toString());
double rotationZ = Double.parseDouble(rotation.get("Z").toString());
Quaternion quaternion = new Quaternion(rotationW, rotationX, rotationY,rotationZ);
JSONObject quaternion = (JSONObject) rotation.get("quaternion");
double rotationW = Double.parseDouble(quaternion.get("W").toString());
double rotationX = Double.parseDouble(quaternion.get("X").toString());
double rotationY = Double.parseDouble(quaternion.get("Y").toString());
double rotationZ = Double.parseDouble(quaternion.get("Z").toString());
Quaternion quaternion3d = new Quaternion(rotationW, rotationX, rotationY,rotationZ);
double translationx = Double.parseDouble(translation.get("x").toString());
double translationy = Double.parseDouble(translation.get("y").toString());
double translationz = Double.parseDouble(translation.get("z").toString());
Translation3d translation3d = new Translation3d(translationx, translationy, translationz);
Pose3d apriltag = new Pose3d(translation3d, new Rotation3d(quaternion));
Pose3d aprilTag = new Pose3d(translation3d, new Rotation3d(quaternion3d));
// System.out.print(i + " " + translation.get("x"));
offseasonTags.put(i, apriltag);
aprilTags.put(i, aprilTag);
}

}

public HashMap<Integer, Pose3d> returnHashMap(){
return offseasonTags;
return aprilTags;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
<body>
<h1>FRC Team 3128 Robot Control Program Utility Library</h1>
<p>Provides utility classes and functions for FRC robot control programs.</p>
<p>Version 1.7.6 (May 14 2024)</p>
<p>Version 1.7.7 (May 24 2024)</p>
</body>

0 comments on commit ca561f9

Please sign in to comment.