Edit: (I got his name wrong, should be Minyoung)
Minyoung posted this:
Someone please tell me if this is going to work:
//don't delete the comments until you do what it said because they're important
package org.usfirst.frc.team6662.robot.commands;
import edu.wpi.first.wpilibj.command.Command;
import org.usfirst.frc.team6662.robot.Robot;
public class TurnLeft extends Command{
public TurnLeft(){
requires(Robot.drivetrain);
}
@Override
protected void initialize(){
//the gyro is already calibrated in robotInit through drivetrain subsystem
}
@Override
protected void execute(){
while (Robot.drivetrain.getAngle()< 90) { //someone needs to make getAngle() in Drivetrain
Robot.drivetrain.drive(-1, 1);
}
@Override
protected boolean isFinished(){
return false;
}
}
This code will probably work. However, it has things that could be improved:
The constructor could take an angle parameter to make the code more flexible (you'd have to also store it within the class so execute can use it).
Is the robot turning in high or low gear? I would suggest making it turn only in low gear.
isFinished needs to return true after the while loop finishes. This could be accomplished with a member variable.
It may sense to make drive be implemented so as to store the speed in the counterclockwise direction looking at the wheel. If this is the case you may have to adjust the arguments of drive.
Edit: (I got his name wrong, should be Minyoung) Minyoung posted this:
Someone please tell me if this is going to work:
This code will probably work. However, it has things that could be improved:
Have you guys bought gyro/encoders?