AlanNaoto / carla-dataset-runner

Data collector for CARLA 0.9.6
MIT License
60 stars 20 forks source link

Possible bug with carla 0.9.11 #5

Closed dbersan closed 3 years ago

dbersan commented 3 years ago

I am running this in a .bash file, recording multiple sequences by calling python carla-dataset-runner/main.py ... many times, separated by sleep commands.

A sporadic error I am getting, usually on the second run (but not always), is on this line:

_, rgb_data, depth_data = sync_mode.tick(timeout=2.0)  # If needed, self.frame can be obtained too
  File "/home/dhiego.bersan/Documents/bounding-box-and-semantic-segmentation-coupling/carla-dataset-runner/set_synchronous_mode.py", line 60, in tick
    data = [self._retrieve_data(q, timeout) for q in self._queues]
  File "/home/dhiego.bersan/Documents/bounding-box-and-semantic-segmentation-coupling/carla-dataset-runner/set_synchronous_mode.py", line 60, in <listcomp>
    data = [self._retrieve_data(q, timeout) for q in self._queues]
  File "/home/dhiego.bersan/Documents/bounding-box-and-semantic-segmentation-coupling/carla-dataset-runner/set_synchronous_mode.py", line 72, in _retrieve_data
    data = sensor_queue.get(timeout=timeout)
  File "/home/dhiego.bersan/anaconda3/envs/carla-0-9-10/lib/python3.7/queue.py", line 178, in get
    raise Empty
_queue.Empty

It seems all sensor data are tested by the data that satisfies data.frame == self.frame is never found and then sensor_queue.get(timeout=timeout) times out.

AlanNaoto commented 3 years ago

It's a long time since I've worked on this, and the set_synchronous_mode.py file is from the original carla repo. On hindsight, I should've separated it better.

In any case, this seems an issue with threading, no? the other scripts I wrote here are all single-threaded, so you might have a more meaningful response if you open an issue in the official carla repo.

If you want a super-hacky and non-ideal solution, you can always wrap a "try" around the sync_mode.tick() and just discard/ignore the data if it does not come by

dbersan commented 3 years ago

It's a long time since I've worked on this, and the set_synchronous_mode.py file is from the original carla repo. On hindsight, I should've separated it better.

In any case, this seems an issue with threading, no? the other scripts I wrote here are all single-threaded, so you might have a more meaningful response if you open an issue in the official carla repo.

If you want a super-hacky and non-ideal solution, you can always wrap a "try" around the sync_mode.tick() and just discard/ignore the data if it does not come by

Yes, I used a try/catch to return the last data point. But the issue just didn't happen again, for some reason. Here is my code anyway:

def _retrieve_data(self, sensor_queue, timeout):
        while True:
            data = None
            try: 
                data = sensor_queue.get(timeout=timeout)
                if data.frame == self.frame:
                    return data
            except:
                print(f"Data.frame: {data.frame}; self.frame: {self.frame}. Queue empty? {'yes' if sensor_queue.empty() else 'no'}")
                return data
zhouwy-lv commented 2 years ago

Hello!I also encountered this problem, have you solved it? @dhiegomaga