Closed Ragzouken closed 2 weeks ago
Can get 30fps but the frames weren't distinct--like frames themselves not updating at 30fps
Used this to verify that frames are being received at 30fps and that the positions are changing between each of those frames. For the rust server I'm getting 99-100% of position values changing, each by at least 2e-7
, with each frame evenly spaced.
import time
import grpc
import numpy as np
from nanover.omni.playback import PlaybackSimulation
from nanover.protocol.trajectory import TrajectoryServiceStub, GetFrameRequest
from nanover.trajectory import FrameData
def test_frames():
playback = PlaybackSimulation.from_paths(["test.traj"])
playback.load()
channel = grpc.insecure_channel("localhost:38801")
stub = TrajectoryServiceStub(channel)
request = GetFrameRequest()
stream = stub.SubscribeLatestFrames(request)
times = []
times_all = []
try:
prev = None
for message in stream:
frame = FrameData(message.frame)
next = np.array(frame.particle_positions)
if prev is not None:
diff = np.abs(next - prev)
min = np.min(diff)
max = np.max(diff)
value_count = np.size(diff)
change_count = np.count_nonzero(diff)
changed_fraction = change_count / value_count
print(f"{changed_fraction:.0%} of values changed, min change: {min:.1g}, max change: {max:.1g}")
else:
print(len(frame.particle_positions) * 3)
prev = next
times.append(time.perf_counter())
times_all.append(times[-1])
if len(times) % 30 == 0:
diffs = np.diff(times)
avg = sum(diffs) / len(diffs)
print(f"{avg}s -- {1 / avg}Hz, {np.min(diffs)}")
times = []
except KeyboardInterrupt:
diffs = np.diff(times_all)
print(diffs)
test_frames()
We'll consider this a non-issue unless it comes up again.
Couldn't replicate with either rust (nanotube, frame/force interval set to 1, include forces and velocities) or python: