pyoscx / scenariogeneration

Python library to generate linked OpenDRIVE and OpenSCENARIO files
Mozilla Public License 2.0
267 stars 83 forks source link

Creating scenario with ParameterDeclaration reference #158

Closed unitzze closed 1 year ago

unitzze commented 1 year ago

I am generating OSCV1.1 scenarios together with parameter distribution file. I want to generate scenario using ParameterDeclaration reference but I get TypeError.

e.g. I want to use CloudState class with $CloudState_Parameter reference. But since this is not part of CloudState enumerations I get TypeError. image

I assume this is the case also for all the others enumerations.

mander76 commented 1 year ago

Hmm, interesting :) this is a use case I haven't thought about. I guess it should be fine according to the standard if the Parameter is of string type.

The xosc module expects that all enums are of type _OscEnum to function properly, this is working since there is a type check for each enum as input. For all other (base type) inputs types it's ok with a parameter (based on a $ as the first character). Same issue will arise while parsing of xosc files, it will not be able to parse parameter references instead of Enums either..

I have to sit down and try to figure out how to deal with this in a nice way..

mander76 commented 1 year ago

I have created a PoC for this on this branch for cloudstate. Can you try it out if it is how you expect it to work?

https://github.com/pyoscx/scenariogeneration/tree/param_for_enum

mander76 commented 1 year ago

Cool, then I'll try to add it to the rest of the classes, might take awhile..

unitzze commented 1 year ago

Thank you for a very fast response.

I tested it for both CloudState and CoordinateSystem (within LongitudinalDistanceAction) enumerations and it works as intended.

Could you please update Weather class as soon as possible, on this same PoC branch, since I need this feature rather quickly. Thank you.

(reopened the issue due to accidentally closing it, please close it once you add it to the rest of the classes)

mander76 commented 1 year ago

I can update the weather first, but I'll keep it in a branch until I have made it work for the others, might still be some pitfalls that I haven't thought about in the other classes (there is a lot of them :P )

mander76 commented 1 year ago

Now Environment (including weather) "should work" on the branch.

mander76 commented 1 year ago

It went faster than I thought :) will make a new release with all classes modified.

Good find!