carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
11.39k stars 3.7k forks source link

Carla recorder #6306

Open Dan-A22 opened 1 year ago

Dan-A22 commented 1 year ago

Hi everybody. I got 2 questions from the carla recorder:

1- Where is the location that the .log file is saved. I just want to make sure that everything is working fine and the simulation data is actually recorded.

2- I followed all the steps that were shown in the carla documentation here(https://carla.readthedocs.io/en/latest/adv_recorder/). The following is my complete code:

def main():
    actor_list = []
    try:
        client = carla.Client('localhost', 2000)
        client.set_timeout(10.0)
        client.start_recorder("/home/carla/recording01.log", True)
        world = client.get_world()
        world.set_weather(carla.WeatherParameters.ClearSunset)
        blueprint_library = world.get_blueprint_library()
        bp = blueprint_library.filter('model3')[0]
        spawn_point = random.choice(world.get_map().get_spawn_points())
        vehicle = world.try_spawn_actor(bp, spawn_point)
        actor_list.append(vehicle)
        bp = random.choice(blueprint_library.filter('vehicle'))
        spawn_point = random.choice(world.get_map().get_spawn_points())
        vehicle2 = world.try_spawn_actor(bp, spawn_point)
        actor_list.append(vehicle2)
        bp = random.choice(blueprint_library.filter('vehicle'))
        spawn_point = random.choice(world.get_map().get_spawn_points())
        vehicle3 = world.try_spawn_actor(bp, spawn_point)
        actor_list.append(vehicle3)
        time.sleep(1)
        vehicle.set_autopilot(True)
        vehicle2.set_autopilot(True)
        vehicle3.set_autopilot(True)
        timme = datetime.now()
        # dummy loop to keep the recording go for 60 seconds
        i = 1
        while (datetime.now() - timme).total_seconds() <= 60:
            i += 1
        client.stop_recorder()
    finally:
        print("destroying actors")
        for actor in actor_list:
            actor.destroy()
        print("done")

However when I try to replay it using the following code:

def main():
    actor_list = []
    try:
        client = carla.Client('localhost', 2000)
        client.set_timeout(10.0)
        client.replay_file("recording01.log", 0., 0., 1)
        world = client.get_world()
        world.tick()
        timme = datetime.now()
        while (datetime.now() - timme).total_seconds() <= 64:
            print(".")
            world.tick()
    finally:
        print("destroying actors")
        for actor in actor_list:
            actor.destroy()
        print("done")

nothing changes in the carla server and no errors appear in the terminal. am I doing something wrong? thanks for your help!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

PabloVD commented 1 week ago

Sorry for the delay in our response. Here are the answers to your two questions:

1. When you start the recording, you should get a message with the path of the saved log, something like: Recording on file: /home/tda/.config/Epic/CarlaUE4/Saved/test1.log Anyway, you can specify the path of the log when you start recording by: client.start_recorder(logfile)

2. You do not need to perform the tick in replaying. Try with a simple code such as one below:

import carla
import os

client = carla.Client()
world = client.get_world()

logfile = "logfile.log"

id_vehicle = 25 # in case you want to follow one actor in the spectator

print(client.show_recorder_file_info(logfile, True))
print(client.replay_file(logfile, 0, 0, id_vehicle, False))