def __init__(self, args):
     super(CenterCorridor, self).__init__(args)
     config = get_config()["field"]
     self.corridor_u_start = int(config["length"]) * (3.5 / 9.0)
     self.corridor_u_end = int(config["length"]) * (5.5 / 9.0)
     self.ball_distance_history = []
     config = get_config()["Behaviour"]
     self.start = time.time()
     self.go_striker_range = config["Fieldie"]["Defender"]["goStrikerRange"]
     self.go_striker_time = config["Fieldie"]["Defender"]["goStrikerTime"]
     self.ball_history_length = config["Fieldie"]["Defender"]["ballHistoryLenght"]
     self.wait_at_start = config["Fieldie"]["Defender"]["waitAtStart"]
     self.required_number = config["Fieldie"]["Defender"]["requiredNumberTrues"]
 def __init__(self):
     #self.debug = Scope("Util.Speaker")
     self.config = get_config()["speaker"]
     self.saylog = []
     self.__start_speaker()
     self.do_not_speck = os.getenv("FORCE_SPEAKER_TO_BE_QUIET")
     self.speaking = None
 def __init__(self, args):
     super(HeadToPanTilt, self).__init__()
     self.pan = float(args[0])
     self.tilt = float(args[1])
     config = get_config()
     self.delta = config["Behaviour"]["Common"]["Search"]["headTurnPrecision"]
     self.wait_time = config["Behaviour"]["Common"]["Search"]["headTurnTime"]
     self.pan_speed = config["Behaviour"]["Common"]["Search"]["maxPanSpeedSearch"]
     self.tilt_speed = config["Behaviour"]["Common"]["Search"]["maxTiltSpeedSearch"]
     self.at_position = time.time()
 def __init__(self, _):
     super(ContiniousSearch, self).__init__()
     self.pattern_pos = 0
     config = get_config()
     self.goalie_pattern = config["Behaviour"]["Common"]["SearchPattern"]["goalie"]
     self.defender_pattern = config["Behaviour"]["Common"]["SearchPattern"]["defender"]
     self.center_pattern = config["Behaviour"]["Common"]["SearchPattern"]["center"]
     self.ball_pattern = config["Behaviour"]["Common"]["SearchPattern"]["ball"]
     self.default_pattern = config["Behaviour"]["Common"]["SearchPattern"]["ball"]  # todo default <-> Ball pattern
     self.current_pattern = self.default_pattern
     self.last_pattern = self.current_pattern
    def reset_to_own(self):
        # initilize with position in middle of our side
        config = get_config()['field']
        self.length = config['length']
        goal_width = config['goal-width']
        self.goal_posts.append(GoalPost(*convert_uv2polar(-self.length / 4, -goal_width / 2)))
        self.goal_posts.append(GoalPost(*convert_uv2polar(-self.length / 4, goal_width / 2)))
        self.goal_posts.append(GoalPost(*convert_uv2polar(self.length / 4 * 3, goal_width / 2)))
        self.goal_posts.append(GoalPost(*convert_uv2polar(self.length / 4 * 3, -goal_width / 2)))
        # am anfang sollte das Tor 0 unseres sein
        self.own_goal = config['own-goal']

        self.object_list['middle_point'] = LocalObject(*convert_uv2polar(self.length / 4, 0))
 def __init__(self, _):
     super(DefenderDecision, self).__init__()
     config = get_config()["Behaviour"]
     self.toggle_one_time_defender = config["Toggles"]["Fieldie"]["oneTimeDefender"]
     self.go_striker_range = config["Fieldie"]["Defender"]["goStrikerRange"]
     self.go_striker_time = config["Fieldie"]["Defender"]["goStrikerTime"]
     self.ball_history_length = config["Fieldie"]["Defender"]["ballHistoryLenght"]
     self.first_first_time = None
     self.required_number = config["Fieldie"]["Defender"]["requiredNumberTrues"]
     self.start_time = time.time()
     self.wait_at_start = config["Fieldie"]["Defender"]["waitAtStart"]
     self.ball_distance_history = []
     self.started = None
     self.start = time.time()
 def __init__(self, _):
     super(AbstractCorridor, self).__init__()
     config = get_config()["field"]
     self.corridor_u_start = int(config["length"]) * (1.0 / 9.0)
     self.corridor_u_end = int(config["length"]) * (2.0 / 9.0)
     self.corridor_v = int(config["width"]) * (1.0 / 3.0)
     self.corridor_v_diff = 100
     self.field_length = int(config["length"])
     self.ang_threshold = 10
     self.goal_pos_v = 0
     self.goal_pos_u = 0
     self.own_goal = None
     self.opp_goal = None
     self.timestamp_goal = 0
     self.wait_goal_time = 4
    def start(self, data):
        """
        Starting the grid world module, setting a variables like the amount of cells, initializing the grid
        :param data: BitBots data object
        """
        # letzter Start
        self.lastStart = time.time()

        self.grid = dict()
        config = get_config()['field']
        self.length = config['length']
        self.width = config['width']
        self.goal_width = config['goal-width']

        # Cells
        self.xCount = 19  # Amount of cells in horizontal direction
        self.yCount = 13  # Amount of cells in vertical direction
        self.cellCount = self.yCount * self.xCount

        self.x_half = int(self.xCount / 2)
        self.y_half = int(self.yCount / 2)
        self.initialize_grid()

        # Ist -1 wenn der Roboter auf das eigene Tor guckt und 1 wenn er auf das gegnerische Tor guckt
        # Zu Beginn ist der Wert 1, da wir davon ausgehen,
        # dass der Roboter zum Start immer auf das gegnerische Tor guckt
        # Bisher ist jedoch noch keine Loesung dafuer implementiert, um festzustellen auf welches Tor
        # der Roboter schaut.
        self.field_half = 1

        # bin_tm und bin_opp speichern die Binaerrepraesentation der Gridworld
        # und werden zunaechst auf einen default-Wert gesetzt bis es Daten gibt,
        # die eingetragen werden koennen. Die DATA_KEYs werden in update mit ihnen verglichen,
        # damit einige Operationen nur durchgefuehrt werden, wenn sich die Daten tatsaechlich
        # geaendert haben.
        self.bin_tm = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999]
        self.bin_opp = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999]
    def test_if_right_goal(self, connector, goal_distance):
        if connector.team_data_capsule().get_team_goalie_ball_position() == 0 or\
                connector.team_data_capsule().get_team_goalie_ball_position() == (
                999999, 0):
            # zwei fragen, weil ih nicht weiß, was zurückkommt, wenn ich keine daten hab
            return True  # no data from goalie

        config = get_config()['field']
        length = config['length']

        goalie_ball_distance = connector.team_data_capsule().get_goalie_ball_distance()
        delta = abs(goal_distance - goalie_ball_distance)

        if length / 2 + 500 > goalie_ball_distance > length / 2 - 500:
            # der ball liegt sehr mittig, wir treffen lieber keine entscheidung, weil die vermutlich nicht valide ist
            # the ball is in the middle, we better don't decide, because we cant be sure
            return True  # so we let him kick
        else:
            if delta < 1000:
                # falls die distanzen fast gleich sind, ist das wohl das falsche tor
                # in the case the distances are nearly equal, this is probably the wrong golal
                return False
            else:
                return True
 def __init__(self, _):
     super(AbstactSearchForObject, self).__init__()
     self.run = -1
     config = get_config()
     self.pattern = config["Behaviour"]["Common"]
    def __init__(self):
        self.joints = load_joints_from_yaml(find_resource("config/joints.yaml"))

        self.config = get_config()
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from bitbots.debug import Scope
from bitbots.util.resource_manager import find_animation
from bitbots.util.config import get_config

import json

import threading

CONFIG = get_config()
debug = Scope("Util.Scope")
try:
    import bitbots.motion.animation as animation
    __anmimation_module = True
except ImportError:
    # für entwickler welche sachen ohne virtualenv (meist windows) testen
    __anmimation_module = False
    debug.warning(
        "Animation Framework NICHT gefunden (bitbots.motion.animation)")
try:
    from bitbots.ipc import STATE_ANIMATION_RUNNING
except ImportError:
    # für entwickler welche sachen ohne virtualenv (meist windows) testen
    STATE_ANIMATION_RUNNING = 1
    debug.warning("IPC Implementation nicht gefunden")


def __play_animation(name, ipc, callback=None):
    """
    Spielt eine Animation ab
 def __init__(self, _):
     super(DutyDecider, self).__init__()
     config = get_config()["Behaviour"]
     self.max_fieldie_time = config["Fieldie"]["Defender"]["maxFieldieTime"]
     self.toggle_self_positioning = config["Toggles"]["Fieldie"]["trySelfPositioning"]
* created 17.7.14 (Martin Poppinga, Marc Bestmann)

* 06.08.14 Refactor (Marc Bestmann)


"""
import math

from bitbots.modules.abstract.abstract_module import AbstractModule
from bitbots.modules.keys import DATA_KEY_BALL_INFO, DATA_KEY_GOALIE_BALL_RELATIVE_POSITION, DATA_KEY_IS_NEW_FRAME, \
    DATA_KEY_GOAL_MODEL, DATA_KEY_BALL_FOUND
from bitbots.util.config import get_config


config = get_config()['field']
length = config['length']


class ValidateLocalGoalModelModule(AbstractModule):
    def update(self, data):
        if data[DATA_KEY_IS_NEW_FRAME] and data[DATA_KEY_BALL_FOUND] and data.get(DATA_KEY_GOALIE_BALL_RELATIVE_POSITION, 0) != 0:
            ball_distance = data[DATA_KEY_BALL_INFO].distance
            if ball_distance < 1000:  # TODO config

                own_goal_distance = data[DATA_KEY_GOAL_MODEL].get_own_goal()
                opp_goal_distance = data[DATA_KEY_GOAL_MODEL].get_opp_goal()

                goalie_ball_distance = math.sqrt(
                    data[DATA_KEY_GOALIE_BALL_RELATIVE_POSITION][0] ** 2
                    + data[DATA_KEY_GOALIE_BALL_RELATIVE_POSITION][1] ** 2)
 def start(self, data):
     self.goal_model = LocalGoalModel()
     self.ipc = data[DATA_KEY_IPC]
     data[DATA_KEY_GOAL_MODEL] = self.goal_model
     self.use_filtered_goals = get_config()["Toggels"]["use_filtered_goals"]