diff --git a/DecisionSystem/DecentralisedActivityFusion/voter.py b/DecisionSystem/DecentralisedActivityFusion/voter.py index da5b345..c08fdb9 100644 --- a/DecisionSystem/DecentralisedActivityFusion/voter.py +++ b/DecisionSystem/DecentralisedActivityFusion/voter.py @@ -56,12 +56,19 @@ class Voter: # First calculate vi -> the actual vote that is taken # (Or the probability that the observation is a label for each) # We're just going to be doing 1 for the detected and 0 for all others. - # vi = np.zeros(6,1) - # ANDvi = np.zeros(6,6) + # vi is for each hand (action in paper), but we're just going to do a single + # hand for our purposes. Will be able to use the CNN for all hands/gestures if we want to. + vi = np.zeros(6,1) + # Set correct vi. + vote = self.on_vote() + vi[vote] = 1 + # Now send this off to the other nodes. Potentially using gossip... - # # Set diagonal of ANDvi to elements of vi. - # for i in np.size(vi): - # ANDvi[i,i] = vi[i] + # Set diagonal of ANDvi to elements of vi. + # This should actually be ANDvj, as it is for each observation received. + ANDvi = np.diag(vi.flatten()) + + # Nee # M is the probability of going from one state to the next, which # is assumed to be uniform for our situation - someone is just as likely @@ -72,12 +79,21 @@ class Voter: # Y1T = np.full((6,1),1) + # Compute consensus state estimate by taking difference between our observations + # and all others individually. + # Moving to an approach that does not require the previous # timestep (or so much math...) # First take other information and fuse, using algorithm # as appropriate. pass - + + def custom_fuse(self): + vi = np.zeros(6,1) + # Set correct vi. + vote = self.on_vote() + vi[vote] = 1 + def on_message(self, client, userdata, message): try: @@ -106,4 +122,7 @@ class Voter: def collect_vote(self): vote_message = umsgpack.packb({"type": "vote", "client":self._client._client_id, "vote": self.on_vote()}) - return vote_message \ No newline at end of file + return vote_message + + def start_vote(self): + pass \ No newline at end of file