from dynamic_stack_decider.abstract_decision_element import AbstractDecisionElement


class BallClose(AbstractDecisionElement):
    def __init__(self, blackboard, dsd, parameters=None):
        super(BallClose, self).__init__(blackboard, dsd, parameters)
        self.ball_close_distance = parameters.get("distance", self.blackboard.config['ball_close_distance'])

    def perform(self, reevaluate=False):
        """
        Determines whether the ball is in close range to the robot. The distance threshold is set in the config file.
        :param reevaluate:
        :return:
        """
        self.publish_debug_data("ball_distance", self.blackboard.world_model.get_ball_distance())

        if self.blackboard.world_model.get_ball_distance() < self.ball_close_distance:
            return 'YES'
        return 'NO'

    def get_reevaluate(self):
        return True

@@ -1,8 +1,20 @@
+import math%0A
 from dyn
@@ -368,16 +368,81 @@
 tance'%5D)
+%0A        self.ball_close_angle = parameters.get(%22angle%22, math.pi)
 %0A%0A    de
@@ -764,93 +764,281 @@
 ())%0A
-%0A        if self.blackboard.world_model.get_ball_distance() %3C self.ball_close_distanc
+        self.publish_debug_data(%22ball_angle%22, self.blackboard.world_model.get_ball_angle())%0A%0A        if self.blackboard.world_model.get_ball_distance() %3C self.ball_close_distance and %5C%0A                abs(self.blackboard.world_model.get_ball_angle()) %3C self.ball_close_angl
 e:%0A 

Add angles to ball close decision