team401 / high-key-2024

Other
2 stars 0 forks source link

Add json #83

Open linglejack06 opened 4 days ago

linglejack06 commented 4 days ago
linglejack06 commented 4 days ago

@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 commented 4 days ago

ive asked nathan what will happen with the gson as well

avidraccoon commented 4 days ago

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 commented 4 days ago

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 commented 3 days ago

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 commented 3 days ago

@avidraccoon

linglejack06 commented 3 days ago

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 commented 3 days ago

@linglejack06 can you show me the code?

avidraccoon commented 3 days ago

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 commented 3 days ago
@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 commented 3 days ago

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

linglejack06 commented 3 days ago

@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 commented 3 days ago

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 commented 3 days ago

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

avidraccoon commented 3 days ago

@linglejack06

jkleiber commented 3 days ago

@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 commented 3 days ago

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: @.***>

linglejack06 commented 3 days ago

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: @.***>

jkleiber commented 3 days ago

@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 commented 3 days ago

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

avidraccoon commented 3 days ago

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

avidraccoon commented 3 days ago

@linglejack06 @jkleiber

jkleiber commented 3 days ago

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

avidraccoon commented 3 days ago

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

jkleiber commented 3 days ago

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

avidraccoon commented 2 days ago

@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 commented 2 days ago

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