Add back SampleRobot Template

Add GettingStarted example based on IterativeRobot

Change-Id: Ic8caec4f62b7bdbaae7fafedfec5859b2f936809
This commit is contained in:
Kevin O'Connor
2014-08-14 07:46:49 -04:00
parent 70d09de2e9
commit 597e209c09
9 changed files with 190 additions and 5 deletions

View File

@@ -0,0 +1,69 @@
package $package;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class Robot extends IterativeRobot {
RobotDrive myRobot;
Joystick stick;
int autoLoopCounter;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
myRobot = new RobotDrive(0,1);
stick = new Joystick(1);
}
/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
myRobot.drive(-0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
myRobot.drive(0.0, 0.0); // stop robot
}
}
/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
myRobot.arcadeDrive(stick);
}
/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
LiveWindow.run();
}
}

View File

@@ -15,6 +15,25 @@
<name>Simulation</name>
<description>Examples that can be run in simulation.</description>
</tagDescription>-->
<tagDescription>
<name>Getting Started with Java</name>
<description>Examples for getting started with FRC Java</description>
</tagDescription>
<example>
<name>Getting Started</name>
<description>An example program which demonstrates the simplest autonomous and
teleoperated routines.</description>
<tags>
<tag>Getting Started with Java</tag>
</tags>
<packages>
<package>src/$package-dir</package>
</packages>
<files>
<file source="examples/GettingStarted/src/org/usfirst/frc/team190/robot/Robot.java"
destination="src/$package-dir/Robot.java"></file>
</files>
</example>
<tagDescription>
<name>CommandBased Robot</name>
<description>Examples for CommandBased robot programs.</description>

View File

@@ -3,6 +3,9 @@ package $package;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
/**
* This is a demo program showing the use of the RobotDrive class.

View File

@@ -8,10 +8,10 @@ import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType;
import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin;
public class JavaProjectType implements ProjectType {
static ProjectType SIMPLE = new JavaProjectType() {
static ProjectType SAMPLE = new JavaProjectType() {
@Override public Map<String, String> getFiles(String packageName) {
Map<String, String> files = super.getFiles(packageName);
files.put("src/"+packageName.replace(".", "/")+"/Robot.java", "simple/Robot.java");
files.put("src/"+packageName.replace(".", "/")+"/Robot.java", "sample/Robot.java");
return files;
}
};
@@ -40,7 +40,7 @@ public class JavaProjectType implements ProjectType {
};
@SuppressWarnings("serial")
static Map<String, ProjectType> TYPES = new HashMap<String, ProjectType>() {{
put(ProjectType.SIMPLE, SIMPLE);
put(ProjectType.SAMPLE, SAMPLE);
put(ProjectType.ITERATIVE, ITERATIVE);
put(ProjectType.COMMAND_BASED, COMMAND_BASED);
}};