View Single Post
  #1   Spotlight this post!  
Unread 03-28-2016, 09:48 PM
MRT45's Avatar
MRT45 MRT45 is offline
Registered User
FRC #0253 (Mills Robotics Team)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2013
Location: CA
Posts: 14
MRT45 is an unknown quantity at this point
Autonomous not stopping. Constantly running... during enabling

Hey Guys,
I decided to get autonomous to work this year and ran into the problem of an unlimited run time despite a set stopping point.

Can someone check this out and find the problem? I honestly don't know what the problem is.

I may be overlooking something simple, but I am clearly not seeing it.
Code:
 
    public void autonomousInit() {
        // schedule the autonomous command (example)
       // if (autonomousCommand != null) autonomousCommand.start();
    	//autonomousCommand.start();
    	  // Reset timer to 0sec
    	edu.wpi.first.wpilibj.Timer myTimer = new edu.wpi.first.wpilibj.Timer();
        myTimer.reset();

        // Start timer
        myTimer.start();
    	
       // move(-0.5,3.0);

    }

    /**
     * This function is called periodically during autonomous
     */



 public void autonomousPeriodic() {
// link  -https://www.reddit.com/r/FRC/comments/3zcc2d/timer_not_working/
        // If is has been less than 2 seconds since autonomous started, drive forwards
    	
    	edu.wpi.first.wpilibj.Timer myTimer = new edu.wpi.first.wpilibj.Timer();
        if(myTimer.get() < 2.0){
        	Robot.drivetraintank.setLeft_Back(0.5);
        	Robot.drivetraintank.setLeft(0.5);
        	Robot.drivetraintank.setRight(0.5);
        	Robot.drivetraintank.setRight_Back(0.5);
        }

        // If more than 2 seconds have elapsed, stop driving and turn off the timer
        else {
        	Robot.drivetraintank.setLeft_Back(0.5);
        	Robot.drivetraintank.setLeft(0.5);
        	Robot.drivetraintank.setRight(0.5);
        	Robot.drivetraintank.setRight_Back(0.5);
            myTimer.stop();
        }

    }
    	
    	
       // Scheduler.getInstance().run();
__________________
Member of the MILLS ROBOTICS TEAM - 253

"Everyone and everything is like a formula. You may seem small, but God has spent a long time making you right." - Wayne Phillips
Reply With Quote