mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add templates for new commands for vscode plugin (#2016)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user