<commit_before># Under MIT License, see LICENSE.txt
"""
    Ce module permet de créer des commandes pour faire agir les robots.
    Des fonctions utilitaire permettent de transformer une commande de
    Position (Pose) en une commande de vitesse.

    L'embarqué et le simulateur utilise un vecteur de vitesse (Pose) pour
    contrôler les robots.
"""
from abc import abstractmethod

import time

from ..Game.Player import Player
from ..Util.area import *
import RULEngine.Communication.util.serial_protocol as protocol


class _Command(object):
    def __init__(self, player):
        assert (isinstance(player, Player))
        self.player = player
        self.pose = Pose()
        self.kick_speed = 0

    @abstractmethod
    def package_command(self, mcu_version=protocol.MCUVersion.STM32F407):
        pass


class Move(_Command):
    def __init__(self, player, destination):
        # Parameters Assertion
        assert (isinstance(destination, Pose))
        super().__init__(player)
        self.pose = destination

    def package_command(self, mcu_version=protocol.MCUVersion.STM32F407):
        x = self.pose.position.x
        y = self.pose.position.y
        theta = self.pose.orientation
        if mcu_version == protocol.MCUVersion.C2000:
            x, y = x, -y

        player_idx = self.player.id
        packed_command = protocol.create_speed_command(x, y, theta, player_idx)

        return packed_command


class Kick(_Command):
    def __init__(self, player, kick_strength):
        """ Kick speed est un int entre 0 et 4 """
        super().__init__(player)
        self.kick_strength = 4

    def package_command(self, mcu_version=protocol.MCUVersion.STM32F407):
        return protocol.create_kick_command(self.player.id, self.kick_strength)


class Stop(_Command):
    def __init__(self, player):
        super().__init__(player)<commit_msg>repaired kick command<commit_after># Under MIT License, see LICENSE.txt
"""
    Ce module permet de créer des commandes pour faire agir les robots.
    Des fonctions utilitaire permettent de transformer une commande de
    Position (Pose) en une commande de vitesse.

    L'embarqué et le simulateur utilise un vecteur de vitesse (Pose) pour
    contrôler les robots.
"""
from abc import abstractmethod

import time

from ..Game.Player import Player
from ..Util.area import *
import RULEngine.Communication.util.serial_protocol as protocol


class _Command(object):
    def __init__(self, player):
        assert (isinstance(player, Player))
        self.player = player
        self.pose = Pose()
        self.kick_speed = 0

    @abstractmethod
    def package_command(self, mcu_version=protocol.MCUVersion.STM32F407):
        pass


class Move(_Command):
    def __init__(self, player, destination):
        # Parameters Assertion
        assert (isinstance(destination, Pose))
        super().__init__(player)
        self.pose = destination

    def package_command(self, mcu_version=protocol.MCUVersion.STM32F407):
        x = self.pose.position.x
        y = self.pose.position.y
        theta = self.pose.orientation
        if mcu_version == protocol.MCUVersion.C2000:
            x, y = x, -y

        player_idx = self.player.id
        packed_command = protocol.create_speed_command(x, y, theta, player_idx)

        return packed_command


class Kick(_Command):
    def __init__(self, player, kick_strength):
        """ Kick speed est un int entre 0 et 4 """
        super().__init__(player)
        self.kick_speed = 4

    def package_command(self, mcu_version=protocol.MCUVersion.STM32F407):
        return protocol.create_kick_command(self.player.id, self.kick_speed)


class Stop(_Command):
    def __init__(self, player):
        super().__init__(player)
{'fraction_non_alphanumeric': 0.08702616123865456, 'fraction_numerical': 0.012279765082754938, 'mean_word_length': 3.0333692142088267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6392193', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1090, 'n_words': 307}