Adds command examples to built examples (#1062)

This commit is contained in:
Thad House
2018-05-15 23:56:03 -07:00
committed by Peter Johnson
parent 7cd15aa049
commit 938d5379e6
26 changed files with 771 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ if (project.hasProperty("publishVersion")) {
def baseExamplesArtifactId = 'examples'
def baseTemplatesArtifactId = 'templates'
def baseCommandsArtifactId = 'commands'
def artifactGroupId = 'edu.wpi.first.wpilibj'
def outputsFolder = file("$project.buildDir/outputs")
@@ -46,8 +47,22 @@ task javaTemplatesZip(type: Zip) {
}
}
task javaCommandsZip(type: Zip) {
destinationDir = outputsFolder
baseName = 'wpilibj-commands'
from(licenseFile) {
into '/'
}
from('src/main/java/edu/wpi/first/wpilibj/commands') {
into 'commands'
}
}
build.dependsOn javaTemplatesZip
build.dependsOn javaExamplesZip
build.dependsOn javaCommandsZip
publishing {
publications {
@@ -66,5 +81,13 @@ publishing {
groupId artifactGroupId
version pubVersion
}
commands(MavenPublication) {
artifact javaCommandsZip
artifactId = baseCommandsArtifactId
groupId artifactGroupId
version pubVersion
}
}
}

View File

@@ -0,0 +1,43 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.commands.command;
import edu.wpi.first.wpilibj.command.Command;
public class ReplaceMeCommand extends Command {
public ReplaceMeCommand() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
}
// Called just before this Command runs the first time
@Override
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
}
// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished() {
return false;
}
// Called once after isFinished returns true
@Override
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
}
}

View File

@@ -0,0 +1,31 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.commands.commandgroup;
import edu.wpi.first.wpilibj.command.CommandGroup;
public class ReplaceMeCommandGroup extends CommandGroup {
public ReplaceMeCommandGroup() {
// Add Commands here:
// e.g. addSequential(new Command1());
// addSequential(new Command2());
// these will run in order.
// To run multiple commands at the same time,
// use addParallel()
// e.g. addParallel(new Command1());
// addSequential(new Command2());
// Command1 and Command2 will run in parallel.
// A command group will require all of the subsystems that each member
// would require.
// e.g. if Command1 requires chassis, and Command2 requires arm,
// a CommandGroup containing them would require both the chassis and the
// arm.
}
}

View File

@@ -0,0 +1,66 @@
[
{
"name": "Command",
"description": "Create a base command",
"tags": [
"command"
],
"foldername": "command",
"replacename": "ReplaceMeCommand"
},
{
"name": "Command Group",
"description": "Create a command group",
"tags": [
"commandgroup"
],
"foldername": "commandgroup",
"replacename": "ReplaceMeCommandGroup"
},
{
"name": "Instant Command",
"description": "A command that runs immediately",
"tags": [
"instantcommand"
],
"foldername": "instant",
"replacename": "ReplaceMeInstantCommand"
},
{
"name": "Subsystem",
"description": "A subsystem",
"tags": [
"subsystem"
],
"foldername": "subsystem",
"replacename": "ReplaceMeSubsystem"
},
{
"name": "PID Subsystem",
"description": "A subsystem that runs a PID loop",
"tags": [
"pidsubsystem",
"pid"
],
"foldername": "pidsubsystem",
"replacename": "ReplaceMePIDSubsystem"
},
{
"name": "Timed Command",
"description": "A command that runs for a specified time",
"tags": [
"timedcommand"
],
"foldername": "timed",
"replacename": "ReplaceMeTimedCommand"
},
{
"name": "Trigger",
"description": "A command that runs off of a trigger",
"tags": [
"trigger"
],
"foldername": "trigger",
"replacename": "ReplaceMeTrigger"
}
]

View File

@@ -0,0 +1,27 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.commands.instant;
import edu.wpi.first.wpilibj.command.InstantCommand;
/**
* Add your docs here.
*/
public class ReplaceMeInstantCommand extends InstantCommand {
public ReplaceMeInstantCommand() {
super();
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
}
// Called once when the command executes
@Override
protected void initialize() {
}
}

View File

@@ -0,0 +1,45 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.commands.pidsubsystem;
import edu.wpi.first.wpilibj.command.PIDSubsystem;
/**
* Add your docs here.
*/
public class ReplaceMePIDSubsystem extends PIDSubsystem {
// Initialize your subsystem here
public ReplaceMePIDSubsystem() {
// Intert a subsystem name and PID values here
super("SubsystemName", 1, 2, 3);
// Use these to get going:
// setSetpoint() - Sets where the PID controller should move the system
// to
// enable() - Enables the PID controller.
}
@Override
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
@Override
protected double returnPIDInput() {
// Return your input value for the PID loop
// e.g. a sensor, like a potentiometer:
// yourPot.getAverageVoltage() / kYourMaxVoltage;
return 0.0;
}
@Override
protected void usePIDOutput(double output) {
// Use output to drive your system, like a motor
// e.g. yourMotor.set(output);
}
}

View File

@@ -0,0 +1,24 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.commands.subsystem;
import edu.wpi.first.wpilibj.command.Subsystem;
/**
* Add your docs here.
*/
public class ReplaceMeSubsystem extends Subsystem {
// Put methods for controlling this subsystem
// here. Call these from Commands.
@Override
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
}

View File

@@ -0,0 +1,42 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.commands.timed;
import edu.wpi.first.wpilibj.command.TimedCommand;
/**
* Add your docs here.
*/
public class ReplaceMeTimedCommand extends TimedCommand {
public ReplaceMeTimedCommand(double timeout) {
super(timeout);
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
}
// Called just before this Command runs the first time
@Override
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
}
// Called once after timeout
@Override
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted() {
}
}

View File

@@ -0,0 +1,20 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.commands.trigger;
import edu.wpi.first.wpilibj.buttons.Trigger;
/**
* Add your docs here.
*/
public class ReplaceMeTrigger extends Trigger {
@Override
public boolean get() {
return false;
}
}