コード例 #1
0
    def select_behavior(self):
        try:
            candidates = self.candidate_behaviors.pop()
        except IndexError:
            logdebug("No candidate behaviors received")
            candidates = None

        # Attempt to select a candidate behavior using a behavior network
        if candidates is not None:
            behavior = self.behavior_net.select_behavior(candidates, self.rate_in_hz)

            if behavior is not None:
                logdebug("Behavior selected: {}".format(behavior))
                self.selected_behaviors.push(behavior)
コード例 #2
0
    def publish_selected_behavior(self):

        # Check for available selected behaviors
        try:
            behavior = self.selected_behaviors.pop()
        except IndexError:
            behavior = None

        # Publish selected behavior to selected behaviors queue for action
        # execution (if applicable)
        if behavior is not None:
            logdebug("Publishing selected behaviors for execution")
            SELECTED_BEHAVIORS_TOPIC.send(behavior)
        else:
            logdebug("No behaviors selected for execution")
コード例 #3
0
    def select_behavior(self, behaviors, rate_in_hz):
        best_candidate = max(behaviors, key=attrgetter('activation'))

        # [Behavior Selected]
        if best_candidate.activation >= self.candidate_threshold:
            logdebug("Behavior selected: {}".format(best_candidate))

            # Remove activation from selected behavior
            best_candidate.activation = 0.0

            # Reset candidate threshold
            self.candidate_threshold = self.initial_candidate_threshold

            logdebug("Resetting candidate threshold to {}".format(self.candidate_threshold))

            return best_candidate

        # [No Selected Behavior]
        else:
            self.candidate_threshold \
                = self.candidate_threshold_decay_strategy.get_next_value(self.candidate_threshold, rate_in_hz)

            logdebug("No behavior selected.  Reducing candidate_threshold to {}".format(self.candidate_threshold))

            return None
コード例 #4
0
 def receive_coalitions(self):
     logdebug("Receiving workspace coalitions")
コード例 #5
0
 def receive_cue(self):
     logdebug("Receiving workspace cue")