<commit_before>"""This module contains the FRC robot class."""

# Imports

# If wpilib not available use pyfrc
try:
    import wpilib
except ImportError:
    from pyfrc import wpilib

import common
import drivetrain
import logging
import math
import parameters
import sys
import userinterface


class MyRobot(wpilib.IterativeRobot):
    """Controls the robot.

    This is the main robot class that controls the robot during all 3 modes.
    """
    # Public member variables

    # Private member objects
    _drive_train = None
    _log = None
    _logger = None
    _parameters = None
    _user_interface = None

    # Private parameters

    # Private member variables
    _log_enabled = False
    _parameters_file = None
    _driver_alternate = False
    _driver_controls_swap_ratio = 1.0


    # Iterative robot methods that we override.
    # These get called by the main control loop in the IterativeRobot class.
    def robotInit(self):
        """Performs robot-wide initialization.

        Called upon robot power-on.

        """
        self._initialize("/py/par/robot.par", True)

    def disabledInit(self):
        """Prepares the robot for Disabled mode.

        Called only when first disabled.

        """
        self._set_robot_state(common.ProgramState.DISABLED)

        # Read sensors
        self._read_sensors()

        self.GetWatchdog().SetEnabled(False)

    def autonomousInit(self):
        """Prepares the robot for Autonomous mode.

        Called each and every time autonomous is entered from another mode.

        """
        # Read sensors
        self._read_sensors()

        self._set_robot_state(common.ProgramState.AUTONOMOUS)
        self.GetWatchdog().SetEnabled(False)

    def teleopInit(self):
        """Prepares the robot for Teleop mode.

        Called each and every time teleop is entered from another mode.

        """
        self._set_robot_state(common.ProgramState.TELEOP)

        # Enable the watchdog
        dog = self.GetWatchdog()
        dog.SetEnabled(True)
        dog.SetExpiration(1.0)

    def testInit(self):
        """Prepares the robot for Test mode.

        Called each and every time test mode is entered from another mode.

        """
        pass

    def disabledPeriodic(self):
        """Called iteratively during disabled mode.

        The period is synced to the driver station control packets,
        giving a periodic frequency of about 50Hz (50 times per second).

        """
        # Set all motors to be stopped (prevent motor safety errors)
        if self._drive_train:
            self._drive_train.drive(0.0, 0.0, False)

        # Read sensors
        self._read_sensors()

        wpilib.Wait(0.01)

    def autonomousPeriodic(self):
        """Called iteratively during autonomous mode.

        The period is synced to the driver station control packets,
        giving a periodic frequency of about 50Hz (50 times per second).

        """
        # Read sensors
        self._read_sensors()

        wpilib.Wait(0.01)

    def teleopPeriodic(self):
        """Called iteratively during teleop mode.

        The period is synced to the driver station control packets,
        giving a periodic frequency of about 50Hz (50 times per second).

        """
        # Feed the watchdog timer
        self.GetWatchdog().Feed()

        # Read sensors
        self._read_sensors()

        # Perform user controlled actions
        if self._user_interface:<commit_msg>Removed watchdog code, since it seems to be removed from wpilib<commit_after>"""This module contains the FRC robot class."""

# Imports

# If wpilib not available use pyfrc
try:
    import wpilib
except ImportError:
    from pyfrc import wpilib

import common
import drivetrain
import logging
import math
import parameters
import sys
import userinterface


class MyRobot(wpilib.IterativeRobot):
    """Controls the robot.

    This is the main robot class that controls the robot during all 3 modes.
    """
    # Public member variables

    # Private member objects
    _drive_train = None
    _log = None
    _logger = None
    _parameters = None
    _user_interface = None

    # Private parameters

    # Private member variables
    _log_enabled = False
    _parameters_file = None
    _driver_alternate = False
    _driver_controls_swap_ratio = 1.0


    # Iterative robot methods that we override.
    # These get called by the main control loop in the IterativeRobot class.
    def robotInit(self):
        """Performs robot-wide initialization.

        Called upon robot power-on.

        """
        self._initialize("/py/par/robot.par", True)

    def disabledInit(self):
        """Prepares the robot for Disabled mode.

        Called only when first disabled.

        """
        self._set_robot_state(common.ProgramState.DISABLED)

        # Read sensors
        self._read_sensors()

    def autonomousInit(self):
        """Prepares the robot for Autonomous mode.

        Called each and every time autonomous is entered from another mode.

        """
        # Read sensors
        self._read_sensors()

        self._set_robot_state(common.ProgramState.AUTONOMOUS)

    def teleopInit(self):
        """Prepares the robot for Teleop mode.

        Called each and every time teleop is entered from another mode.

        """
        self._set_robot_state(common.ProgramState.TELEOP)

    def testInit(self):
        """Prepares the robot for Test mode.

        Called each and every time test mode is entered from another mode.

        """
        pass

    def disabledPeriodic(self):
        """Called iteratively during disabled mode.

        The period is synced to the driver station control packets,
        giving a periodic frequency of about 50Hz (50 times per second).

        """
        # Set all motors to be stopped (prevent motor safety errors)
        if self._drive_train:
            self._drive_train.drive(0.0, 0.0, False)

        # Read sensors
        self._read_sensors()

        wpilib.Wait(0.01)

    def autonomousPeriodic(self):
        """Called iteratively during autonomous mode.

        The period is synced to the driver station control packets,
        giving a periodic frequency of about 50Hz (50 times per second).

        """
        # Read sensors
        self._read_sensors()

        wpilib.Wait(0.01)

    def teleopPeriodic(self):
        """Called iteratively during teleop mode.

        The period is synced to the driver station control packets,
        giving a periodic frequency of about 50Hz (50 times per second).

        """
        # Read sensors
        self._read_sensors()

        # Perform user controlled actions
        if self._user_interface:
{'fraction_non_alphanumeric': 0.06795827123695976, 'fraction_numerical': 0.007749627421758569, 'mean_word_length': 2.3639097744360904, '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': '3782697', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1734, 'n_words': 645}