Closed Nancy22-NJ closed 1 year ago
Hello,
Could you provide a code snippet that triggers this error? I'm able to serialize scenes on my machine so I'm unsure where the problem might be. Once I can reproduce the issue I'm happy to help further!
**scenario = scenic.scenarioFromFile(task, params=dict, mode2D=True) scene, _ = scenario.generate()
data = scenario.sceneToBytes(scene)
with open(pathlib.Path(tempfile.gettempdir()) / 'record/test.scene', 'wb') as f:
f.write(data)**
I was trying to store this scene.
I'm able to serialize one of our driving examples with this script, so I'm not sure what the problem is. Can you print out what scene is?
Oh sorry, I meant could you print out the variable scene
before you try to serialize it?
No problem! I was thinking something along the lines of:
scenario = scenic.scenarioFromFile(task, params=dict, mode2D=True)
scene, _ = scenario.generate()
print(scene)
No problem! I was thinking something along the lines of:
scenario = scenic.scenarioFromFile(task, params=dict, mode2D=True) scene, _ = scenario.generate() print(scene)
After printing the scene, it shows '<scenic.core.scenarios.Scene object at 0x7f2b7379f580>'
@Eric-Vin Sorry to bother you, I wonder if only the static scenes can be serialized? Because i can't serialize the examples in the folder of NHTSA_Scenarios too. Thank you for your time.
All scenes should be serializable, but if you want to serialize a simulation you'd need the simulationToBytes
method. Can you include the .scenic file from above in a code block so I can debug on my end? The one you posted above has lost all formatting so it's hard to extract.
All scenes should be serializable, but if you want to serialize a simulation you'd need the
simulationToBytes
method. Can you include the .scenic file from above in a code block so I can debug on my end? The one you posted above has lost all formatting so it's hard to extract.
`The python file: import scenic, tempfile, pathlib scenario = scenic.scenarioFromFile('carlaChallenge1.scenic', mode2D=True) scene, _ = scenario.generate() simulator = scenario.getSimulator() simulation = simulator.simulate(scene, maxSteps=200) data = scenario.simulationToBytes(simulation) with open(pathlib.Path(tempfile.gettempdir()) / 'test.scene', 'wb') as f: f.write(data)
The scenic file (from the Carla_challenge): param map = localPath('../../../assets/maps/CARLA/Town01.xodr') param carla_map = 'Town01' model scenic.simulators.carla.model
EGO_MODEL = "vehicle.lincoln.mkz_2017" EGO_SPEED = 10
behavior EgoBehavior(speed=10): do FollowLaneBehavior(speed)
lane = Uniform(*network.lanes)
start = new OrientedPoint on lane.centerline ego = new Car at start, with blueprint EGO_MODEL, with behavior EgoBehavior(EGO_SPEED)
debris1 = new Debris following roadDirection for Range(10, 20) debris2 = new Debris following roadDirection from debris1 for Range(5, 10) debris3 = new Debris following roadDirection from debris2 for Range(5, 10)
require (distance to intersection) > 50 terminate when (distance from debris3 to ego) > 10 and (distance to start) > 50 ` The error is scenic.core.serialization.SerializationError: Orientation type does not implement serialization
Oh perfect! I'm not sure what changed to cause this new error but that's an error that I'm currently working on patching. It should be merged in soon, but if you'd like to try it sooner you can checkout the code on this branch. Please let me know if this resolves your issue!
@Nancy22-NJ The PR with a fix has been merged into main. Please feel free to re-open this issue if you're still experiencing the bug.
Hello, i have problem on encoding the scene as bytes. The following are the codes and its error message. Looking forward to your reply! data = scenario.sceneToBytes(scene) TypeError: a bytes-like object is required, not 'list'