mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Add templates for new commands for vscode plugin (#2016)
This commit is contained in:
@@ -70,6 +70,7 @@ task checkCommands(type: Task) {
|
||||
assert it.tags != null
|
||||
assert it.foldername != null
|
||||
assert it.replacename != null
|
||||
assert it.commandversion != null
|
||||
if (project.isCppCommands) {
|
||||
assert it.headers != null
|
||||
assert !it.headers.isEmpty()
|
||||
|
||||
@@ -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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeCommand2.h"
|
||||
|
||||
ReplaceMeCommand2::ReplaceMeCommand2() {
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
void ReplaceMeCommand2::Initialize() {}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void ReplaceMeCommand2::Execute() {}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
void ReplaceMeCommand2::End(bool interrupted) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool ReplaceMeCommand2::IsFinished() { return false; }
|
||||
@@ -0,0 +1,32 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
|
||||
/**
|
||||
* An example command.
|
||||
*
|
||||
* <p>Note that this extends CommandHelper, rather extending CommandBase
|
||||
* directly; this is crucially important, or else the decorator functions in
|
||||
* Command will *not* work!
|
||||
*/
|
||||
class ReplaceMeCommand2
|
||||
: public frc2::CommandHelper<frc2::CommandBase, ReplaceMeCommand2> {
|
||||
public:
|
||||
ReplaceMeCommand2();
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Execute() override;
|
||||
|
||||
void End(bool interrupted) override;
|
||||
|
||||
bool IsFinished() override;
|
||||
};
|
||||
@@ -12,10 +12,11 @@
|
||||
"source": [
|
||||
"ReplaceMeEmptyClass.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeEmptyClass"
|
||||
"replacename": "ReplaceMeEmptyClass",
|
||||
"commandversion": 0
|
||||
},
|
||||
{
|
||||
"name": "Command",
|
||||
"name": "Command (Old)",
|
||||
"description": "Create a base command",
|
||||
"tags": [
|
||||
"command"
|
||||
@@ -27,10 +28,11 @@
|
||||
"source": [
|
||||
"ReplaceMeCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeCommand"
|
||||
"replacename": "ReplaceMeCommand",
|
||||
"commandversion": 1
|
||||
},
|
||||
{
|
||||
"name": "Command Group",
|
||||
"name": "Command Group (Old)",
|
||||
"description": "Create a command group",
|
||||
"tags": [
|
||||
"commandgroup"
|
||||
@@ -42,10 +44,11 @@
|
||||
"source": [
|
||||
"ReplaceMeCommandGroup.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeCommandGroup"
|
||||
"replacename": "ReplaceMeCommandGroup",
|
||||
"commandversion": 1
|
||||
},
|
||||
{
|
||||
"name": "Instant Command",
|
||||
"name": "Instant Command (Old)",
|
||||
"description": "A command that runs immediately",
|
||||
"tags": [
|
||||
"instantcommand"
|
||||
@@ -57,10 +60,11 @@
|
||||
"source": [
|
||||
"ReplaceMeInstantCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeInstantCommand"
|
||||
"replacename": "ReplaceMeInstantCommand",
|
||||
"commandversion": 1
|
||||
},
|
||||
{
|
||||
"name": "Subsystem",
|
||||
"name": "Subsystem (Old)",
|
||||
"description": "A subsystem",
|
||||
"tags": [
|
||||
"subsystem"
|
||||
@@ -72,10 +76,11 @@
|
||||
"source": [
|
||||
"ReplaceMeSubsystem.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeSubsystem"
|
||||
"replacename": "ReplaceMeSubsystem",
|
||||
"commandversion": 1
|
||||
},
|
||||
{
|
||||
"name": "PID Subsystem",
|
||||
"name": "PID Subsystem (Old)",
|
||||
"description": "A subsystem that runs a PID loop",
|
||||
"tags": [
|
||||
"pidsubsystem",
|
||||
@@ -88,10 +93,11 @@
|
||||
"source": [
|
||||
"ReplaceMePIDSubsystem.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMePIDSubsystem"
|
||||
"replacename": "ReplaceMePIDSubsystem",
|
||||
"commandversion": 1
|
||||
},
|
||||
{
|
||||
"name": "Timed Command",
|
||||
"name": "Timed Command (Old)",
|
||||
"description": "A command that runs for a specified time",
|
||||
"tags": [
|
||||
"timedcommand"
|
||||
@@ -103,10 +109,11 @@
|
||||
"source": [
|
||||
"ReplaceMeTimedCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeTimedCommand"
|
||||
"replacename": "ReplaceMeTimedCommand",
|
||||
"commandversion": 1
|
||||
},
|
||||
{
|
||||
"name": "Trigger",
|
||||
"name": "Trigger (Old)",
|
||||
"description": "A command that runs off of a trigger",
|
||||
"tags": [
|
||||
"trigger"
|
||||
@@ -118,6 +125,215 @@
|
||||
"source": [
|
||||
"ReplaceMeTrigger.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeTrigger"
|
||||
"replacename": "ReplaceMeTrigger",
|
||||
"commandversion": 1
|
||||
},
|
||||
{
|
||||
"name": "Command (New)",
|
||||
"description": "A command.",
|
||||
"tags": [
|
||||
"command"
|
||||
],
|
||||
"foldername": "command2",
|
||||
"headers": [
|
||||
"ReplaceMeCommand2.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeCommand2.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeCommand2",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "InstantCommand (New)",
|
||||
"description": "A command that finishes instantly.",
|
||||
"tags": [
|
||||
"instantcommand"
|
||||
],
|
||||
"foldername": "instantcommand",
|
||||
"headers": [
|
||||
"ReplaceMeInstantCommand2.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeInstantCommand2.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeInstantCommand2",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "ParallelCommandGroup (New)",
|
||||
"description": "A command group that runs commands in parallel, ending when all commands have finished.",
|
||||
"tags": [
|
||||
"parallelcommandgroup"
|
||||
],
|
||||
"foldername": "parallelcommandgroup",
|
||||
"headers": [
|
||||
"ReplaceMeParallelCommandGroup.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeParallelCommandGroup.cpp"
|
||||
],
|
||||
"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",
|
||||
"headers": [
|
||||
"ReplaceMeParallelDeadlineGroup.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeParallelDeadlineGroup.cpp"
|
||||
],
|
||||
"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",
|
||||
"headers": [
|
||||
"ReplaceMeParallelRaceGroup.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeParallelRaceGroup.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeParallelRaceGroup",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "PIDCommand (New)",
|
||||
"description": "A command that runs a PIDController.",
|
||||
"tags": [
|
||||
"pidcommand"
|
||||
],
|
||||
"foldername": "pidcommand",
|
||||
"headers": [
|
||||
"ReplaceMePIDCommand.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMePIDCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMePIDCommand",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "PIDSubsystem (New)",
|
||||
"description": "A subsystem that runs a PIDController.",
|
||||
"tags": [
|
||||
"pidsubsystem"
|
||||
],
|
||||
"foldername": "pidsubsystem2",
|
||||
"headers": [
|
||||
"ReplaceMePIDSubsystem2.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMePIDSubsystem2.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMePIDSubsystem2",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "ProfiledPIDCommand (New)",
|
||||
"description": "A command that runs a ProfiledPIDController.",
|
||||
"tags": [
|
||||
"profiledpidcommand"
|
||||
],
|
||||
"foldername": "profiledpidcommand",
|
||||
"headers": [
|
||||
"ReplaceMeProfiledPIDCommand.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeProfiledPIDCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeProfiledPIDCommand",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "ProfiledPIDSubsystem (New)",
|
||||
"description": "A subsystem that runs a ProfiledPIDController.",
|
||||
"tags": [
|
||||
"profiledpidsubsystem"
|
||||
],
|
||||
"foldername": "profiledpidsubsystem",
|
||||
"headers": [
|
||||
"ReplaceMeProfiledPIDSubsystem.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeProfiledPIDSubsystem.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeProfiledPIDSubsystem",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "SequentialCommandGroup (New)",
|
||||
"description": "A command group that runs commands in sequence.",
|
||||
"tags": [
|
||||
"sequentialcommandgroup"
|
||||
],
|
||||
"foldername": "sequentialcommandgroup",
|
||||
"headers": [
|
||||
"ReplaceMeSequentialCommandGroup.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeSequentialCommandGroup.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeSequentialCommandGroup",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "Subsystem (New)",
|
||||
"description": "A robot subsystem.",
|
||||
"tags": [
|
||||
"subsystem"
|
||||
],
|
||||
"foldername": "subsystem2",
|
||||
"headers": [
|
||||
"ReplaceMeSubsystem2.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeSubsystem2.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeSubsystem2",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "TrapezoidProfileCommand (New)",
|
||||
"description": "A command that executes a trapezoidal motion profile.",
|
||||
"tags": [
|
||||
"trapezoidprofilecommand"
|
||||
],
|
||||
"foldername": "trapezoidprofilecommand",
|
||||
"headers": [
|
||||
"ReplaceMeTrapezoidProfileCommand.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeTrapezoidProfileCommand.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeTrapezoidProfileCommand",
|
||||
"commandversion": 2
|
||||
},
|
||||
{
|
||||
"name": "TrapezoidProfileSubsystem (New)",
|
||||
"description": "A command that executes a trapezoidal motion profile.",
|
||||
"tags": [
|
||||
"trapezoidprofilesubsystem"
|
||||
],
|
||||
"foldername": "trapezoidprofilesubsystem",
|
||||
"headers": [
|
||||
"ReplaceMeTrapezoidProfileSubsystem.h"
|
||||
],
|
||||
"source": [
|
||||
"ReplaceMeTrapezoidProfileSubsystem.cpp"
|
||||
],
|
||||
"replacename": "ReplaceMeTrapezoidProfileSubsystem",
|
||||
"commandversion": 2
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeInstantCommand2.h"
|
||||
|
||||
// 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
|
||||
ReplaceMeInstantCommand2::ReplaceMeInstantCommand2() {
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
void ReplaceMeInstantCommand2::Initialize() {}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/InstantCommand.h>
|
||||
|
||||
class ReplaceMeInstantCommand2
|
||||
: public frc2::CommandHelper<frc2::InstantCommand,
|
||||
ReplaceMeInstantCommand2> {
|
||||
public:
|
||||
ReplaceMeInstantCommand2();
|
||||
|
||||
void Initialize() override;
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeParallelCommandGroup.h"
|
||||
|
||||
// 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
|
||||
ReplaceMeParallelCommandGroup::ReplaceMeParallelCommandGroup() {
|
||||
// Add your commands here, e.g.
|
||||
// AddCommands(FooCommand(), BarCommand());
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/ParallelCommandGroup.h>
|
||||
|
||||
class ReplaceMeParallelCommandGroup
|
||||
: public frc2::CommandHelper<frc2::ParallelCommandGroup,
|
||||
ReplaceMeParallelCommandGroup> {
|
||||
public:
|
||||
ReplaceMeParallelCommandGroup();
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeParallelDeadlineGroup.h"
|
||||
|
||||
#include <frc2/command/InstantCommand.h>
|
||||
|
||||
// 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
|
||||
ReplaceMeParallelDeadlineGroup::ReplaceMeParallelDeadlineGroup()
|
||||
: CommandHelper(
|
||||
// The deadline command
|
||||
frc2::InstantCommand([] {})) {
|
||||
// Add your commands here, e.g.
|
||||
// AddCommands(FooCommand(), BarCommand());
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/ParallelDeadlineGroup.h>
|
||||
|
||||
class ReplaceMeParallelDeadlineGroup
|
||||
: public frc2::CommandHelper<frc2::ParallelDeadlineGroup,
|
||||
ReplaceMeParallelDeadlineGroup> {
|
||||
public:
|
||||
ReplaceMeParallelDeadlineGroup();
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeParallelRaceGroup.h"
|
||||
|
||||
// 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
|
||||
ReplaceMeParallelRaceGroup::ReplaceMeParallelRaceGroup() {
|
||||
// Add your commands here, e.g.
|
||||
// AddCommands(FooCommand(), BarCommand());
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/ParallelRaceGroup.h>
|
||||
|
||||
class ReplaceMeParallelRaceGroup
|
||||
: public frc2::CommandHelper<frc2::ParallelRaceGroup,
|
||||
ReplaceMeParallelRaceGroup> {
|
||||
public:
|
||||
ReplaceMeParallelRaceGroup();
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMePIDCommand.h"
|
||||
|
||||
// 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
|
||||
ReplaceMePIDCommand::ReplaceMePIDCommand()
|
||||
: CommandHelper(frc2::PIDController(0, 0, 0),
|
||||
// This should return the measurement
|
||||
[] { return 0; },
|
||||
// This should return the setpoint (can also be a constant)
|
||||
[] { return 0; },
|
||||
// This uses the output
|
||||
[](double output) {
|
||||
// Use the output here
|
||||
}) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool ReplaceMePIDCommand::IsFinished() { return false; }
|
||||
@@ -0,0 +1,19 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/PIDCommand.h>
|
||||
|
||||
class ReplaceMePIDCommand
|
||||
: public frc2::CommandHelper<frc2::PIDCommand, ReplaceMePIDCommand> {
|
||||
public:
|
||||
ReplaceMePIDCommand();
|
||||
|
||||
bool IsFinished() override;
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMePIDSubsystem2.h"
|
||||
|
||||
ReplaceMePIDSubsystem2::ReplaceMePIDSubsystem2()
|
||||
: PIDSubsystem(
|
||||
// The PIDController used by the subsystem
|
||||
frc2::PIDController(0, 0, 0)) {}
|
||||
|
||||
void ReplaceMePIDSubsystem2::UseOutput(double output, double setpoint) {
|
||||
// Use the output here
|
||||
}
|
||||
|
||||
double ReplaceMePIDSubsystem2::GetMeasurement() {
|
||||
// Return the process variable measurement here
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/PIDSubsystem.h>
|
||||
|
||||
class ReplaceMePIDSubsystem2 : public frc2::PIDSubsystem {
|
||||
public:
|
||||
ReplaceMePIDSubsystem2();
|
||||
|
||||
protected:
|
||||
void UseOutput(double output, double setpoint) override;
|
||||
|
||||
double GetMeasurement() override;
|
||||
};
|
||||
@@ -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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeProfiledPIDCommand.h"
|
||||
|
||||
// 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
|
||||
ReplaceMeProfiledPIDCommand::ReplaceMeProfiledPIDCommand()
|
||||
: CommandHelper(
|
||||
// The ProfiledPIDController that the command will use
|
||||
frc::ProfiledPIDController<units::meter>(
|
||||
// The PID gains
|
||||
0, 0, 0,
|
||||
// The motion profile constraints
|
||||
{0_mps, 0_mps_sq}),
|
||||
// This should return the measurement
|
||||
[] { return 0_m; },
|
||||
// This should return the goal state (can also be a constant)
|
||||
[] {
|
||||
return frc::TrapezoidProfile<units::meter>::State{0_m, 0_mps};
|
||||
},
|
||||
// This uses the output and current trajectory setpoint
|
||||
[](double output,
|
||||
frc::TrapezoidProfile<units::meter>::State setpoint) {
|
||||
// Use the output and setpoint here
|
||||
}) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool ReplaceMeProfiledPIDCommand::IsFinished() { return false; }
|
||||
@@ -0,0 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/ProfiledPIDCommand.h>
|
||||
|
||||
class ReplaceMeProfiledPIDCommand
|
||||
: public frc2::CommandHelper<frc2::ProfiledPIDCommand<units::meter>,
|
||||
ReplaceMeProfiledPIDCommand> {
|
||||
public:
|
||||
ReplaceMeProfiledPIDCommand();
|
||||
|
||||
bool IsFinished() override;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeProfiledPIDSubsystem.h"
|
||||
|
||||
ReplaceMeProfiledPIDSubsystem::ReplaceMeProfiledPIDSubsystem()
|
||||
: ProfiledPIDSubsystem(
|
||||
// The ProfiledPIDController used by the subsystem
|
||||
frc::ProfiledPIDController<units::meter>(
|
||||
// The PID gains
|
||||
0, 0, 0,
|
||||
// The constraints for the motion profiles
|
||||
{0_mps, 0_mps_sq})) {}
|
||||
|
||||
void ReplaceMeProfiledPIDSubsystem::UseOutput(
|
||||
double output, frc::TrapezoidProfile<units::meter>::State setpoint) {
|
||||
// Use the output and current trajectory setpoint here
|
||||
}
|
||||
|
||||
units::meter_t ReplaceMeProfiledPIDSubsystem::GetMeasurement() {
|
||||
// Return the process variable measurement here
|
||||
return 0_m;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/ProfiledPIDSubsystem.h>
|
||||
|
||||
class ReplaceMeProfiledPIDSubsystem
|
||||
: public frc2::ProfiledPIDSubsystem<units::meter> {
|
||||
public:
|
||||
ReplaceMeProfiledPIDSubsystem();
|
||||
|
||||
protected:
|
||||
void UseOutput(double output,
|
||||
frc::TrapezoidProfile<units::meter>::State setpoint) override;
|
||||
|
||||
units::meter_t GetMeasurement() override;
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeSequentialCommandGroup.h"
|
||||
|
||||
// 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
|
||||
ReplaceMeSequentialCommandGroup::ReplaceMeSequentialCommandGroup() {
|
||||
// Add your commands here, e.g.
|
||||
// AddCommands(FooCommand(), BarCommand());
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/SequentialCommandGroup.h>
|
||||
|
||||
class ReplaceMeSequentialCommandGroup
|
||||
: public frc2::CommandHelper<frc2::SequentialCommandGroup,
|
||||
ReplaceMeSequentialCommandGroup> {
|
||||
public:
|
||||
ReplaceMeSequentialCommandGroup();
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeSubsystem2.h"
|
||||
|
||||
ReplaceMeSubsystem2::ReplaceMeSubsystem2() {}
|
||||
|
||||
// This method will be called once per scheduler run
|
||||
void ReplaceMeSubsystem2::Periodic() {}
|
||||
@@ -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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/SubsystemBase.h>
|
||||
|
||||
class ReplaceMeSubsystem2 : public frc2::SubsystemBase {
|
||||
public:
|
||||
ReplaceMeSubsystem2();
|
||||
|
||||
/**
|
||||
* Will be called periodically whenever the CommandScheduler runs.
|
||||
*/
|
||||
void Periodic();
|
||||
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeTrapezoidProfileCommand.h"
|
||||
|
||||
// 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
|
||||
ReplaceMeTrapezoidProfileCommand::ReplaceMeTrapezoidProfileCommand()
|
||||
: CommandHelper
|
||||
// The profile to execute
|
||||
(frc::TrapezoidProfile<units::meter>(
|
||||
// The maximum velocity and acceleration of the profile
|
||||
{5_mps, 5_mps_sq},
|
||||
// The goal state of the profile
|
||||
{10_m, 0_mps},
|
||||
// The initial state of the profile
|
||||
{0_m, 0_mps}),
|
||||
[](frc::TrapezoidProfile<units::meter>::State state) {
|
||||
// Use the computed intermediate trajectory state here
|
||||
}) {}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc2/command/TrapezoidProfileCommand.h>
|
||||
|
||||
class ReplaceMeTrapezoidProfileCommand
|
||||
: public frc2::CommandHelper<frc2::TrapezoidProfileCommand<units::meter>,
|
||||
ReplaceMeTrapezoidProfileCommand> {
|
||||
public:
|
||||
ReplaceMeTrapezoidProfileCommand();
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReplaceMeTrapezoidProfileSubsystem.h"
|
||||
|
||||
ReplaceMeTrapezoidProfileSubsystem::ReplaceMeTrapezoidProfileSubsystem()
|
||||
: TrapezoidProfileSubsystem(
|
||||
// The motion profile constraints
|
||||
{5_mps, 5_mps_sq},
|
||||
// The initial position of the mechanism
|
||||
0_m) {}
|
||||
|
||||
void ReplaceMeTrapezoidProfileSubsystem::UseState(
|
||||
frc::TrapezoidProfile<units::meters>::State state) {
|
||||
// Use the current profile state here
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 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. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/TrapezoidProfileSubsystem.h>
|
||||
|
||||
class ReplaceMeTrapezoidProfileSubsystem
|
||||
: frc2::TrapezoidProfileSubsystem<units::meters> {
|
||||
public:
|
||||
ReplaceMeTrapezoidProfileSubsystem();
|
||||
|
||||
protected:
|
||||
void UseState(frc::TrapezoidProfile<units::meters>::State state) override;
|
||||
};
|
||||
@@ -18,8 +18,6 @@ class ExampleSubsystem : public frc2::SubsystemBase {
|
||||
*/
|
||||
void Periodic() override;
|
||||
|
||||
// Subsystem methods go here.
|
||||
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user