Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit 60f8007

Browse files
committed
new project
- created a new, empty, command-based robot project - created and filled out a .gitignore
1 parent 89d5970 commit 60f8007

10 files changed

Lines changed: 300 additions & 0 deletions

File tree

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>RobotCode2018</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

Robot2018/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/bin/
2+
/build/
3+
/dist/
4+
.classpath
5+
.DS_Store

Robot2018/.project

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Robot2018</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
<nature>edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature</nature>
17+
</natures>
18+
</projectDescription>

Robot2018/build.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Project specific information
2+
package=org.usfirst.frc.team199.robot
3+
robot.class=${package}.Robot
4+
simulation.world.file=/usr/share/frcsim/worlds/GearsBotDemo.world

Robot2018/build.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project name="FRC Deployment" default="deploy">
4+
5+
<!--
6+
The following properties can be defined to override system level
7+
settings. These should not be touched unless you know what you're
8+
doing. The primary use is to override the wpilib version when
9+
working with older robots that can't compile with the latest
10+
libraries.
11+
-->
12+
13+
<!-- By default the system version of WPI is used -->
14+
<!-- <property name="version" value=""/> -->
15+
16+
<!-- By default the system team number is used -->
17+
<!-- <property name="team-number" value=""/> -->
18+
19+
<!-- By default the target is set to 10.TE.AM.2 -->
20+
<!-- <property name="target" value=""/> -->
21+
22+
<!-- Any other property in build.properties can also be overridden. -->
23+
24+
<property file="${user.home}/wpilib/wpilib.properties"/>
25+
<property file="build.properties"/>
26+
<property file="${user.home}/wpilib/java/${version}/ant/build.properties"/>
27+
28+
<import file="${wpilib.ant.dir}/build.xml"/>
29+
30+
</project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.usfirst.frc.team199.robot;
2+
3+
import edu.wpi.first.wpilibj.buttons.Button;
4+
5+
import org.usfirst.frc.team199.robot.commands.ExampleCommand;
6+
7+
/**
8+
* This class is the glue that binds the controls on the physical operator
9+
* interface to the commands and command groups that allow control of the robot.
10+
*/
11+
public class OI {
12+
//// CREATING BUTTONS
13+
// One type of button is a joystick button which is any button on a
14+
//// joystick.
15+
// You create one by telling it which joystick it's on and which button
16+
// number it is.
17+
// Joystick stick = new Joystick(port);
18+
// Button button = new JoystickButton(stick, buttonNumber);
19+
20+
// There are a few additional built in buttons you can use. Additionally,
21+
// by subclassing Button you can create custom triggers and bind those to
22+
// commands the same as any other Button.
23+
24+
//// TRIGGERING COMMANDS WITH BUTTONS
25+
// Once you have a button, it's trivial to bind it to a button in one of
26+
// three ways:
27+
28+
// Start the command when the button is pressed and let it run the command
29+
// until it is finished as determined by it's isFinished method.
30+
// button.whenPressed(new ExampleCommand());
31+
32+
// Run the command while the button is being held down and interrupt it once
33+
// the button is released.
34+
// button.whileHeld(new ExampleCommand());
35+
36+
// Start the command when the button is released and let it run the command
37+
// until it is finished as determined by it's isFinished method.
38+
// button.whenReleased(new ExampleCommand());
39+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
2+
package org.usfirst.frc.team199.robot;
3+
4+
import edu.wpi.first.wpilibj.IterativeRobot;
5+
import edu.wpi.first.wpilibj.command.Command;
6+
import edu.wpi.first.wpilibj.command.Scheduler;
7+
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
8+
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
9+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
10+
11+
import org.usfirst.frc.team199.robot.commands.ExampleCommand;
12+
import org.usfirst.frc.team199.robot.subsystems.ExampleSubsystem;
13+
14+
/**
15+
* The VM is configured to automatically run this class, and to call the
16+
* functions corresponding to each mode, as described in the IterativeRobot
17+
* documentation. If you change the name of this class or the package after
18+
* creating this project, you must also update the manifest file in the resource
19+
* directory.
20+
*/
21+
public class Robot extends IterativeRobot {
22+
23+
public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
24+
public static OI oi;
25+
26+
Command autonomousCommand;
27+
SendableChooser<Command> chooser = new SendableChooser<>();
28+
29+
/**
30+
* This function is run when the robot is first started up and should be
31+
* used for any initialization code.
32+
*/
33+
@Override
34+
public void robotInit() {
35+
oi = new OI();
36+
chooser.addDefault("Default Auto", new ExampleCommand());
37+
// chooser.addObject("My Auto", new MyAutoCommand());
38+
SmartDashboard.putData("Auto mode", chooser);
39+
}
40+
41+
/**
42+
* This function is called once each time the robot enters Disabled mode.
43+
* You can use it to reset any subsystem information you want to clear when
44+
* the robot is disabled.
45+
*/
46+
@Override
47+
public void disabledInit() {
48+
49+
}
50+
51+
@Override
52+
public void disabledPeriodic() {
53+
Scheduler.getInstance().run();
54+
}
55+
56+
/**
57+
* This autonomous (along with the chooser code above) shows how to select
58+
* between different autonomous modes using the dashboard. The sendable
59+
* chooser code works with the Java SmartDashboard. If you prefer the
60+
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
61+
* getString code to get the auto name from the text box below the Gyro
62+
*
63+
* You can add additional auto modes by adding additional commands to the
64+
* chooser code above (like the commented example) or additional comparisons
65+
* to the switch structure below with additional strings & commands.
66+
*/
67+
@Override
68+
public void autonomousInit() {
69+
autonomousCommand = chooser.getSelected();
70+
71+
/*
72+
* String autoSelected = SmartDashboard.getString("Auto Selector",
73+
* "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
74+
* = new MyAutoCommand(); break; case "Default Auto": default:
75+
* autonomousCommand = new ExampleCommand(); break; }
76+
*/
77+
78+
// schedule the autonomous command (example)
79+
if (autonomousCommand != null)
80+
autonomousCommand.start();
81+
}
82+
83+
/**
84+
* This function is called periodically during autonomous
85+
*/
86+
@Override
87+
public void autonomousPeriodic() {
88+
Scheduler.getInstance().run();
89+
}
90+
91+
@Override
92+
public void teleopInit() {
93+
// This makes sure that the autonomous stops running when
94+
// teleop starts running. If you want the autonomous to
95+
// continue until interrupted by another command, remove
96+
// this line or comment it out.
97+
if (autonomousCommand != null)
98+
autonomousCommand.cancel();
99+
}
100+
101+
/**
102+
* This function is called periodically during operator control
103+
*/
104+
@Override
105+
public void teleopPeriodic() {
106+
Scheduler.getInstance().run();
107+
}
108+
109+
/**
110+
* This function is called periodically during test mode
111+
*/
112+
@Override
113+
public void testPeriodic() {
114+
LiveWindow.run();
115+
}
116+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.usfirst.frc.team199.robot;
2+
3+
/**
4+
* The RobotMap is a mapping from the ports sensors and actuators are wired into
5+
* to a variable name. This provides flexibility changing wiring, makes checking
6+
* the wiring easier and significantly reduces the number of magic numbers
7+
* floating around.
8+
*/
9+
public class RobotMap {
10+
// For example to map the left and right motors, you could define the
11+
// following variables to use with your drivetrain subsystem.
12+
// public static int leftMotor = 1;
13+
// public static int rightMotor = 2;
14+
15+
// If you are using multiple modules, make sure to define both the port
16+
// number and the module. For example you with a rangefinder:
17+
// public static int rangefinderPort = 1;
18+
// public static int rangefinderModule = 1;
19+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.usfirst.frc.team199.robot.commands;
2+
3+
import edu.wpi.first.wpilibj.command.Command;
4+
5+
import org.usfirst.frc.team199.robot.Robot;
6+
7+
/**
8+
*
9+
*/
10+
public class ExampleCommand extends Command {
11+
public ExampleCommand() {
12+
// Use requires() here to declare subsystem dependencies
13+
requires(Robot.exampleSubsystem);
14+
}
15+
16+
// Called just before this Command runs the first time
17+
@Override
18+
protected void initialize() {
19+
}
20+
21+
// Called repeatedly when this Command is scheduled to run
22+
@Override
23+
protected void execute() {
24+
}
25+
26+
// Make this return true when this Command no longer needs to run execute()
27+
@Override
28+
protected boolean isFinished() {
29+
return false;
30+
}
31+
32+
// Called once after isFinished returns true
33+
@Override
34+
protected void end() {
35+
}
36+
37+
// Called when another command which requires one or more of the same
38+
// subsystems is scheduled to run
39+
@Override
40+
protected void interrupted() {
41+
}
42+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.usfirst.frc.team199.robot.subsystems;
2+
3+
import edu.wpi.first.wpilibj.command.Subsystem;
4+
5+
/**
6+
*
7+
*/
8+
public class ExampleSubsystem extends Subsystem {
9+
// Put methods for controlling this subsystem
10+
// here. Call these from Commands.
11+
12+
public void initDefaultCommand() {
13+
// Set the default command for a subsystem here.
14+
// setDefaultCommand(new MySpecialCommand());
15+
}
16+
}

0 commit comments

Comments
 (0)