Go to Post The most important part of successfully solving the problem is to understand what the problem is. Elegance in engineering comes from "optimizing" your solution, not solving problems that don't really exist. Fulfill your requirements, meet your goals... - JVN [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-10-2015, 23:51
josephno1's Avatar
josephno1 josephno1 is offline
Registered User
FRC #3647
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: murica
Posts: 21
josephno1 is an unknown quantity at this point
Autonomous Code Troubleshooting

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.

Code:
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

    }
Code:
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!
Reply With Quote
  #2   Spotlight this post!  
Unread 17-10-2015, 00:13
Caleb Sykes's Avatar
Caleb Sykes Caleb Sykes is offline
Registered User
FRC #4536 (MinuteBots)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: St. Paul, Minnesota
Posts: 1,054
Caleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond repute
Re: Autonomous Code Troubleshooting

The problem with your code right now is that your move variable is set to true in robotInit but nowhere else. Since robotInit is only called when the roboRio first boots up, your auto code will only run once.

The fix that requires the least changes would probably be to put Auto.move=true into autonomousInit instead of robotInit. However, this may not be the smartest way to go depending on what else your code is doing.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:36.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi