josephno1
16-10-2015, 23:51
An issue that I am currently having trouble with Autonomous is that it only performs the code once. For example if it hit enable, the code will run perfectly however once I Disable it and hit Enable again, the code will not run.
Here is the portion of code that is in question.
public class Robot extends IterativeRobot {
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
Camera.USBCamInit(); //runs USB Camera
Auto.move=true; //Sets a variable to be true in the Auto class
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
Auto.trashCan(); //This is the autonomous task
}
package org.usfirst.frc.team3647.robot;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
public class Auto {
//static boolean move= false;
public static boolean move;
public static void trashCan()
{
if (move){
TrashCanLifter.lifter.set(1);
Timer.delay(7);
TrashCanLifter.lifter.set(0);
move=false;
}
}
}
The end goal that I want it to do is the run the autonomous portion every time I hit enable instead of the autonomous portion to only work the first time I hit Enable.
Thanks!
Here is the portion of code that is in question.
public class Robot extends IterativeRobot {
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
Camera.USBCamInit(); //runs USB Camera
Auto.move=true; //Sets a variable to be true in the Auto class
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
Auto.trashCan(); //This is the autonomous task
}
package org.usfirst.frc.team3647.robot;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Timer;
public class Auto {
//static boolean move= false;
public static boolean move;
public static void trashCan()
{
if (move){
TrashCanLifter.lifter.set(1);
Timer.delay(7);
TrashCanLifter.lifter.set(0);
move=false;
}
}
}
The end goal that I want it to do is the run the autonomous portion every time I hit enable instead of the autonomous portion to only work the first time I hit Enable.
Thanks!