<commit_before>/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.AnalogChannel;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.CounterBase;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Encoder;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class RobotTemplate extends IterativeRobot {
    
    // Constants
    private final double RANGEFINDER_SCALE_FACTOR = (1024/5.0);
    private final double SHOOTING_DISTANCE = (194 - 24); //
    private final double AUTONOMOUS_SPEED = 1.0;
    private final double SHOOTING_FAILSAFE = 6.0;
    private final int    AUTONOMOUS_BRIGHTNESS = 3;
    private final int    TELEOP_BRIGHTNESS = 75;
    private final double GATHER_SPEED = 1.0;
    private final int    HALO_DRIVE = 1;
    private final int    TANK_DRIVE = 2;
    private final double DEADBAND_AMOUNT = 0.05;
    private final double ENCODER_MAX_PERIOD = 0.1;
    private final double ENCODER_MIN_RATE = 10.0;
    private final double ENCODER_DISTANCE_PER_PULSE = 0.05; //(39.0/817.0); // inches/count
    private final int    ENCODER_SAMPLES_TO_AVERAGE = 7;
    
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
        driveTrain  = new RobotDrive(1,2);
        Stick       = new Joystick(1);
        rangeFinder = new AnalogChannel(2);
        gyro        = new Gyro(1);
        timer       = new Timer();
        DriveType   = TANK_DRIVE;

        compressor  = new Compressor(1,1);
        LowGear     = new Solenoid(1);
        HighGear    = new Solenoid(2);
        GatherUp    = new Solenoid(3);
        GatherDown  = new Solenoid(4);
        Gather      = new Talon(3);
        Shoot1      = new Talon(4);
        Shoot2      = new Talon(5);
        LeftEncoder = new Encoder(2,3, true, Encoder.EncodingType.k4X);
        RightEncoder= new Encoder(4,5, false, Encoder.EncodingType.k4X); 
        detector    = new TargetDetector();
        detector.init();       
     
        LeftEncoder.setMaxPeriod(ENCODER_MAX_PERIOD);
        LeftEncoder.setMinRate(ENCODER_MIN_RATE);
        LeftEncoder.setDistancePerPulse(ENCODER_DISTANCE_PER_PULSE);
        LeftEncoder.setSamplesToAverage(ENCODER_SAMPLES_TO_AVERAGE);
        
        RightEncoder.setMaxPeriod(ENCODER_MAX_PERIOD);
        RightEncoder.setMinRate(ENCODER_MIN_RATE);
        RightEncoder.setDistancePerPulse(ENCODER_DISTANCE_PER_PULSE);
        RightEncoder.setSamplesToAverage(ENCODER_SAMPLES_TO_AVERAGE);   
        
        LeftEncoder.start();
        RightEncoder.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        boolean isDrivingDone = false;
        
        // Drive until we reach the low goal
        double d = getDistance ();
        if (d < SHOOTING_DISTANCE) {<commit_msg>FRC 2014 project<commit_after>/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.AnalogChannel;
import edu.wpi.first.wpilibj.Gyro;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.CounterBase;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Encoder;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * documentation. If you change the name of this class or the package after
 * creating this project, you must also update the manifest file in the resource
 * directory.
 */
public class RobotTemplate extends IterativeRobot {
    
    // Constants
    private final double RANGEFINDER_SCALE_FACTOR = (1024/5.0);
    private final double SHOOTING_DISTANCE = (194 - 24); //
    private final double AUTONOMOUS_SPEED = 1.0;
    private final double SHOOTING_FAILSAFE = 6.0;
    private final int    AUTONOMOUS_BRIGHTNESS = 3;
    private final int    TELEOP_BRIGHTNESS = 75;
    private final double GATHER_SPEED = 1.0;
    private final int    HALO_DRIVE = 1;
    private final int    TANK_DRIVE = 2;
    private final double DEADBAND_AMOUNT = 0.05;
    private final double ENCODER_MAX_PERIOD = 0.1;
    private final double ENCODER_MIN_RATE = 10.0;
    private final double ENCODER_DISTANCE_PER_PULSE = 0.05; //(39.0/817.0); // inches/count
    private final int    ENCODER_SAMPLES_TO_AVERAGE = 7;
    
    /**
     * This function is run when the robot is first started up and should be
     * used for any initialization code.
     */
    public void robotInit() {
        driveTrain  = new RobotDrive(1,2);
        Stick       = new Joystick(1);
        rangeFinder = new AnalogChannel(2);
        gyro        = new Gyro(1);
        timer       = new Timer();
        DriveType   = TANK_DRIVE;

        compressor  = new Compressor(1,1);
        LowGear     = new Solenoid(1);
        HighGear    = new Solenoid(2);
        GatherUp    = new Solenoid(3);
        GatherDown  = new Solenoid(4);
        Gather      = new Talon(3);
        Shoot1      = new Talon(4);
        Shoot2      = new Talon(5);
        LeftEncoder = new Encoder(2,3, true, Encoder.EncodingType.k4X);
        RightEncoder= new Encoder(4,5, false, Encoder.EncodingType.k4X); 
        detector    = new TargetDetector();
        detector.init();       
     
        // Initialize encoders
        LeftEncoder.setMaxPeriod(ENCODER_MAX_PERIOD);
        LeftEncoder.setMinRate(ENCODER_MIN_RATE);
        LeftEncoder.setDistancePerPulse(ENCODER_DISTANCE_PER_PULSE);
        LeftEncoder.setSamplesToAverage(ENCODER_SAMPLES_TO_AVERAGE);
        
        RightEncoder.setMaxPeriod(ENCODER_MAX_PERIOD);
        RightEncoder.setMinRate(ENCODER_MIN_RATE);
        RightEncoder.setDistancePerPulse(ENCODER_DISTANCE_PER_PULSE);
        RightEncoder.setSamplesToAverage(ENCODER_SAMPLES_TO_AVERAGE);   
        
        LeftEncoder.start();
        RightEncoder.start();
    }

    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        boolean isDrivingDone = false;
        
        // Drive until we reach the low goal
        double d = getDistance ();
        if (d < SHOOTING_DISTANCE) {
{'fraction_non_alphanumeric': 0.11992120167446442, 'fraction_numerical': 0.01699088894360995, 'mean_word_length': 2.2701288244766507, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '9950', 'n_tokens_mistral': 2597, 'n_tokens_neox': 2476, 'n_words': 618}