-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Add json #83
Conversation
linglejack06
commented
Nov 21, 2024
- 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
@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. |
ive asked nathan what will happen with the gson as well |
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 |
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 |
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 |
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 |
@linglejack06 can you show me the code? |
Just use static for the JsonSync because I know it works for that but for other i have not had a chance to check |
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 |
got it ill do that |
… be plenty for checking, now build just fialing due to jitpack
@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 |
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 |
Also the JsonExclude was designed not to work on enum because it is not needed i believe |
@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 |
At this point, I’ve added all the schema files though, so the code will crash in simulation I think until all of those have json. I can just send them to a dummy file though if gson doesn’t have a problem with not finding variables. I’ll try it out maybe tomorrow or Sunday Sent from my iPhoneOn Nov 22, 2024, at 6:12 PM, Justin Kleiber ***@***.***> wrote:
@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
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Okay so json has an enum type? Is it just keys?Sent from my iPhoneOn Nov 22, 2024, at 5:50 PM, avidraccoon ***@***.***> wrote:
Also the JsonExclude was designed not to work on enum because it is not needed i believe
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@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 |
You can store variable that are of a enum type in json |
if you wait till the week after next I will have added a lot of things that will make this easier to use |
@avidraccoon could you make some ticket(s) for the issues you've identified so it's clear what needs to be improved? |
Yeah I can do that once I am out of the car and have arrived. I might have to do it tomorrow .@jkleiber |
Thanks @avidraccoon whenever is convenient for you - have a good vacation! |
@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? |
@avidraccoon let's just try to get JSON working first and then we can evaluate if protobuf is a better option |
@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 |