BerkeleyLearnVerify / Scenic

A compiler and scenario generator for the Scenic scenario description language.
https://scenic-lang.org/
Other
271 stars 93 forks source link

Generate a json file containing a scene #151

Closed johannesskaro closed 1 year ago

johannesskaro commented 1 year ago

Hi, in my simulator the scenario is defined by a json file. I want to use scenic to make scenarios and then convert the scene into that json file. How would you go about doing this? Are there any built-in functionality to generate a data with a scenic program?

Eric-Vin commented 1 year ago

@johannesskaro, are you interested in having Scenic interface directly with the simulator? This would allow you to use the features of dynamic scenarios, but would require you to write a new simulator interface for your simulator (unless it's already one we support).

If on the other hand you're just interested in exporting a scene generated by Scenic to a JSON file, you can sample a scene programmatically and access all the Scenic Objects in that Scene, which you could then use to create a JSON in your desired format.

Hope this helps!

johannesskaro commented 1 year ago

Yes, thanks for a quick reply!

I would need to generate scenes programmatically, and I think for static scenarios this shouldn't be any problem. However for the dynamic scenarios, I am a bit unsure. The thing is that, with my simulator, one cannot interact with it once the simulation has started. All the events that should happen at some time-step needs to be encoded into the JSON file that initializes the simulation. So therefore I don't think the simulator can be interfaced directly with Scenic, correct me if I'm wrong.

One solution could be to use a simple simulator like the newtonian, just to generate the trajectories of objects in the scenario that would interfere with the ego object, and then use my simulator to simulate the control system that will control the ego object. Does that make sense?

I know there isn't a specific question here, I would just like to hear your thoughts. Thank you!

Eric-Vin commented 1 year ago

It sounds like your simulator just won't work for dynamic scenarios with how Scenic is setup right now. I wouldn't recommend the Newtonian simulator for what you're describing since it is fairly simplistic and may have some accuracy issues, though I suppose it could work.

If all you want to do is trigger certain events at certain times, you can generate those random times in Scenic, but Scenic is designed for dynamic scenarios where what happens next in the scenario can depend on the state of the world, and it isn’t possible to encode such a scenario into a static file — there needs to be back-and-forth interaction between the simulator and Scenic.

johannesskaro commented 1 year ago

Alright, I understand. Thank you for your time.