From 15819cc9810557abf83230c3eae6e9dbe5e03aad Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Fri, 10 Jul 2020 21:21:31 -0700 Subject: [PATCH] [command] Add SimulationPeriodic to templates (#2582) --- .../commandbased/cpp/subsystems/ExampleSubsystem.cpp | 6 +++++- .../commandbased/include/subsystems/ExampleSubsystem.h | 8 +++++++- .../commandbased/subsystems/ExampleSubsystem.java | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/subsystems/ExampleSubsystem.cpp b/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/subsystems/ExampleSubsystem.cpp index 2e720c9a7c..0cfda95e7b 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/subsystems/ExampleSubsystem.cpp +++ b/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/subsystems/ExampleSubsystem.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 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. */ @@ -14,3 +14,7 @@ ExampleSubsystem::ExampleSubsystem() { void ExampleSubsystem::Periodic() { // Implementation of subsystem periodic method goes here. } + +void ExampleSubsystem::SimulationPeriodic() { + // Implementation of subsystem simulation periodic method goes here. +} diff --git a/wpilibcExamples/src/main/cpp/templates/commandbased/include/subsystems/ExampleSubsystem.h b/wpilibcExamples/src/main/cpp/templates/commandbased/include/subsystems/ExampleSubsystem.h index f6cd550514..b64c26ff82 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbased/include/subsystems/ExampleSubsystem.h +++ b/wpilibcExamples/src/main/cpp/templates/commandbased/include/subsystems/ExampleSubsystem.h @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 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. */ @@ -18,6 +18,12 @@ class ExampleSubsystem : public frc2::SubsystemBase { */ void Periodic() override; + /** + * Will be called periodically whenever the CommandScheduler runs during + * simulation. + */ + void SimulationPeriodic() override; + private: // Components (e.g. motor controllers and sensors) should generally be // declared private and exposed only through public methods. diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/subsystems/ExampleSubsystem.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/subsystems/ExampleSubsystem.java index 8d56fcf45d..76202fe01c 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/subsystems/ExampleSubsystem.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/templates/commandbased/subsystems/ExampleSubsystem.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2018-2020 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. */ @@ -21,4 +21,9 @@ public class ExampleSubsystem extends SubsystemBase { public void periodic() { // This method will be called once per scheduler run } + + @Override + public void simulationPeriodic() { + // This method will be called once per scheduler run during simulation + } }