tum-autonomousdriving / autonomous-driving-simulator

44 stars 3 forks source link

[Performance issue] Drive script lags behind of simulator #14

Closed tarikisildar closed 1 year ago

tarikisildar commented 1 year ago

My drive.py script is receiving at most 17-18 images per second. Without even running the model, it lags behind the actual simulator as in the image I added.

image

I can't really make sure about the reason without checking out the code. Can we add the unity project under this repository so we can point out potential performance improvements or bug fixes more easily?

pranav-ap commented 1 year ago

Are you facing this in a windows OS?

tarikisildar commented 1 year ago

Are you facing this in a windows OS?

Yes

Einholz-Gao commented 1 year ago

Hi. If you need, this is the Project. PLS try it on Unity 2021.3.21f1 / 2021.3.25f1 Unity

tarikisildar commented 1 year ago

I found the issue. On ServerInputProvider.cs Start calls -> InvokeRepeating("CaptureAndSendImage", 0.0f, 0.05f) which making computation and sends image unrelated from the current frame. 0.05 second makes 30 captures per second. And simulation runs around 15 fps, So in every frame, two images are sent.

Removing that line and adding this

private void Update()
        {
            CaptureAndSendImage();
        }

solved it for me.

Einholz-Gao commented 1 year ago

This line is to limit the frequency of image transmission and prevent the emulator from freezing. In my opinion we should find the best balance

tarikisildar commented 1 year ago

Well, it's not a limiting factor in this context. I have a pretty high-end device and the simulator is still on 15-20 ish fps. This line is making it send an image