Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. def acc_compute(self,):
  2.         """
  3.            Compute acc
  4.        """
  5.         import numpy as np
  6.         from step_counting import step_counting
  7.  
  8.         self.acc_data = {"x": [], "y": [], "z": []}
  9.         print("Starting acc compute")
  10.         while self.running.is_set():
  11.             try:
  12.                 acc = self.compute_acc_queue.get(timeout=5)
  13.  
  14.                 for idx, axe in enumerate("xyz"):
  15.                     self.acc_data[axe] += acc[idx]
  16.  
  17.                 if len(self.acc_data["x"]) < (10 * params.ACC_FREQ):
  18.                     continue
  19.  
  20.                 ar = np.array(
  21.                     [
  22.                         (
  23.                             self.acc_data["x"][idx],
  24.                             self.acc_data["y"][idx],
  25.                             self.acc_data["z"][idx],
  26.                         )
  27.                         for idx in range(len(self.acc_data["x"]))
  28.                     ]
  29.                 )
  30.  
  31.                ## DO WHAT YOU WANT WITH YOUR ACC_DATA HERE
  32.  
  33.             except Queue.Empty:
  34.                 time.sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement