Commit d09c3238 authored by elagil's avatar elagil
Browse files

cleanup

parent abd1c3bf
from .detector import Detector, Hitbox
class Hitbox():
def __init__(self, ranges, angles, triggerCounter=4, releaseCounter=1, releaseDebounce=2):
self.ranges = ranges
self.angles = angles
self.counter = 0
self.debounce = 0
self.triggerCounter = triggerCounter
self.releaseCounter = releaseCounter
self.releaseDebounce = releaseDebounce
self.triggerCounterReached = False
self.releaseCounterReached = False
self.triggered = False
self.triggeredPreviously = False
def isWithinRange(self, value, valueRange):
if valueRange[0] <= value <= valueRange[1]:
return True
else:
return False
def hit(self, r, a):
if self.isWithinRange(r, self.ranges) and self.isWithinRange(a, self.angles):
self.counter += 1
def evaluate(self):
self.triggerCounterReached = self.counter >= self.triggerCounter
self.releaseCounterReached = self.counter < self.releaseCounter
self.counter = 0
if self.triggerCounterReached and self.triggered == False:
self.triggered = True
self.debounce = self.releaseDebounce
if self.releaseCounterReached and self.triggered == True:
self.debounce -= 1
if self.debounce <= 0:
self.triggered = False
def arm(self):
self.triggeredPreviously = self.triggered
class Detector():
def __init__(self):
self.hitboxes = []
def newHitbox(self, ranges, angles):
self.hitboxes.append(Hitbox(ranges, angles))
def run(self, detectedRanges, detectedAngles):
for hitbox in self.hitboxes:
hitbox.arm()
for r, a in zip(detectedRanges, detectedAngles):
hitbox.hit(r, a)
hitbox.evaluate()
......@@ -12,7 +12,7 @@ from shutil import rmtree
from setuptools import find_packages, setup, Command
# Package meta-data.
NAME = 'detection'
NAME = 'vitalsensing'
DESCRIPTION = 'Provides target detection capabilities'
URL = ''
EMAIL = 'adrian@figueroa.eu'
......
from .sensor import Sensor, SensorSettings
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment