Add templates for new commands for vscode plugin (#2016)

This commit is contained in:
Oblarg
2019-12-29 16:02:49 -05:00
committed by Peter Johnson
parent 6ea13ea8f3
commit 5b7dd186d2
45 changed files with 1354 additions and 35 deletions

View File

@@ -0,0 +1,40 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.command2;
import edu.wpi.first.wpilibj2.command.CommandBase;
public class ReplaceMeCommand extends CommandBase {
/**
* Creates a new ReplaceMeCommand.
*/
public ReplaceMeCommand() {
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@@ -6,34 +6,38 @@
"class"
],
"foldername": "emptyclass",
"replacename": "ReplaceMeEmptyClass"
"replacename": "ReplaceMeEmptyClass",
"commandversion": 0
},
{
"name": "Command",
"name": "Command (Old)",
"description": "Create a base command",
"tags": [
"command"
],
"foldername": "command",
"replacename": "ReplaceMeCommand"
"replacename": "ReplaceMeCommand",
"commandversion": 1
},
{
"name": "Command Group",
"name": "Command Group (Old)",
"description": "Create a command group",
"tags": [
"commandgroup"
],
"foldername": "commandgroup",
"replacename": "ReplaceMeCommandGroup"
"replacename": "ReplaceMeCommandGroup",
"commandversion": 1
},
{
"name": "Instant Command",
"name": "Instant Command (Old)",
"description": "A command that runs immediately",
"tags": [
"instantcommand"
],
"foldername": "instant",
"replacename": "ReplaceMeInstantCommand"
"replacename": "ReplaceMeInstantCommand",
"commandversion": 1
},
{
"name": "Subsystem",
@@ -42,34 +46,168 @@
"subsystem"
],
"foldername": "subsystem",
"replacename": "ReplaceMeSubsystem"
"replacename": "ReplaceMeSubsystem",
"commandversion": 1
},
{
"name": "PID Subsystem",
"name": "PID Subsystem (Old)",
"description": "A subsystem that runs a PID loop",
"tags": [
"pidsubsystem",
"pid"
],
"foldername": "pidsubsystem",
"replacename": "ReplaceMePIDSubsystem"
"replacename": "ReplaceMePIDSubsystem",
"commandversion": 1
},
{
"name": "Timed Command",
"name": "Timed Command (Old)",
"description": "A command that runs for a specified time",
"tags": [
"timedcommand"
],
"foldername": "timed",
"replacename": "ReplaceMeTimedCommand"
"replacename": "ReplaceMeTimedCommand",
"commandversion": 1
},
{
"name": "Trigger",
"name": "Trigger (Old)",
"description": "A command that runs off of a trigger",
"tags": [
"trigger"
],
"foldername": "trigger",
"replacename": "ReplaceMeTrigger"
"replacename": "ReplaceMeTrigger",
"commandversion": 1
},
{
"name": "Command (New)",
"description": "A command.",
"tags": [
"command"
],
"foldername": "command2",
"replacename": "ReplaceMeCommand",
"commandversion": 2
},
{
"name": "InstantCommand (New)",
"description": "A command that finishes instantly.",
"tags": [
"instantcommand"
],
"foldername": "instantcommand",
"replacename": "ReplaceMeInstantCommand",
"commandversion": 2
},
{
"name": "ParallelCommandGroup (New)",
"description": "A command group that runs commands in parallel, ending when all commands have finished.",
"tags": [
"parallelcommandgroup"
],
"foldername": "parallelcommandgroup",
"replacename": "ReplaceMeParallelCommandGroup",
"commandversion": 2
},
{
"name": "ParallelDeadlineGroup (New)",
"description": "A command group that runs commands in parallel, ending when a specific command has finished.",
"tags": [
"paralleldeadlinegroup"
],
"foldername": "paralleldeadlinegroup",
"replacename": "ReplaceMeParallelDeadlineGroup",
"commandversion": 2
},
{
"name": "ParallelRaceGroup (New)",
"description": "A command that runs commands in parallel, ending as soon as any command has finished.",
"tags": [
"parallelracegroup"
],
"foldername": "parallelracegroup",
"replacename": "ReplaceMeParallelRaceGroup",
"commandversion": 2
},
{
"name": "PIDCommand (New)",
"description": "A command that runs a PIDController.",
"tags": [
"pidcommand"
],
"foldername": "pidcommand",
"replacename": "ReplaceMePIDCommand",
"commandversion": 2
},
{
"name": "PIDSubsystem (New)",
"description": "A subsystem that runs a PIDController.",
"tags": [
"pidsubsystem"
],
"foldername": "pidsubsystem2",
"replacename": "ReplaceMePIDSubsystem",
"commandversion": 2
},
{
"name": "ProfiledPIDCommand (New)",
"description": "A command that runs a ProfiledPIDController.",
"tags": [
"profiledpidcommand"
],
"foldername": "profiledpidcommand",
"replacename": "ReplaceMeProfiledPIDCommand",
"commandversion": 2
},
{
"name": "ProfiledPIDSubsystem (New)",
"description": "A subsystem that runs a ProfiledPIDController.",
"tags": [
"profiledpidsubsystem"
],
"foldername": "profiledpidsubsystem",
"replacename": "ReplaceMeProfiledPIDSubsystem",
"commandversion": 2
},
{
"name": "SequentialCommandGroup (New)",
"description": "A command group that runs commands in sequence.",
"tags": [
"sequentialcommandgroup"
],
"foldername": "sequentialcommandgroup",
"replacename": "ReplaceMeSequentialCommandGroup",
"commandversion": 2
},
{
"name": "Subsystem (New)",
"description": "A robot subsystem.",
"tags": [
"subsystem"
],
"foldername": "subsystem2",
"replacename": "ReplaceMeSubsystem",
"commandversion": 2
},
{
"name": "TrapezoidProfileCommand (New)",
"description": "A command that executes a trapezoidal motion profile.",
"tags": [
"trapezoidprofilecommand"
],
"foldername": "trapezoidprofilecommand",
"replacename": "ReplaceMeTrapezoidProfileCommand",
"commandversion": 2
},
{
"name": "TrapezoidProfileSubsystem (New)",
"description": "A command that executes a trapezoidal motion profile.",
"tags": [
"trapezoidprofilesubsystem"
],
"foldername": "trapezoidprofilesubsystem",
"replacename": "ReplaceMeTrapezoidProfileSubsystem",
"commandversion": 2
}
]

View File

@@ -0,0 +1,24 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.instantcommand;
import edu.wpi.first.wpilibj2.command.InstantCommand;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMeInstantCommand extends InstantCommand {
public ReplaceMeInstantCommand() {
// Use addRequirements() here to declare subsystem dependencies.
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
}
}

View File

@@ -0,0 +1,23 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.parallelcommandgroup;
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMeParallelCommandGroup extends ParallelCommandGroup {
/**
* Creates a new ReplaceMeParallelCommandGroup.
*/
public ReplaceMeParallelCommandGroup() {
// Add your commands in the super() call, e.g.
// super(new FooCommand(), new BarCommand());super();
}
}

View File

@@ -0,0 +1,26 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.paralleldeadlinegroup;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMeParallelDeadlineGroup extends ParallelDeadlineGroup {
/**
* Creates a new ReplaceMeParallelDeadlineGroup.
*/
public ReplaceMeParallelDeadlineGroup() {
// Add your commands in the super() call. Add the deadline first.
super(
new InstantCommand()
);
}
}

View File

@@ -0,0 +1,24 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.parallelracegroup;
import edu.wpi.first.wpilibj2.command.ParallelRaceGroup;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMeParallelRaceGroup extends ParallelRaceGroup {
/**
* Creates a new ReplaceMeParallelRaceGroup.
*/
public ReplaceMeParallelRaceGroup() {
// Add your commands in the super() call, e.g.
// super(new FooCommand(), new BarCommand());
super();
}
}

View File

@@ -0,0 +1,41 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.pidcommand;
import edu.wpi.first.wpilibj.controller.PIDController;
import edu.wpi.first.wpilibj2.command.PIDCommand;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMePIDCommand extends PIDCommand {
/**
* Creates a new ReplaceMePIDCommand.
*/
public ReplaceMePIDCommand() {
super(
// The controller that the command will use
new PIDController(0, 0, 0),
// This should return the measurement
() -> 0,
// This should return the setpoint (can also be a constant)
() -> 0,
// This uses the output
output -> {
// Use the output here
});
// Use addRequirements() here to declare subsystem dependencies.
// Configure additional PID options by calling `getController` here.
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@@ -0,0 +1,33 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.pidsubsystem2;
import edu.wpi.first.wpilibj.controller.PIDController;
import edu.wpi.first.wpilibj2.command.PIDSubsystem;
public class ReplaceMePIDSubsystem extends PIDSubsystem {
/**
* Creates a new ReplaceMePIDSubsystem.
*/
public ReplaceMePIDSubsystem() {
super(
// The PIDController used by the subsystem
new PIDController(0, 0, 0));
}
@Override
public void useOutput(double output, double setpoint) {
// Use the output here
}
@Override
public double getMeasurement() {
// Return the process variable measurement here
return 0;
}
}

View File

@@ -0,0 +1,46 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.profiledpidcommand;
import edu.wpi.first.wpilibj.controller.ProfiledPIDController;
import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
import edu.wpi.first.wpilibj2.command.ProfiledPIDCommand;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMeProfiledPIDCommand extends ProfiledPIDCommand {
/**
* Creates a new ReplaceMeProfiledPIDCommand.
*/
public ReplaceMeProfiledPIDCommand() {
super(
// The ProfiledPIDController used by the command
new ProfiledPIDController(
// The PID gains
0, 0, 0,
// The motion profile constraints
new TrapezoidProfile.Constraints(0, 0)),
// This should return the measurement
() -> 0,
// This should return the goal (can also be a constant)
() -> new TrapezoidProfile.State(),
// This uses the output
(output, setpoint) -> {
// Use the output (and setpoint, if desired) here
});
// Use addRequirements() here to declare subsystem dependencies.
// Configure additional PID options by calling `getController` here.
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@@ -0,0 +1,36 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.profiledpidsubsystem;
import edu.wpi.first.wpilibj.controller.ProfiledPIDController;
import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
import edu.wpi.first.wpilibj2.command.ProfiledPIDSubsystem;
public class ReplaceMeProfiledPIDSubsystem extends ProfiledPIDSubsystem {
/**
* Creates a new ReplaceMeProfiledPIDSubsystem.
*/
public ReplaceMeProfiledPIDSubsystem() {
super(
// The ProfiledPIDController used by the subsystem
new ProfiledPIDController(0, 0, 0,
// The motion profile constraints
new TrapezoidProfile.Constraints(0, 0)));
}
@Override
public void useOutput(double output, TrapezoidProfile.State setpoint) {
// Use the output (and optionally the setpoint) here
}
@Override
public double getMeasurement() {
// Return the process variable measurement here
return 0;
}
}

View File

@@ -0,0 +1,24 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.sequentialcommandgroup;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMeSequentialCommandGroup extends SequentialCommandGroup {
/**
* Creates a new ReplaceMeSequentialCommandGroup.
*/
public ReplaceMeSequentialCommandGroup() {
// Add your commands in the super() call, e.g.
// super(new FooCommand(), new BarCommand());
super();
}
}

View File

@@ -0,0 +1,24 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.subsystem2;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
public class ReplaceMeSubsystem extends SubsystemBase {
/**
* Creates a new ReplaceMeSubsystem.
*/
public ReplaceMeSubsystem() {
}
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}

View File

@@ -0,0 +1,34 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.trapezoidprofilecommand;
import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
import edu.wpi.first.wpilibj2.command.TrapezoidProfileCommand;
// NOTE: Consider using this command inline, rather than writing a subclass. For more
// information, see:
// https://docs.wpilib.org/en/latest/docs/software/commandbased/convenience-features.html
public class ReplaceMeTrapezoidProfileCommand extends TrapezoidProfileCommand {
/**
* Creates a new ReplaceMeTrapezoidProfileCommand.
*/
public ReplaceMeTrapezoidProfileCommand() {
super(
// The motion profile to be executed
new TrapezoidProfile(
// The motion profile constraints
new TrapezoidProfile.Constraints(0, 0),
// Goal state
new TrapezoidProfile.State(),
// Initial state
new TrapezoidProfile.State()),
state -> {
// Use current trajectory state here
});
}
}

View File

@@ -0,0 +1,29 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 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.trapezoidprofilesubsystem;
import edu.wpi.first.wpilibj.trajectory.TrapezoidProfile;
import edu.wpi.first.wpilibj2.command.TrapezoidProfileSubsystem;
public class ReplaceMeTrapezoidProfileSubsystem extends TrapezoidProfileSubsystem {
/**
* Creates a new ReplaceMeTrapezoidProfileSubsystem.
*/
public ReplaceMeTrapezoidProfileSubsystem() {
super(
// The constraints for the generated profiles
new TrapezoidProfile.Constraints(0, 0),
// The initial position of the mechanism
0);
}
@Override
protected void useState(TrapezoidProfile.State state) {
// Use the computed profile state here.
}
}

View File

@@ -24,6 +24,28 @@ public class ExampleCommand extends CommandBase {
*/
public ExampleCommand(ExampleSubsystem subsystem) {
m_subsystem = subsystem;
// Use addRequirements() here to declare subsystem dependencies.
addRequirements(subsystem);
}
// Called when the command is initially scheduled.
@Override
public void initialize() {
}
// Called every time the scheduler runs while the command is scheduled.
@Override
public void execute() {
}
// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
}
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
}

View File

@@ -17,11 +17,8 @@ public class ExampleSubsystem extends SubsystemBase {
}
/**
* Will be called periodically whenever the CommandScheduler runs.
*/
@Override
public void periodic() {
// This method will be called once per scheduler run
}
}