View Single Post
  #1   Spotlight this post!  
Unread 22-05-2015, 20:22
cpapplefamily cpapplefamily is offline
Registered User
FRC #3244 (Granite City Gearheads)
Team Role: Mentor
 
Join Date: May 2015
Rookie Year: 2015
Location: Minnesota
Posts: 256
cpapplefamily has a spectacular aura aboutcpapplefamily has a spectacular aura about
Re: pass a value to a command.

Is what I had:
Code:
public class  DriveSpinInPlace extends Command {
	
    private static LinkedList<Double> fifo = null;
    private static double averagegyro = 0;
    private static boolean sample_gyro = false;
    private static double spin = 0;                         //Declared my "spin" Var 
    private static double spinTarget = 0;
    
    public DriveSpinInPlace(double s) {
        
        requires(Robot.driveSystem);
        spin = s;                                         //Set the spin = passed par
    }

    protected void initialize() {
    	
    	sample_gyro = false;
    	fifo = new LinkedList<Double>();
    	fifo.clear();	
    }

   
    protected void execute() {
        //Do my code
    }
 protected boolean isFinished() {
        return sample_gyro && averagegyro > spinTarget-10 && averagegyro < spinTarget+10;
    }

   
    protected void end() {
    	Robot.driveSystem.driveStraight(0,0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    	end();
    }
}
But all ways reacted to last addSequential(new DriveSpinInPlace(90));
If I have:

Code:
addSequential(new DriveSpinInPlace(90))
addSequential(new DriveSpinInPlace(-180))
addSequential(new DriveSpinInPlace(90))
addSequential(new DriveSpinInPlace(-95))
addSequential(new DriveSpinInPlace(-45))
Every all 5 scheduled commands will do -45.

Am I declaring the correct type of variable?