Skip to content

Commit

Permalink
experiments: ball speed detector example
Browse files Browse the repository at this point in the history
  • Loading branch information
nzjrs committed Dec 16, 2020
1 parent 0e15042 commit d1e53e2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions experiments/ball_speed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import collections

import numpy as np

from flyvr.control.experiment import Experiment


class _MyExperiment(Experiment):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._speed_hist = collections.deque(maxlen=33)

def process_state(self, state):
self._speed_hist.append(state.speed)
if np.mean(state.speed) > 0.03:
print(self.is_started(), self.is_backend_ready(Experiment.BACKEND_VIDEO), self.is_stopped())
print("SPIN ", state.frame_cnt, "=", np.mean(state.speed))

experiment = _MyExperiment()

0 comments on commit d1e53e2

Please sign in to comment.