<commit_before>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.stuy.commands;

import edu.wpi.first.wpilibj.Timer;

/**
 *
 * @author English
 */
public abstract class AutonDrive extends CommandBase {
    private int direction;
    private double timeoutTime;
    private double leftSpeed, rightSpeed;
    public double startTime = -1;

    //Low gear speed 4 ft/s
    //High gear speed 10 ft/s
    public AutonDrive(int direction, double time) {
        // Use requires() here to declare subsystem dependencies
        requires(drivetrain);
        this.direction = direction;
        leftSpeed = 0.6;
        rightSpeed = 0.6;
        timeoutTime = time;
    }
    
    public AutonDrive(int direction, double leftSpeed, double rightSpeed, double time) {
        this(1, time);
        this.leftSpeed = leftSpeed;
        this.rightSpeed = rightSpeed;
    }

    // Called just before this Command runs the first time
    protected void initialize() {
        this.setTimeout(timeoutTime);
    }

    // Called repeatedly when this Command is scheduled to run
    public void execute(){
        double leftSpeedRamp, rightSpeedRamp;

        double runTime;
        if (startTime < 0) {
            startTime = Timer.getFPGATimestamp();
            runTime = 0;
        }
        else {
            runTime = Timer.getFPGATimestamp() - startTime;
        }

        if (runTime < 0.1) {
            leftSpeedRamp = 0.3;
            rightSpeedRamp = 0.3;
        }
        else if (runTime < 0.25) {
            leftSpeedRamp = 0.5;
            rightSpeedRamp = 0.5;
        }
        else {
            leftSpeedRamp = leftSpeed;
            rightSpeedRamp = rightSpeed;
        }

        drivetrain.tankDrive(leftSpeedRamp * direction, rightSpeedRamp * direction);
        // slower than full speed so that we actually bring down the bridge,
        // not just slam it and push balls the wrong way
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return isTimedOut();
    }

    // Called once after isFinished returns true
    protected void end() {
        drivetrain.tankDrive(0, 0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
        end();
    }
}
<commit_msg>Change ramping to use ratios instead of repeated values.<commit_after>/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.stuy.commands;

import edu.wpi.first.wpilibj.Timer;

/**
 *
 * @author English
 */
public abstract class AutonDrive extends CommandBase {
    private int direction;
    private double timeoutTime;
    private double leftSpeed, rightSpeed;
    public double startTime = -1;

    //Low gear speed 4 ft/s
    //High gear speed 10 ft/s
    public AutonDrive(int direction, double time) {
        // Use requires() here to declare subsystem dependencies
        requires(drivetrain);
        this.direction = direction;
        leftSpeed = 0.6;
        rightSpeed = 0.6;
        timeoutTime = time;
    }
    
    public AutonDrive(int direction, double leftSpeed, double rightSpeed, double time) {
        this(1, time);
        this.leftSpeed = leftSpeed;
        this.rightSpeed = rightSpeed;
    }

    // Called just before this Command runs the first time
    protected void initialize() {
        this.setTimeout(timeoutTime);
    }

    // Called repeatedly when this Command is scheduled to run
    public void execute(){
        double leftSpeedRamp, rightSpeedRamp;

        double runTime;
        if (startTime < 0) {
            startTime = Timer.getFPGATimestamp();
            runTime = 0;
        }
        else {
            runTime = Timer.getFPGATimestamp() - startTime;
        }

        if (runTime < 0.1) {
            leftSpeedRamp = 0.5 * leftSpeed;
            rightSpeedRamp = 0.5 * rightSpeed;
        }
        else if (runTime < 0.25) {
            leftSpeedRamp = 0.75 * leftSpeed;
            rightSpeedRamp = 0.75 * rightSpeed;
        }
        else {
            leftSpeedRamp = leftSpeed;
            rightSpeedRamp = rightSpeed;
        }

        drivetrain.tankDrive(leftSpeedRamp * direction, rightSpeedRamp * direction);
        // slower than full speed so that we actually bring down the bridge,
        // not just slam it and push balls the wrong way
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return isTimedOut();
    }

    // Called once after isFinished returns true
    protected void end() {
        drivetrain.tankDrive(0, 0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
        end();
    }
}

{'fraction_non_alphanumeric': 0.08055723803755299, 'fraction_numerical': 0.010902483343428226, 'mean_word_length': 2.061804697156984, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6020597', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1337, 'n_words': 460}