[examples] Reorganize templates to use CommandsV2 (#8432)

Change Commandbased to Commandv2
Run example check on templates
This commit is contained in:
sciencewhiz
2025-11-29 20:46:32 -08:00
committed by GitHub
parent 5aa0b7afea
commit e902a98601
44 changed files with 119 additions and 115 deletions

View File

@@ -24,30 +24,12 @@ def fileCheck = { parsedJson, folder ->
}
}
task checkTemplates(type: Task) {
doLast {
def parsedJson = new groovy.json.JsonSlurper().parseText(templateFile.text)
fileCheck(parsedJson, templateDirectory)
parsedJson.each {
assert it.name != null
assert it.description != null
assert it.tags != null
assert it.foldername != null
assert it.gradlebase != null
assert it.commandversion != null
if (it.gradlebase == 'java') {
assert it.mainclass != null
}
}
}
}
def tagList = [
/* --- Categories --- */
// On-RIO image processing
"Vision",
"Vision", "AprilTags",
// Command-based
"Command-based",
"Commandv2", "Commandv3",
// Romi
"Romi",
// XRP
@@ -79,11 +61,33 @@ def tagList = [
/* --- HID --- */
"XboxController", "PS4Controller", "PS5Controller", "Joystick",
/* --- RobotBase --- */
"Timed", "Timeslice", "RobotBase", "Educational",
/* --- Misc --- */
/* (try to keep this section minimal) */
"EventLoop", "AprilTags", "Mechanism2d", "Preferences",
"EventLoop", "Mechanism2d", "Preferences", "Skeleton"
]
task checkTemplates(type: Task) {
doLast {
def parsedJson = new groovy.json.JsonSlurper().parseText(templateFile.text)
fileCheck(parsedJson, templateDirectory)
parsedJson.each {
assert it.name != null
assert it.description != null
assert it.tags != null
assert it.tags.findAll { !tagList.contains(it) }.empty
assert it.foldername != null
assert it.gradlebase != null
assert it.commandversion != null
if (it.gradlebase == 'java') {
assert it.mainclass != null
}
}
}
}
task checkExamples(type: Task) {
doLast {
def parsedJson = new groovy.json.JsonSlurper().parseText(exampleFile.text)

View File

@@ -84,8 +84,8 @@ SNIPPETS_FOLDERS = [
]
TEMPLATES_FOLDERS = [
"commandbased",
"commandbasedskeleton",
"commandv2",
"commandv2skeleton",
"robotbaseskeleton",
"timed",
"timedskeleton",

View File

@@ -296,10 +296,10 @@
},
{
"name": "'Traditional' Hatchbot",
"description": "A fully-functional command-based hatchbot for the 2019 game, written in the 'traditional' style, i.e. commands are given their own classes.",
"description": "A fully-functional Commandv2 hatchbot for the 2019 game, written in the 'traditional' style, i.e. commands are given their own classes.",
"tags": [
"Complete Robot",
"Command-based",
"Commandv2",
"Differential Drive",
"Encoder",
"Sendable",
@@ -313,10 +313,10 @@
},
{
"name": "'Inlined' Hatchbot",
"description": "A fully-functional command-based hatchbot for the 2019 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"description": "A fully-functional Commandv2 hatchbot for the 2019 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"tags": [
"Complete Robot",
"Command-based",
"Commandv2",
"Differential Drive",
"Encoder",
"Sendable",
@@ -330,10 +330,10 @@
},
{
"name": "Rapid React Command Bot",
"description": "A fully-functional command-based fender bot for the 2022 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"description": "A fully-functional Commandv2 fender bot for the 2022 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"tags": [
"Complete Robot",
"Command-based",
"Commandv2",
"Differential Drive",
"Intake",
"Flywheel",
@@ -353,7 +353,7 @@
"name": "Select Command Example",
"description": "Use SelectCommand to select an autonomous routine.",
"tags": [
"Command-based"
"Commandv2"
],
"foldername": "SelectCommand",
"gradlebase": "cpp",
@@ -466,7 +466,7 @@
"name": "DriveDistanceOffboard",
"description": "Drive a differential drivetrain a set distance using TrapezoidProfile and smart motor controller PID.",
"tags": [
"Command-based",
"Commandv2",
"Differential Drive",
"Trapezoid Profile",
"Smart Motor Controller",
@@ -478,10 +478,10 @@
},
{
"name": "RomiReference",
"description": "An example command-based robot program that can be used with the Romi reference robot design.",
"description": "An example Commandv2 robot program that can be used with the Romi reference robot design.",
"tags": [
"Romi",
"Command-based",
"Commandv2",
"Differential Drive",
"Digital Input",
"Joystick"
@@ -495,10 +495,10 @@
},
{
"name": "XRP Reference",
"description": "An example command-based robot program that can be used with the XRP reference robot design.",
"description": "An example Commandv2 robot program that can be used with the XRP reference robot design.",
"tags": [
"XRP",
"Command-based",
"Commandv2",
"Differential Drive",
"Digital Input",
"Joystick"
@@ -662,7 +662,7 @@
},
{
"name": "SimpleDifferentialDriveSimulation",
"description": "Simulate a differential drivetrain and follow trajectories with LTVUnicycleController (non-command-based).",
"description": "Simulate a differential drivetrain and follow trajectories with LTVUnicycleController (non-Commandv2).",
"tags": [
"Differential Drive",
"State-Space",
@@ -706,10 +706,10 @@
},
{
"name": "SysIdRoutine",
"description": "A sample command-based robot demonstrating use of the SysIdRoutine command factory",
"description": "A sample Commandv2 robot demonstrating use of the SysIdRoutine command factory",
"tags": [
"SysId",
"Command-based",
"Commandv2",
"DataLog"
],
"foldername": "SysIdRoutine",

View File

@@ -1,22 +1,22 @@
[
{
"name": "Command Robot",
"description": "Command-based, with explanatory comments and example code.",
"name": "Command v2 Robot",
"description": "Command v2, with explanatory comments and example code.",
"tags": [
"Command"
"Commandv2"
],
"foldername": "commandbased",
"foldername": "commandv2",
"gradlebase": "cpp",
"commandversion": 2
},
{
"name": "Command Robot Skeleton (Advanced)",
"description": "Skeleton (stub) code for Command-based, without explanatory comments and example code.",
"name": "Command v2 Robot Skeleton (Advanced)",
"description": "Skeleton (stub) code for Command v2, without explanatory comments and example code.",
"tags": [
"Command",
"Commandv2",
"Skeleton"
],
"foldername": "commandbasedskeleton",
"foldername": "commandv2skeleton",
"gradlebase": "cpp",
"commandversion": 2
},
@@ -77,10 +77,10 @@
"name": "Romi - Command Robot",
"description": "Romi - Command style",
"tags": [
"Command",
"Commandv2",
"Romi"
],
"foldername": "commandbased",
"foldername": "commandv2",
"gradlebase": "cppromi",
"commandversion": 2,
"extravendordeps": [
@@ -105,10 +105,10 @@
"name": "XRP - Command Robot",
"description": "XRP - Command style",
"tags": [
"Command",
"Commandv2",
"XRP"
],
"foldername": "commandbased",
"foldername": "commandv2",
"gradlebase": "cppxrp",
"commandversion": 2,
"extravendordeps": [

View File

@@ -83,18 +83,18 @@ SNIPPETS_FOLDERS = [
]
TEMPLATES_FOLDERS = [
"commandbased",
"commandbasedskeleton",
"commandv2",
"commandv2skeleton",
"educational",
"robotbaseskeleton",
"romicommandbased",
"romicommandv2",
"romieducational",
"romitimed",
"timed",
"timedskeleton",
"timeslice",
"timesliceskeleton",
"xrpcommandbased",
"xrpcommandv2",
"xrpeducational",
"xrptimed",
]

View File

@@ -282,10 +282,10 @@
},
{
"name": "'Traditional' Hatchbot",
"description": "A fully-functional command-based hatchbot for the 2019 game, written in the 'traditional' style, i.e. commands are given their own classes.",
"description": "A fully-functional Commandv2 hatchbot for the 2019 game, written in the 'traditional' style, i.e. commands are given their own classes.",
"tags": [
"Complete Robot",
"Command-based",
"Commandv2",
"Differential Drive",
"Encoder",
"Pneumatics",
@@ -300,10 +300,10 @@
},
{
"name": "'Inlined' Hatchbot",
"description": "A fully-functional command-based hatchbot for the 2019 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"description": "A fully-functional Commandv2 hatchbot for the 2019 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"tags": [
"Complete Robot",
"Command-based",
"Commandv2",
"Differential Drive",
"Encoder",
"Pneumatics",
@@ -318,10 +318,10 @@
},
{
"name": "Rapid React Command Bot",
"description": "A fully-functional command-based fender bot for the 2022 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"description": "A fully-functional Commandv2 fender bot for the 2022 game, written in the 'inlined' style, i.e. many commands are defined inline with lambdas.",
"tags": [
"Complete Robot",
"Command-based",
"Commandv2",
"Differential Drive",
"Intake",
"Flywheel",
@@ -342,7 +342,7 @@
"name": "Select Command Example",
"description": "Use SelectCommand to select an autonomous routine.",
"tags": [
"Command-based"
"Commandv2"
],
"foldername": "selectcommand",
"gradlebase": "java",
@@ -464,7 +464,7 @@
"name": "DriveDistanceOffboard",
"description": "Drive a differential drivetrain a set distance using TrapezoidProfile and smart motor controller PID.",
"tags": [
"Command-based",
"Commandv2",
"Differential Drive",
"Trapezoid Profile",
"Smart Motor Controller",
@@ -542,7 +542,7 @@
},
{
"name": "SimpleDifferentialDriveSimulation",
"description": "Simulate a differential drivetrain and follow trajectories with LTVUnicycleController (non-command-based).",
"description": "Simulate a differential drivetrain and follow trajectories with LTVUnicycleController (non-Commandv2).",
"tags": [
"Differential Drive",
"State-Space",
@@ -672,10 +672,10 @@
},
{
"name": "RomiReference",
"description": "An example command-based robot program that can be used with the Romi reference robot design.",
"description": "An example Commandv2 robot program that can be used with the Romi reference robot design.",
"tags": [
"Romi",
"Command-based",
"Commandv2",
"Differential Drive",
"Digital Input",
"Joystick"
@@ -690,10 +690,10 @@
},
{
"name": "XRP Reference",
"description": "An example command-based robot program that can be used with the XRP reference robot design.",
"description": "An example Commandv2 robot program that can be used with the XRP reference robot design.",
"tags": [
"XRP",
"Command-based",
"Commandv2",
"Differential Drive",
"Digital Input",
"Joystick"
@@ -747,10 +747,10 @@
},
{
"name": "SysIdRoutine",
"description": "A sample command-based robot demonstrating use of the SysIdRoutine command factory",
"description": "A sample Commandv2 robot demonstrating use of the SysIdRoutine command factory",
"tags": [
"SysId",
"Command-based",
"Commandv2",
"DataLog"
],
"foldername": "sysidroutine",

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbased;
package org.wpilib.templates.commandv2;
/**
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbased;
package org.wpilib.templates.commandv2;
import org.wpilib.framework.RobotBase;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbased;
package org.wpilib.templates.commandv2;
import org.wpilib.command2.Command;
import org.wpilib.command2.CommandScheduler;

View File

@@ -2,15 +2,15 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbased;
package org.wpilib.templates.commandv2;
import org.wpilib.command2.Command;
import org.wpilib.command2.button.CommandXboxController;
import org.wpilib.command2.button.Trigger;
import org.wpilib.templates.commandbased.Constants.OperatorConstants;
import org.wpilib.templates.commandbased.commands.Autos;
import org.wpilib.templates.commandbased.commands.ExampleCommand;
import org.wpilib.templates.commandbased.subsystems.ExampleSubsystem;
import org.wpilib.templates.commandv2.Constants.OperatorConstants;
import org.wpilib.templates.commandv2.commands.Autos;
import org.wpilib.templates.commandv2.commands.ExampleCommand;
import org.wpilib.templates.commandv2.subsystems.ExampleSubsystem;
/**
* This class is where the bulk of the robot should be declared. Since Command-based is a

View File

@@ -2,11 +2,11 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbased.commands;
package org.wpilib.templates.commandv2.commands;
import org.wpilib.command2.Command;
import org.wpilib.command2.Commands;
import org.wpilib.templates.commandbased.subsystems.ExampleSubsystem;
import org.wpilib.templates.commandv2.subsystems.ExampleSubsystem;
public final class Autos {
/** Example static factory for an autonomous command. */

View File

@@ -2,10 +2,10 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbased.commands;
package org.wpilib.templates.commandv2.commands;
import org.wpilib.command2.Command;
import org.wpilib.templates.commandbased.subsystems.ExampleSubsystem;
import org.wpilib.templates.commandv2.subsystems.ExampleSubsystem;
/** An example command that uses an example subsystem. */
public class ExampleCommand extends Command {

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbased.subsystems;
package org.wpilib.templates.commandv2.subsystems;
import org.wpilib.command2.Command;
import org.wpilib.command2.SubsystemBase;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbasedskeleton;
package org.wpilib.templates.commandv2skeleton;
import org.wpilib.framework.RobotBase;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbasedskeleton;
package org.wpilib.templates.commandv2skeleton;
import org.wpilib.command2.Command;
import org.wpilib.command2.CommandScheduler;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.commandbasedskeleton;
package org.wpilib.templates.commandv2skeleton;
import org.wpilib.command2.Command;
import org.wpilib.command2.Commands;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.xrpcommandbased;
package org.wpilib.templates.romicommandv2;
/**
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.xrpcommandbased;
package org.wpilib.templates.romicommandv2;
import org.wpilib.framework.RobotBase;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.xrpcommandbased;
package org.wpilib.templates.romicommandv2;
import org.wpilib.command2.Command;
import org.wpilib.command2.CommandScheduler;

View File

@@ -2,12 +2,12 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.romicommandbased;
package org.wpilib.templates.romicommandv2;
import org.wpilib.command2.Command;
import org.wpilib.driverstation.XboxController;
import org.wpilib.templates.romicommandbased.commands.ExampleCommand;
import org.wpilib.templates.romicommandbased.subsystems.RomiDrivetrain;
import org.wpilib.templates.romicommandv2.commands.ExampleCommand;
import org.wpilib.templates.romicommandv2.subsystems.RomiDrivetrain;
/**
* This class is where the bulk of the robot should be declared. Since Command-based is a

View File

@@ -2,10 +2,10 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.romicommandbased.commands;
package org.wpilib.templates.romicommandv2.commands;
import org.wpilib.command2.Command;
import org.wpilib.templates.romicommandbased.subsystems.RomiDrivetrain;
import org.wpilib.templates.romicommandv2.subsystems.RomiDrivetrain;
/** An example command that uses an example subsystem. */
public class ExampleCommand extends Command {

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.romicommandbased.subsystems;
package org.wpilib.templates.romicommandv2.subsystems;
import org.wpilib.command2.SubsystemBase;
import org.wpilib.drive.DifferentialDrive;

View File

@@ -1,23 +1,23 @@
[
{
"name": "Command Robot",
"description": "Command-based, with explanatory comments and example code.",
"name": "Command v2 Robot",
"description": "Command v2, with explanatory comments and example code.",
"tags": [
"Command"
"Commandv2"
],
"foldername": "commandbased",
"foldername": "commandv2",
"gradlebase": "java",
"mainclass": "Main",
"commandversion": 2
},
{
"name": "Command Robot Skeleton (Advanced)",
"description": "Skeleton (stub) code for Command-based, without explanatory comments and example code.",
"name": "Command v2 Robot Skeleton (Advanced)",
"description": "Skeleton (stub) code for Command v2, without explanatory comments and example code.",
"tags": [
"Command",
"Commandv2",
"Skeleton"
],
"foldername": "commandbasedskeleton",
"foldername": "commandv2skeleton",
"gradlebase": "java",
"mainclass": "Main",
"commandversion": 2
@@ -84,10 +84,10 @@
"name": "Romi - Command Robot",
"description": "Romi - Command style",
"tags": [
"Command",
"Commandv2",
"Romi"
],
"foldername": "romicommandbased",
"foldername": "romicommandv2",
"gradlebase": "javaromi",
"mainclass": "Main",
"commandversion": 2,
@@ -114,10 +114,10 @@
"name": "XRP - Command Robot",
"description": "XRP - Command style",
"tags": [
"Command",
"Commandv2",
"XRP"
],
"foldername": "xrpcommandbased",
"foldername": "xrpcommandv2",
"gradlebase": "javaxrp",
"mainclass": "Main",
"commandversion": 2,

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.romicommandbased;
package org.wpilib.templates.xrpcommandv2;
/**
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.romicommandbased;
package org.wpilib.templates.xrpcommandv2;
import org.wpilib.framework.RobotBase;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.romicommandbased;
package org.wpilib.templates.xrpcommandv2;
import org.wpilib.command2.Command;
import org.wpilib.command2.CommandScheduler;

View File

@@ -2,12 +2,12 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.xrpcommandbased;
package org.wpilib.templates.xrpcommandv2;
import org.wpilib.command2.Command;
import org.wpilib.driverstation.XboxController;
import org.wpilib.templates.xrpcommandbased.commands.ExampleCommand;
import org.wpilib.templates.xrpcommandbased.subsystems.XRPDrivetrain;
import org.wpilib.templates.xrpcommandv2.commands.ExampleCommand;
import org.wpilib.templates.xrpcommandv2.subsystems.XRPDrivetrain;
/**
* This class is where the bulk of the robot should be declared. Since Command-based is a

View File

@@ -2,10 +2,10 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.xrpcommandbased.commands;
package org.wpilib.templates.xrpcommandv2.commands;
import org.wpilib.command2.Command;
import org.wpilib.templates.xrpcommandbased.subsystems.XRPDrivetrain;
import org.wpilib.templates.xrpcommandv2.subsystems.XRPDrivetrain;
/** An example command that uses an example subsystem. */
public class ExampleCommand extends Command {

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.templates.xrpcommandbased.subsystems;
package org.wpilib.templates.xrpcommandv2.subsystems;
import org.wpilib.command2.SubsystemBase;
import org.wpilib.drive.DifferentialDrive;