You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on a project where I need to save (of fork) a specific tick (timestamp) state during a simulation for later analysis or to restore the simulation to that exact point.
CARLA version: 0.9.13 Platform/OS: Linux, Ubuntu 20.04 Problem you have experienced: Try to fork a Carla.World, and restore it after complete a simulation. I try to use fork_world = copy.deepcopy(world) but not work. What you expected to happen: Fork a Carla world, and can restore it later. Steps to reproduce: Here is my demo code.
importcarlaimporttimeimportrandomimportloguruimportcopyclient=carla.Client("localhost", 2000)
client.set_timeout(10.0)
fork_world=Nonefork_spectator_transform=Noneforiinrange(5):
client.load_world("Town01")
loguru.logger.info(f"The {i}-th simulation")
world=client.get_world()
blueprint_library=world.get_blueprint_library()
transform=random.choice(world.get_map().get_spawn_points())
vehicle_bp=random.choice(blueprint_library.filter("vehicle.*"))
vehicle=world.spawn_actor(vehicle_bp, transform)
# create a spectatorspectator=world.get_spectator()
spectator_transform=carla.Transform(
transform.location+carla.Location(z=50), carla.Rotation(pitch=-90)
)
spectator.set_transform(spectator_transform)
ifi==0: # the simulation i interestedfork_world=copy.deepcopy(world) # fail: RuntimeError: Pickling of "carla.libcarla.World" instances is not enabled (http://www.boost.org/libs/python/doc/v2/pickle.html)# fork_world = world # fail: no vehicle in the fork_worldfork_spectator_transform=spectator_transformtime.sleep(5)
else:
vehicle.destroy()
time.sleep(2)
# restore the simulation pointworld=fork_worldspectator=world.get_spectator()
spectator.set_transform(fork_spectator_transform)
Other information (documentation you consulted, workarounds you tried):
I attempted to use copy.deepcopy of the Carla.World object to save the state of the simulation at a particular tick. However, there are some error in the code.
Traceback (most recent call last):
File "/home/k/Downloads/scenario_runner-0.9.13/fork_world.py", line 26, in<module>
fork_world = copy.deepcopy(world)
File "/home/k/anaconda3/envs/carla_run/lib/python3.7/copy.py", line 169, in deepcopy
rv = reductor(4)
RuntimeError: Pickling of "carla.libcarla.World" instances is not enabled (http://www.boost.org/libs/python/doc/v2/pickle.html)
While fork_world = world can run success, the vehicle that spawn in origin simulation do not show in fork world.
My guess is that the simulation environment cannot be forked because Carla PythonAPI is a C++ interface. Is there any similar API or documentation support?
I appreciate any assistance you can provide.
The text was updated successfully, but these errors were encountered:
Hello,
I am currently working on a project where I need to save (of fork) a specific tick (timestamp) state during a simulation for later analysis or to restore the simulation to that exact point.
CARLA version: 0.9.13
Platform/OS: Linux, Ubuntu 20.04
Problem you have experienced: Try to fork a
Carla.World
, and restore it after complete a simulation. I try to usefork_world = copy.deepcopy(world)
but not work.What you expected to happen: Fork a Carla world, and can restore it later.
Steps to reproduce: Here is my demo code.
Other information (documentation you consulted, workarounds you tried):
I attempted to use
copy.deepcopy
of the Carla.World object to save the state of the simulation at a particular tick. However, there are some error in the code.While
fork_world = world
can run success, the vehicle that spawn in origin simulation do not show in fork world.My guess is that the simulation environment cannot be forked because Carla PythonAPI is a C++ interface. Is there any similar API or documentation support?
I appreciate any assistance you can provide.
The text was updated successfully, but these errors were encountered: