Skip to content

Commit

Permalink
Replace example utils with local frameCounter def
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmadAmine998 committed Jan 27, 2025
1 parent e5d8198 commit 50db444
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion f1tenth_gym/envs/rendering/rendering_pyqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from PyQt6 import QtWidgets, QtCore
from PyQt6 import QtGui
import pyqtgraph as pg
from pyqtgraph.examples.utils import FrameCounter
from pyqtgraph.exporters import ImageExporter
from PIL import ImageColor

Expand All @@ -24,6 +23,32 @@
INSTRUCTION_TEXT = "Mouse click (L/M/R): Change POV - 'S' key: On/Off"


# Replicated from pyqtgraphs' example utils for ci pipelines to pass
from time import perf_counter
class FrameCounter(QtCore.QObject):
sigFpsUpdate = QtCore.pyqtSignal(object)

def __init__(self, interval=1000):
super().__init__()
self.count = 0
self.last_update = 0
self.interval = interval

def update(self):
self.count += 1

if self.last_update == 0:
self.last_update = perf_counter()
self.startTimer(self.interval)

def timerEvent(self, evt):
now = perf_counter()
elapsed = now - self.last_update
fps = self.count / elapsed
self.last_update = now
self.count = 0
self.sigFpsUpdate.emit(fps)

class PyQtEnvRenderer(EnvRenderer):
"""
Renderer of the environment using PyQtGraph.
Expand Down

0 comments on commit 50db444

Please sign in to comment.