mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Adds command examples to built examples (#1062)
This commit is contained in:
committed by
Peter Johnson
parent
7cd15aa049
commit
938d5379e6
@@ -29,8 +29,9 @@ templatesTree.list(new FilenameFilter() {
|
||||
templatesMap.put(it, [])
|
||||
}
|
||||
|
||||
|
||||
ext {
|
||||
sharedCvConfigs = examplesMap + templatesMap
|
||||
sharedCvConfigs = examplesMap + templatesMap + [commands: []]
|
||||
staticCvConfigs = [:]
|
||||
useJava = false
|
||||
useCpp = true
|
||||
@@ -40,6 +41,34 @@ apply from: "${rootDir}/shared/opencv.gradle"
|
||||
|
||||
model {
|
||||
components {
|
||||
commands(NativeLibrarySpec) {
|
||||
binaries.all { binary ->
|
||||
if (binary in StaticLibraryBinarySpec) {
|
||||
binary.buildable = false
|
||||
return
|
||||
}
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
||||
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
||||
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
||||
lib project: ':hal', library: 'hal', linkage: 'shared'
|
||||
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
project(':ni-libraries').addNiLibrariesToLinker(binary)
|
||||
}
|
||||
sources {
|
||||
cpp {
|
||||
source {
|
||||
srcDirs = ['src/main/cpp/commands']
|
||||
include '**/*.cpp'
|
||||
}
|
||||
exportedHeaders {
|
||||
srcDirs 'src/main/cpp/commands'
|
||||
include '**/*.h'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
examplesMap.each { key, value ->
|
||||
"${key}"(NativeExecutableSpec) {
|
||||
binaries.all { binary ->
|
||||
|
||||
@@ -16,6 +16,7 @@ if (project.hasProperty("publishVersion")) {
|
||||
|
||||
def baseExamplesArtifactId = 'examples'
|
||||
def baseTemplatesArtifactId = 'templates'
|
||||
def baseCommandsArtifactId = 'commands'
|
||||
def artifactGroupId = 'edu.wpi.first.wpilibc'
|
||||
|
||||
def outputsFolder = file("$project.buildDir/outputs")
|
||||
@@ -46,8 +47,22 @@ task cppTemplatesZip(type: Zip) {
|
||||
}
|
||||
}
|
||||
|
||||
task cppCommandsZip(type: Zip) {
|
||||
destinationDir = outputsFolder
|
||||
baseName = 'wpilibc-commands'
|
||||
|
||||
from(licenseFile) {
|
||||
into '/'
|
||||
}
|
||||
|
||||
from('src/main/cpp/commands') {
|
||||
into 'commands'
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn cppTemplatesZip
|
||||
build.dependsOn cppExamplesZip
|
||||
build.dependsOn cppCommandsZip
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
@@ -66,5 +81,13 @@ publishing {
|
||||
groupId artifactGroupId
|
||||
version pubVersion
|
||||
}
|
||||
|
||||
commands(MavenPublication) {
|
||||
artifact cppCommandsZip
|
||||
|
||||
artifactId = baseCommandsArtifactId
|
||||
groupId artifactGroupId
|
||||
version pubVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeCommand.h"
|
||||
|
||||
ReplaceMeCommand::ReplaceMeCommand() {
|
||||
// Use Requires() here to declare subsystem dependencies
|
||||
// eg. Requires(Robot::chassis.get());
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void ReplaceMeCommand::Initialize() {}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void ReplaceMeCommand::Execute() {}
|
||||
|
||||
// Make this return true when this Command no longer needs to run execute()
|
||||
bool ReplaceMeCommand::IsFinished() { return false; }
|
||||
|
||||
// Called once after isFinished returns true
|
||||
void ReplaceMeCommand::End() {}
|
||||
|
||||
// Called when another command which requires one or more of the same
|
||||
// subsystems is scheduled to run
|
||||
void ReplaceMeCommand::Interrupted() {}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Commands/Command.h>
|
||||
|
||||
class ReplaceMeCommand : public frc::Command {
|
||||
public:
|
||||
ReplaceMeCommand();
|
||||
void Initialize() override;
|
||||
void Execute() override;
|
||||
bool IsFinished() override;
|
||||
void End() override;
|
||||
void Interrupted() override;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeCommandGroup.h"
|
||||
|
||||
ReplaceMeCommandGroup::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.
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Commands/CommandGroup.h>
|
||||
|
||||
class ReplaceMeCommandGroup : public frc::CommandGroup {
|
||||
public:
|
||||
ReplaceMeCommandGroup();
|
||||
};
|
||||
108
wpilibcExamples/src/main/cpp/commands/commands.json
Normal file
108
wpilibcExamples/src/main/cpp/commands/commands.json
Normal file
@@ -0,0 +1,108 @@
|
||||
[
|
||||
{
|
||||
"name": "Command",
|
||||
"description": "Create a base command",
|
||||
"tags": [
|
||||
"command"
|
||||
],
|
||||
"foldername": "command",
|
||||
"headers": [
|
||||
"ReplaceMeCommand.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeCommand"
|
||||
},
|
||||
{
|
||||
"name": "Command Group",
|
||||
"description": "Create a command group",
|
||||
"tags": [
|
||||
"commandgroup"
|
||||
],
|
||||
"foldername": "commandgroup",
|
||||
"headers": [
|
||||
"ReplaceMeCommandGroup.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeCommandGroup.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeCommandGroup"
|
||||
},
|
||||
{
|
||||
"name": "Instant Command",
|
||||
"description": "A command that runs immediately",
|
||||
"tags": [
|
||||
"instantcommand"
|
||||
],
|
||||
"foldername": "instant",
|
||||
"headers": [
|
||||
"ReplaceMeInstantCommand.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeInstantCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeInstantCommand"
|
||||
},
|
||||
{
|
||||
"name": "Subsystem",
|
||||
"description": "A subsystem",
|
||||
"tags": [
|
||||
"subsystem"
|
||||
],
|
||||
"foldername": "subsystem",
|
||||
"headers": [
|
||||
"ReplaceMeSubsystem.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeSubsystem.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeSubsystem"
|
||||
},
|
||||
{
|
||||
"name": "PID Subsystem",
|
||||
"description": "A subsystem that runs a PID loop",
|
||||
"tags": [
|
||||
"pidsubsystem",
|
||||
"pid"
|
||||
],
|
||||
"foldername": "pidsubsystem",
|
||||
"headers": [
|
||||
"ReplaceMePIDSubsystem.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMePIDSubsystem.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMePIDSubsystem"
|
||||
},
|
||||
{
|
||||
"name": "Timed Command",
|
||||
"description": "A command that runs for a specified time",
|
||||
"tags": [
|
||||
"timedcommand"
|
||||
],
|
||||
"foldername": "timed",
|
||||
"headers": [
|
||||
"ReplaceMeTimedCommand.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeTimedCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeTimedCommand"
|
||||
},
|
||||
{
|
||||
"name": "Trigger",
|
||||
"description": "A command that runs off of a trigger",
|
||||
"tags": [
|
||||
"trigger"
|
||||
],
|
||||
"foldername": "trigger",
|
||||
"headers": [
|
||||
"ReplaceMeTrigger.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeTrigger.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeTrigger"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeInstantCommand.h"
|
||||
|
||||
ReplaceMeInstantCommand::ReplaceMeInstantCommand() {
|
||||
// Use Requires() here to declare subsystem dependencies
|
||||
// eg. Requires(Robot::chassis.get());
|
||||
}
|
||||
|
||||
// Called once when the command executes
|
||||
void ReplaceMeInstantCommand::Initialize() {}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Commands/InstantCommand.h"
|
||||
|
||||
class ReplaceMeInstantCommand : public frc::InstantCommand {
|
||||
public:
|
||||
ReplaceMeInstantCommand();
|
||||
void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMePIDSubsystem.h"
|
||||
|
||||
#include <LiveWindow/LiveWindow.h>
|
||||
#include <SmartDashboard/SmartDashboard.h>
|
||||
|
||||
ReplaceMePIDSubsystem::ReplaceMePIDSubsystem()
|
||||
: PIDSubsystem("ReplaceMePIDSubsystem", 1.0, 0.0, 0.0) {
|
||||
// Use these to get going:
|
||||
// SetSetpoint() - Sets where the PID controller should move the system
|
||||
// to
|
||||
// Enable() - Enables the PID controller.
|
||||
}
|
||||
|
||||
double ReplaceMePIDSubsystem::ReturnPIDInput() {
|
||||
// Return your input value for the PID loop
|
||||
// e.g. a sensor, like a potentiometer:
|
||||
// yourPot->SetAverageVoltage() / kYourMaxVoltage;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ReplaceMePIDSubsystem::UsePIDOutput(double output) {
|
||||
// Use output to drive your system, like a motor
|
||||
// e.g. yourMotor->Set(output);
|
||||
}
|
||||
|
||||
void ReplaceMePIDSubsystem::InitDefaultCommand() {
|
||||
// Set the default command for a subsystem here.
|
||||
// SetDefaultCommand(new MySpecialCommand());
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Commands/PIDSubsystem.h>
|
||||
|
||||
class ReplaceMePIDSubsystem : public frc::PIDSubsystem {
|
||||
public:
|
||||
ReplaceMePIDSubsystem();
|
||||
double ReturnPIDInput() override;
|
||||
void UsePIDOutput(double output) override;
|
||||
void InitDefaultCommand() override;
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeSubsystem.h"
|
||||
|
||||
ReplaceMeSubsystem::ReplaceMeSubsystem() : Subsystem("ExampleSubsystem") {}
|
||||
|
||||
void ReplaceMeSubsystem::InitDefaultCommand() {
|
||||
// Set the default command for a subsystem here.
|
||||
// SetDefaultCommand(new MySpecialCommand());
|
||||
}
|
||||
|
||||
// Put methods for controlling this subsystem
|
||||
// here. Call these from Commands.
|
||||
@@ -0,0 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Commands/Subsystem.h>
|
||||
|
||||
class ReplaceMeSubsystem : public frc::Subsystem {
|
||||
private:
|
||||
// It's desirable that everything possible under private except
|
||||
// for methods that implement subsystem capabilities
|
||||
|
||||
public:
|
||||
ReplaceMeSubsystem();
|
||||
void InitDefaultCommand() override;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeTimedCommand.h"
|
||||
|
||||
ReplaceMeTimedCommand::ReplaceMeTimedCommand(double timeout)
|
||||
: TimedCommand(timeout) {
|
||||
// Use Requires() here to declare subsystem dependencies
|
||||
// eg. Requires(Robot::chassis.get());
|
||||
}
|
||||
|
||||
// Called just before this Command runs the first time
|
||||
void ReplaceMeTimedCommand::Initialize() {}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void ReplaceMeTimedCommand::Execute() {}
|
||||
|
||||
// Called once after command times out
|
||||
void ReplaceMeTimedCommand::End() {}
|
||||
|
||||
// Called when another command which requires one or more of the same
|
||||
// subsystems is scheduled to run
|
||||
void ReplaceMeTimedCommand::Interrupted() {}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Commands/TimedCommand.h"
|
||||
|
||||
class ReplaceMeTimedCommand : public frc::TimedCommand {
|
||||
public:
|
||||
explicit ReplaceMeTimedCommand(double timeout);
|
||||
void Initialize() override;
|
||||
void Execute() override;
|
||||
void End() override;
|
||||
void Interrupted() override;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeTrigger.h"
|
||||
|
||||
ReplaceMeTrigger::ReplaceMeTrigger() {}
|
||||
|
||||
bool ReplaceMeTrigger::Get() { return false; }
|
||||
@@ -0,0 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Buttons/Trigger.h>
|
||||
|
||||
class ReplaceMeTrigger : public frc::Trigger {
|
||||
public:
|
||||
ReplaceMeTrigger();
|
||||
bool Get() override;
|
||||
};
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user