<commit_before>import sys
import os.path
path, file = os.path.split(os.path.realpath(__file__))
sys.path.append(os.path.join(path, "Communication"))
from .Game.Ball import Ball
from .Game.Field import Field
from .Game.Game import Game
from .Game.Player import Player
from .Game.Referee import Referee
from .Game.Team import Team
from .Util.Pose import Pose
from .Util.Position import Position
from .Util.constant import PLAYER_PER_TEAM
from .Communication.vision import Vision
from .Communication.referee import RefereeServer
from .Communication.udp_command_sender import UDPCommandSender
from .Command.Command import Stop
import math
import time
from collections import deque
import threading

def convertPositionToSpeed(player, x, y, theta):
    current_theta = player.pose.orientation
    current_x = player.pose.position.x
    current_y = player.pose.position.y
    theta_direction = theta - current_theta
    if theta_direction >= math.pi:
        theta_direction -= 2 * math.pi
    elif theta_direction <= -math.pi:
        theta_direction += 2*math.pi

    if (theta_direction == 0):
        theta_speed = 0
    elif (abs(theta_direction) > 0.2):
        theta_speed = 2
    elif(abs(theta_direction) <= 0.2 and abs(theta_direction) > 0):
        theta_speed = 0.4
    new_theta = theta_speed if theta_direction >= 0 else -theta_speed

    direction_x = x - current_x
    direction_y = y - current_y
    norm = math.hypot(direction_x, direction_y)
    speed = 1 if norm >= dead_zone else 0
    if norm:
        direction_x /= norm
        direction_y /= norm
    angle = math.atan2(direction_y, direction_x)
    cosangle = math.cos(-current_theta)
    sinangle = math.sin(-current_theta)
    new_x = (direction_x * cosangle - direction_y * sinangle) * speed
    new_y = (direction_y * cosangle + direction_x * sinangle) * speed
<commit_msg>deadzone fix, TODO: mettre en place la constante dans le fichier, eventuellement<commit_after>import sys
import os.path
path, file = os.path.split(os.path.realpath(__file__))
sys.path.append(os.path.join(path, "Communication"))
from .Game.Ball import Ball
from .Game.Field import Field
from .Game.Game import Game
from .Game.Player import Player
from .Game.Referee import Referee
from .Game.Team import Team
from .Util.Pose import Pose
from .Util.Position import Position
from .Util.constant import PLAYER_PER_TEAM
from .Communication.vision import Vision
from .Communication.referee import RefereeServer
from .Communication.udp_command_sender import UDPCommandSender
from .Command.Command import Stop
import math
import time
from collections import deque
import threading

def convertPositionToSpeed(player, x, y, theta):
    current_theta = player.pose.orientation
    current_x = player.pose.position.x
    current_y = player.pose.position.y
    theta_direction = theta - current_theta
    if theta_direction >= math.pi:
        theta_direction -= 2 * math.pi
    elif theta_direction <= -math.pi:
        theta_direction += 2*math.pi

    if (theta_direction == 0):
        theta_speed = 0
    elif (abs(theta_direction) > 0.2):
        theta_speed = 2
    elif(abs(theta_direction) <= 0.2 and abs(theta_direction) > 0):
        theta_speed = 0.4
    new_theta = theta_speed if theta_direction >= 0 else -theta_speed

    direction_x = x - current_x
    direction_y = y - current_y
    norm = math.hypot(direction_x, direction_y)
    speed = 1 if norm >= 50 else 0
    if norm:
        direction_x /= norm
        direction_y /= norm
    angle = math.atan2(direction_y, direction_x)
    cosangle = math.cos(-current_theta)
    sinangle = math.sin(-current_theta)
    new_x = (direction_x * cosangle - direction_y * sinangle) * speed
    new_y = (direction_y * cosangle + direction_x * sinangle) * speed

{'fraction_non_alphanumeric': 0.0881726158763985, 'fraction_numerical': 0.009057005860415556, 'mean_word_length': 3.546004842615012, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6456220', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1151, 'n_words': 333}