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

Add json #83

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add json #83

wants to merge 5 commits into from

Conversation

linglejack06
Copy link
Contributor

  • add constants loader class to interface with JSONSync
  • add json files to replace java constants
  • replace java constants with java constants schemas to interface with JSONSync

@linglejack06 linglejack06 self-assigned this Nov 21, 2024
@linglejack06
Copy link
Contributor Author

@jkleiber could you check out the ConstantsLoader loadScoringConstants method to see if the maps look right? this method should work assuming gson does not throw an error when it cant find corresponding json key for java variable. if it throws an error, i guess ill have to add another scoring constants java class that includes the maps and then extend it from the schema.

@linglejack06
Copy link
Contributor Author

ive asked nathan what will happen with the gson as well

@avidraccoon
Copy link
Contributor

They cant be static if you want them loaded I believe also you can add the maps inside it but just use the JSONExclude annotation

@avidraccoon
Copy link
Contributor

If you want another example other then the tests which are old and need to be updated look here I used the JsonSync to load controllers here

@linglejack06
Copy link
Contributor Author

do i have to use json exclude in front of the JSON Sync declaration as well or only in front of the variable i want excluded

@linglejack06
Copy link
Contributor Author

@avidraccoon

@linglejack06
Copy link
Contributor Author

also @avidraccoon im running into an issue with json exclude, its not letting me put it in front of an enum, any clue why? im trying to throw it in front oft of the align target enum in drive constants

@avidraccoon
Copy link
Contributor

@linglejack06 can you show me the code?

@avidraccoon
Copy link
Contributor

Just use static for the JsonSync because I know it works for that but for other i have not had a chance to check

@linglejack06
Copy link
Contributor Author

@JSONExclude public enum AlignTarget {
     NONE,
     AMP,
     SPEAKER,
     SOURCE,
     ENDGAME,
     UP,
     DOWN,
     LEFT,
     RIGHT,
     PASS
 }

this is what i am attempting to exxlude, it tells me i cannot use json exclude in this location, it works for variables of other types though

@linglejack06
Copy link
Contributor Author

Just use static for the JsonSync because I know it works for that but for other i have not had a chance to check

got it ill do that

… be plenty for checking, now build just fialing due to jitpack
@linglejack06
Copy link
Contributor Author

@jkleiber do you know of an easy way to convert java to json (like a website or something) i really dont want to copy all the key value pairs for scoring and drive to see if the special use cases work

@avidraccoon
Copy link
Contributor

If you give me a day to three I was gonna add that to the JsonSync it has been a planned feature for a while

@avidraccoon
Copy link
Contributor

Also the JsonExclude was designed not to work on enum because it is not needed i believe

@avidraccoon
Copy link
Contributor

@linglejack06

@jkleiber
Copy link
Member

@linglejack06 if it's a lot of trouble you could just make a separate file for only special cases and just knock one out at a time (i.e. check that it loads and is correct). Then you don't have to convert a bunch of random stuff that isn't pertinent

@linglejack06
Copy link
Contributor Author

linglejack06 commented Nov 23, 2024 via email

@linglejack06
Copy link
Contributor Author

linglejack06 commented Nov 23, 2024 via email

@jkleiber
Copy link
Member

@linglejack06 if you can't figure this out and are blocked by this, I'd let @avidraccoon make whatever updates he needs to and try to work on vision stuff while that gets sorted out

@avidraccoon
Copy link
Contributor

You can store variable that are of a enum type in json

@avidraccoon
Copy link
Contributor

if you wait till the week after next I will have added a lot of things that will make this easier to use

@avidraccoon
Copy link
Contributor

@linglejack06 @jkleiber

@jkleiber
Copy link
Member

@avidraccoon could you make some ticket(s) for the issues you've identified so it's clear what needs to be improved?

@avidraccoon
Copy link
Contributor

Yeah I can do that once I am out of the car and have arrived. I might have to do it tomorrow .@jkleiber

@jkleiber
Copy link
Member

Thanks @avidraccoon whenever is convenient for you - have a good vacation!

@avidraccoon
Copy link
Contributor

avidraccoon commented Nov 23, 2024

@linglejack06 @jkleiber When looking at wpilib it looks like it has base support for protobuf I'm gonna test it with gson but if it doesn't work do you think we should switch?

@jkleiber
Copy link
Member

@avidraccoon let's just try to get JSON working first and then we can evaluate if protobuf is a better option

@avidraccoon
Copy link
Contributor

@linglejack06 @jkleiber Good new it does support WPILIB class (At least Pose2d I will test more later) But for some I might have to do verification of values because it doesn't check the values when loaded as an example for Rotation2D you could set 2.3 radians the cos equal to 20 and sin 2.2134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants