From b3f97759f5b9e7e2ecdb7794ee0884591f261d07 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Sun, 27 Oct 2024 16:36:53 -0400 Subject: [PATCH 01/15] Added withDeadline modifier --- .../edu/wpi/first/wpilibj2/command/Commands.java | 6 +++--- .../first/wpilibj2/command/ParallelCommandGroup.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java index c53409a033d..06df7fb1da8 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java @@ -242,7 +242,7 @@ public static Command repeatingSequence(Command... commands) { * @return the command * @see ParallelCommandGroup */ - public static Command parallel(Command... commands) { + public static ParallelCommandGroup parallel(Command... commands) { return new ParallelCommandGroup(commands); } @@ -254,7 +254,7 @@ public static Command parallel(Command... commands) { * @return the command group * @see ParallelRaceGroup */ - public static Command race(Command... commands) { + public static ParallelRaceGroup race(Command... commands) { return new ParallelRaceGroup(commands); } @@ -268,7 +268,7 @@ public static Command race(Command... commands) { * @see ParallelDeadlineGroup * @throws IllegalArgumentException if the deadline command is also in the otherCommands argument */ - public static Command deadline(Command deadline, Command... otherCommands) { + public static ParallelDeadlineGroup deadline(Command deadline, Command... otherCommands) { return new ParallelDeadlineGroup(deadline, otherCommands); } diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java index 0fc31876ce4..93ea5b80629 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java @@ -37,6 +37,18 @@ public ParallelCommandGroup(Command... commands) { addCommands(commands); } + /** + * Creates a new command that runs the commands of this parallel group + * and the deadline in parallel, stopping all when the deadline finishes. + * + * @param deadline the command deadline; once this finishes, the other commands will be interrupted. + * @return the command group + * @see ParallelDeadlineGroup + */ + public Command withDeadline(Command deadline) { + return new ParallelDeadlineGroup(deadline, this); + } + /** * Adds the given commands to the group. * From 74b22eafa745aa4a0d8e3538ff41c38ae241bd1f Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Sun, 27 Oct 2024 16:55:08 -0400 Subject: [PATCH 02/15] docs changes --- .../wpi/first/wpilibj2/command/ParallelCommandGroup.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java index 93ea5b80629..79bf861ea9e 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java @@ -38,10 +38,11 @@ public ParallelCommandGroup(Command... commands) { } /** - * Creates a new command that runs the commands of this parallel group - * and the deadline in parallel, stopping all when the deadline finishes. + * Creates a new command that runs this parallel group + * and the deadline in parallel, finishing when + * the deadline finishes. * - * @param deadline the command deadline; once this finishes, the other commands will be interrupted. + * @param deadline the deadline of the command group * @return the command group * @see ParallelDeadlineGroup */ From b53f8c3b57ea213b1725ecf121a5f63a0fa27dad Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Mon, 28 Oct 2024 20:31:08 -0400 Subject: [PATCH 03/15] Added WithDeadline to c++, made it a general command instance method(for java) --- .../edu/wpi/first/wpilibj2/command/Command.java | 12 ++++++++++++ .../wpilibj2/command/ParallelCommandGroup.java | 13 ------------- .../src/main/native/cpp/frc2/command/Command.cpp | 4 ++++ .../src/main/native/cpp/frc2/command/CommandPtr.cpp | 5 +++++ .../src/main/native/include/frc2/command/Command.h | 11 +++++++++++ .../main/native/include/frc2/command/CommandPtr.h | 10 ++++++++++ 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index a53d792d0e4..ec69a33b878 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -287,6 +287,18 @@ public SequentialCommandGroup andThen(Command... next) { return group; } + /** + * Creates a new command that runs this command + * and the deadline in parallel, finishing when + * the deadline finishes. + * + * @param deadline the deadline of the command group + * @return the decorated command + */ + public ParallelDeadlineGroup withDeadline(Command deadline) { + return new ParallelDeadlineGroup(deadline, this); + } + /** * Decorates this command with a set of commands to run parallel to it, ending when the calling * command ends and interrupting all the others. Often more convenient/less-verbose than diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java index 79bf861ea9e..0fc31876ce4 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/ParallelCommandGroup.java @@ -37,19 +37,6 @@ public ParallelCommandGroup(Command... commands) { addCommands(commands); } - /** - * Creates a new command that runs this parallel group - * and the deadline in parallel, finishing when - * the deadline finishes. - * - * @param deadline the deadline of the command group - * @return the command group - * @see ParallelDeadlineGroup - */ - public Command withDeadline(Command deadline) { - return new ParallelDeadlineGroup(deadline, this); - } - /** * Adds the given commands to the group. * diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp index 365cf80a4ea..af8e30a33a5 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/Command.cpp @@ -121,6 +121,10 @@ CommandPtr Command::OnlyIf(std::function condition) && { return std::move(*this).ToPtr().OnlyIf(std::move(condition)); } +CommandPtr Command::WithDeadline(CommandPtr&& deadline) && { + return std::move(*this).ToPtr().WithDeadline(std::move(deadline)); +} + CommandPtr Command::DeadlineFor(CommandPtr&& parallel) && { return std::move(*this).ToPtr().DeadlineFor(std::move(parallel)); } diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp index 298cc2e50ca..27dd09797ae 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp @@ -168,6 +168,11 @@ CommandPtr CommandPtr::OnlyIf(std::function condition) && { return std::move(*this).Unless(std::not_fn(std::move(condition))); } +CommandPtr CommandPtr::WithDeadline(CommandPtr&& deadline) && { + AssertValid(); + return std::move(deadline).DeadlineFor(std::move(*this)); +} + CommandPtr CommandPtr::DeadlineWith(CommandPtr&& parallel) && { AssertValid(); std::vector> vec; diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index c4af1afe81b..018b15717cf 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -309,6 +309,16 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { [[nodiscard]] CommandPtr OnlyIf(std::function condition) &&; + /** + * Creates a new command that runs this command + * and the deadline in parallel, finishing when + * the deadline finishes. + * + * @param deadline the deadline of the command group + * @return the decorated command + */ + CommandPtr WithDeadline(CommandPtr&& deadline) &&; + /** * Decorates this command with a set of commands to run parallel to it, ending * when the calling command ends and interrupting all the others. Often more @@ -321,6 +331,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { */ [[nodiscard]] CommandPtr DeadlineFor(CommandPtr&& parallel) &&; + /** * Decorates this command with a set of commands to run parallel to it, ending * when the last command ends. Often more convenient/less-verbose than diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h index e2f534f7547..0900ac00d38 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -182,6 +182,16 @@ class CommandPtr final { [[nodiscard]] CommandPtr OnlyIf(std::function condition) &&; + /** + * Creates a new command that runs this command + * and the deadline in parallel, finishing when + * the deadline finishes. + * + * @param deadline the deadline of the command group + * @return the decorated command + */ + CommandPtr WithDeadline(CommandPtr&& deadline) &&; + /** * Decorates this command with a set of commands to run parallel to it, ending * when the calling command ends and interrupting all the others. Often more From 928945a0adbc017889c3e8d2713328ee502ed28d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:56:04 +0000 Subject: [PATCH 04/15] Formatting fixes --- .../main/java/edu/wpi/first/wpilibj2/command/Command.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index ec69a33b878..23146c00da2 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -288,9 +288,8 @@ public SequentialCommandGroup andThen(Command... next) { } /** - * Creates a new command that runs this command - * and the deadline in parallel, finishing when - * the deadline finishes. + * Creates a new command that runs this command and the deadline in parallel, finishing when the + * deadline finishes. * * @param deadline the deadline of the command group * @return the decorated command From b903bfe4935ba51ffb707dc8ed5abf514d00ee17 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Thu, 31 Oct 2024 13:34:29 -0400 Subject: [PATCH 05/15] Reverted previous changes and revised docs --- .../main/java/edu/wpi/first/wpilibj2/command/Command.java | 6 ++++++ .../main/java/edu/wpi/first/wpilibj2/command/Commands.java | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index ec69a33b878..bef09f5cf76 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -292,6 +292,12 @@ public SequentialCommandGroup andThen(Command... next) { * and the deadline in parallel, finishing when * the deadline finishes. * + *

Note: This decorator works by adding this command to a composition. The command the + * decorator was called on cannot be scheduled independently or be added to a different + * composition (namely, decorators), unless it is manually cleared from the list of composed + * commands with {@link CommandScheduler#removeComposedCommand(Command)}. The command composition + * returned from this method can be further decorated without issue. + * * @param deadline the deadline of the command group * @return the decorated command */ diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java index 06df7fb1da8..c53409a033d 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Commands.java @@ -242,7 +242,7 @@ public static Command repeatingSequence(Command... commands) { * @return the command * @see ParallelCommandGroup */ - public static ParallelCommandGroup parallel(Command... commands) { + public static Command parallel(Command... commands) { return new ParallelCommandGroup(commands); } @@ -254,7 +254,7 @@ public static ParallelCommandGroup parallel(Command... commands) { * @return the command group * @see ParallelRaceGroup */ - public static ParallelRaceGroup race(Command... commands) { + public static Command race(Command... commands) { return new ParallelRaceGroup(commands); } @@ -268,7 +268,7 @@ public static ParallelRaceGroup race(Command... commands) { * @see ParallelDeadlineGroup * @throws IllegalArgumentException if the deadline command is also in the otherCommands argument */ - public static ParallelDeadlineGroup deadline(Command deadline, Command... otherCommands) { + public static Command deadline(Command deadline, Command... otherCommands) { return new ParallelDeadlineGroup(deadline, otherCommands); } From 010155272952cf715c2f1b4f35542d3ff46dfea9 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Tue, 5 Nov 2024 08:36:31 -0500 Subject: [PATCH 06/15] Changed cpp WithDeadline implementation --- .../src/main/native/cpp/frc2/command/CommandPtr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp index 27dd09797ae..9b9c45591fd 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp @@ -170,7 +170,11 @@ CommandPtr CommandPtr::OnlyIf(std::function condition) && { CommandPtr CommandPtr::WithDeadline(CommandPtr&& deadline) && { AssertValid(); - return std::move(deadline).DeadlineFor(std::move(*this)); + std::vector> vec; + vec.emplace_back(std::move(m_ptr)); + m_ptr = + std::make_unique(std::move(deadline).Unwrap(), std::move(vec)); + return std::move(*this); } CommandPtr CommandPtr::DeadlineWith(CommandPtr&& parallel) && { From f98f3278fa4dc0daa9ac73b790ee85ca60c0ac23 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:58:03 +0000 Subject: [PATCH 07/15] Formatting fixes --- hal/generate_usage_reporting.py | 4 ++-- shared/bazel/rules/gen/gen_resources.py | 2 +- upstream_utils/apriltag.py | 6 +----- upstream_utils/eigen.py | 6 +----- upstream_utils/fmt.py | 5 +---- upstream_utils/gcem.py | 5 +---- upstream_utils/gl3w.py | 5 +---- upstream_utils/glfw.py | 5 +---- upstream_utils/googletest.py | 6 +----- upstream_utils/imgui.py | 5 +---- upstream_utils/implot.py | 5 +---- upstream_utils/json.py | 5 +---- upstream_utils/libuv.py | 5 +---- upstream_utils/memory.py | 6 +----- upstream_utils/mpack.py | 5 +---- upstream_utils/protobuf.py | 6 +----- upstream_utils/sleipnir.py | 5 +---- upstream_utils/stb.py | 5 +---- wpilibNewCommands/generate_hids.py | 2 +- .../src/main/native/cpp/frc2/command/CommandPtr.cpp | 4 ++-- wpilibc/generate_hids.py | 2 +- wpilibc/generate_pwm_motor_controllers.py | 4 ++-- wpilibj/generate_hids.py | 2 +- wpilibj/generate_pwm_motor_controllers.py | 2 +- wpimath/generate_numbers.py | 5 +++-- wpimath/generate_quickbuf.py | 3 +-- wpiutil/examples/printlog/datalog.py | 5 +++-- 27 files changed, 34 insertions(+), 86 deletions(-) diff --git a/hal/generate_usage_reporting.py b/hal/generate_usage_reporting.py index 955be4f1101..9953be3745d 100755 --- a/hal/generate_usage_reporting.py +++ b/hal/generate_usage_reporting.py @@ -3,9 +3,9 @@ # Copyright (c) FIRST and other WPILib contributors. # 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. -from pathlib import Path -import sys import argparse +import sys +from pathlib import Path def generate_usage_reporting(output_directory: Path, template_directory: Path): diff --git a/shared/bazel/rules/gen/gen_resources.py b/shared/bazel/rules/gen/gen_resources.py index 869ff1d5914..af0e6a2c071 100644 --- a/shared/bazel/rules/gen/gen_resources.py +++ b/shared/bazel/rules/gen/gen_resources.py @@ -1,6 +1,6 @@ -import os import argparse import binascii +import os def generate_file(resource_file, output_file, prefix, namespace): diff --git a/upstream_utils/apriltag.py b/upstream_utils/apriltag.py index 7fb5f673f29..ea959194175 100755 --- a/upstream_utils/apriltag.py +++ b/upstream_utils/apriltag.py @@ -3,11 +3,7 @@ import os import shutil -from upstream_utils import ( - comment_out_invalid_includes, - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, comment_out_invalid_includes, walk_cwd_and_copy_if def remove_tag(f: str): diff --git a/upstream_utils/eigen.py b/upstream_utils/eigen.py index 70e21549bc0..cc4b102144d 100755 --- a/upstream_utils/eigen.py +++ b/upstream_utils/eigen.py @@ -4,11 +4,7 @@ import re import shutil -from upstream_utils import ( - comment_out_invalid_includes, - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, comment_out_invalid_includes, walk_cwd_and_copy_if def eigen_inclusions(dp, f): diff --git a/upstream_utils/fmt.py b/upstream_utils/fmt.py index 947a1750fd0..adf83d1bf0c 100755 --- a/upstream_utils/fmt.py +++ b/upstream_utils/fmt.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def copy_upstream_src(wpilib_root): diff --git a/upstream_utils/gcem.py b/upstream_utils/gcem.py index 05a1b7a859d..1b4f2d1e447 100755 --- a/upstream_utils/gcem.py +++ b/upstream_utils/gcem.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def copy_upstream_src(wpilib_root): diff --git a/upstream_utils/gl3w.py b/upstream_utils/gl3w.py index 8855fd9d4c7..1858d675a60 100755 --- a/upstream_utils/gl3w.py +++ b/upstream_utils/gl3w.py @@ -2,10 +2,7 @@ import os -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def copy_upstream_src(wpilib_root): diff --git a/upstream_utils/glfw.py b/upstream_utils/glfw.py index 6a4c77a315d..a2d7e84540e 100755 --- a/upstream_utils/glfw.py +++ b/upstream_utils/glfw.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def matches(dp, f, allowed_files): diff --git a/upstream_utils/googletest.py b/upstream_utils/googletest.py index b164228328d..60613ee5350 100755 --- a/upstream_utils/googletest.py +++ b/upstream_utils/googletest.py @@ -3,11 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - walk_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if, walk_if EXCLUDED_FILES = [ "gtest_main.cc", diff --git a/upstream_utils/imgui.py b/upstream_utils/imgui.py index d6828480711..170cf419917 100755 --- a/upstream_utils/imgui.py +++ b/upstream_utils/imgui.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def matches(dp, f, allowed_files): diff --git a/upstream_utils/implot.py b/upstream_utils/implot.py index 00bf796e769..73101e84d9c 100755 --- a/upstream_utils/implot.py +++ b/upstream_utils/implot.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def matches(dp, f, allowed_files): diff --git a/upstream_utils/json.py b/upstream_utils/json.py index 46b49a39035..050e4dd66e5 100755 --- a/upstream_utils/json.py +++ b/upstream_utils/json.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_if, - Lib, -) +from upstream_utils import Lib, walk_if def copy_upstream_src(wpilib_root): diff --git a/upstream_utils/libuv.py b/upstream_utils/libuv.py index 0c48d0f90d3..c837fe96bef 100755 --- a/upstream_utils/libuv.py +++ b/upstream_utils/libuv.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def copy_upstream_src(wpilib_root): diff --git a/upstream_utils/memory.py b/upstream_utils/memory.py index 85b69dfaf84..0099de5ea91 100755 --- a/upstream_utils/memory.py +++ b/upstream_utils/memory.py @@ -3,11 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_if, - copy_to, - Lib, -) +from upstream_utils import Lib, copy_to, walk_if def run_source_replacements(memory_files): diff --git a/upstream_utils/mpack.py b/upstream_utils/mpack.py index 103c67be9e9..1acff50a371 100755 --- a/upstream_utils/mpack.py +++ b/upstream_utils/mpack.py @@ -4,10 +4,7 @@ import shutil import subprocess -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def copy_upstream_src(wpilib_root): diff --git a/upstream_utils/protobuf.py b/upstream_utils/protobuf.py index cb2e5f09e9d..fc7055f524e 100755 --- a/upstream_utils/protobuf.py +++ b/upstream_utils/protobuf.py @@ -3,11 +3,7 @@ import os import shutil -from upstream_utils import ( - copy_to, - walk_if, - Lib, -) +from upstream_utils import Lib, copy_to, walk_if protobuf_lite_sources = set( [ diff --git a/upstream_utils/sleipnir.py b/upstream_utils/sleipnir.py index 28d2fb38e5a..9b5d3e6aae0 100755 --- a/upstream_utils/sleipnir.py +++ b/upstream_utils/sleipnir.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - copy_to, - Lib, -) +from upstream_utils import Lib, copy_to def copy_upstream_src(wpilib_root): diff --git a/upstream_utils/stb.py b/upstream_utils/stb.py index 72a0b8811cc..06fb69a396a 100755 --- a/upstream_utils/stb.py +++ b/upstream_utils/stb.py @@ -3,10 +3,7 @@ import os import shutil -from upstream_utils import ( - walk_cwd_and_copy_if, - Lib, -) +from upstream_utils import Lib, walk_cwd_and_copy_if def copy_upstream_src(wpilib_root): diff --git a/wpilibNewCommands/generate_hids.py b/wpilibNewCommands/generate_hids.py index 6e349d94b42..51093191fa0 100755 --- a/wpilibNewCommands/generate_hids.py +++ b/wpilibNewCommands/generate_hids.py @@ -3,9 +3,9 @@ # Copyright (c) FIRST and other WPILib contributors. # 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. +import argparse import json import sys -import argparse from pathlib import Path from jinja2 import Environment, FileSystemLoader diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp index 9b9c45591fd..d4125fdceb8 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/CommandPtr.cpp @@ -172,8 +172,8 @@ CommandPtr CommandPtr::WithDeadline(CommandPtr&& deadline) && { AssertValid(); std::vector> vec; vec.emplace_back(std::move(m_ptr)); - m_ptr = - std::make_unique(std::move(deadline).Unwrap(), std::move(vec)); + m_ptr = std::make_unique(std::move(deadline).Unwrap(), + std::move(vec)); return std::move(*this); } diff --git a/wpilibc/generate_hids.py b/wpilibc/generate_hids.py index 76a879c1238..bd8e2cf338c 100755 --- a/wpilibc/generate_hids.py +++ b/wpilibc/generate_hids.py @@ -3,9 +3,9 @@ # Copyright (c) FIRST and other WPILib contributors. # 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. +import argparse import json import sys -import argparse from pathlib import Path from jinja2 import Environment, FileSystemLoader diff --git a/wpilibc/generate_pwm_motor_controllers.py b/wpilibc/generate_pwm_motor_controllers.py index a04b918cc4f..1741b71a914 100755 --- a/wpilibc/generate_pwm_motor_controllers.py +++ b/wpilibc/generate_pwm_motor_controllers.py @@ -5,10 +5,10 @@ # the WPILib BSD license file in the root directory of this project. import argparse import json -import sys import os -from typing import Dict, Any +import sys from pathlib import Path +from typing import Any, Dict from jinja2 import Environment, FileSystemLoader from jinja2.environment import Template diff --git a/wpilibj/generate_hids.py b/wpilibj/generate_hids.py index aaa13bf7cf1..f8391a9ec38 100755 --- a/wpilibj/generate_hids.py +++ b/wpilibj/generate_hids.py @@ -3,9 +3,9 @@ # Copyright (c) FIRST and other WPILib contributors. # 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. +import argparse import json import sys -import argparse from pathlib import Path from jinja2 import Environment, FileSystemLoader diff --git a/wpilibj/generate_pwm_motor_controllers.py b/wpilibj/generate_pwm_motor_controllers.py index a8dd780207a..b5af130bd51 100755 --- a/wpilibj/generate_pwm_motor_controllers.py +++ b/wpilibj/generate_pwm_motor_controllers.py @@ -7,7 +7,7 @@ import json import sys from pathlib import Path -from typing import Dict, Any +from typing import Any, Dict from jinja2 import Environment, FileSystemLoader from jinja2.environment import Template diff --git a/wpimath/generate_numbers.py b/wpimath/generate_numbers.py index b95800e4d4d..dd0eb80251b 100755 --- a/wpimath/generate_numbers.py +++ b/wpimath/generate_numbers.py @@ -4,11 +4,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. -import sys import argparse -from jinja2 import Environment, FileSystemLoader +import sys from pathlib import Path +from jinja2 import Environment, FileSystemLoader + def output(output_dir: Path, outfn: str, contents: str): output_dir.mkdir(parents=True, exist_ok=True) diff --git a/wpimath/generate_quickbuf.py b/wpimath/generate_quickbuf.py index 944cc34d5d3..98f2789ef04 100755 --- a/wpimath/generate_quickbuf.py +++ b/wpimath/generate_quickbuf.py @@ -3,9 +3,8 @@ # Copyright (c) FIRST and other WPILib contributors. # 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. -import subprocess -import sys import argparse +import subprocess import sys from pathlib import Path diff --git a/wpiutil/examples/printlog/datalog.py b/wpiutil/examples/printlog/datalog.py index 5bc50cc5b23..649212575cb 100755 --- a/wpiutil/examples/printlog/datalog.py +++ b/wpiutil/examples/printlog/datalog.py @@ -5,9 +5,10 @@ import array import struct -import msgpack from typing import List, SupportsBytes +import msgpack + __all__ = ["StartRecordData", "MetadataRecordData", "DataLogRecord", "DataLogReader"] floatStruct = struct.Struct(" DataLogIterator: if __name__ == "__main__": - from datetime import datetime import mmap import sys + from datetime import datetime if len(sys.argv) != 2: print("Usage: datalog.py ", file=sys.stderr) From 730e1146c9d51f331c26a87db9db460e188b0b04 Mon Sep 17 00:00:00 2001 From: Daniel Chen <108989218+Daniel1464@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:02:14 -0500 Subject: [PATCH 08/15] Revert merge errors --- hal/generate_usage_reporting.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hal/generate_usage_reporting.py b/hal/generate_usage_reporting.py index 88a3ba70351..39764c9711a 100755 --- a/hal/generate_usage_reporting.py +++ b/hal/generate_usage_reporting.py @@ -3,6 +3,7 @@ # Copyright (c) FIRST and other WPILib contributors. # 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. + import argparse from pathlib import Path From 791f0f950386d3281165c430b9941067b4f8ad71 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Sat, 16 Nov 2024 13:11:13 -0500 Subject: [PATCH 09/15] Added java tests --- .../command/CommandDecoratorTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index 1f9605d010c..aea48e43b6b 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -271,6 +271,71 @@ void deadlineForOrderTest() { } } + @Test + void withDeadlineTest() { + try (CommandScheduler scheduler = new CommandScheduler()) { + AtomicBoolean finish = new AtomicBoolean(false); + + Command endsBeforeGroup = Commands.none().withDeadline( + Commands.waitUntil(finish::get) + ); + Command endsAfterGroup = Commands.idle().withDeadline( + Commands.waitUntil(finish::get) + ); + + scheduler.schedule(endsBeforeGroup); + scheduler.run(); + + assertTrue(scheduler.isScheduled(endsBeforeGroup)); + + finish.set(true); + scheduler.run(); + + assertFalse(scheduler.isScheduled(endsBeforeGroup)); + + finish.set(false); + scheduler.schedule(endsAfterGroup); + scheduler.run(); + + assertTrue(scheduler.isScheduled(endsAfterGroup)); + + finish.set(true); + scheduler.run(); + + assertFalse(scheduler.isScheduled(endsAfterGroup)); + } + } + + @Test + void withDeadlineOrderTest() { + try (CommandScheduler scheduler = new CommandScheduler()) { + AtomicBoolean dictatorHasRun = new AtomicBoolean(false); + AtomicBoolean dictatorWasPolled = new AtomicBoolean(false); + + Command dictator = + new FunctionalCommand( + () -> {}, + () -> dictatorHasRun.set(true), + interrupted -> {}, + () -> { + dictatorWasPolled.set(true); + return true; + }); + Command other = + Commands.run( + () -> + assertAll( + () -> assertTrue(dictatorHasRun.get()), + () -> assertTrue(dictatorWasPolled.get()))); + + Command group = other.withDeadline(dictator); + scheduler.schedule(group); + scheduler.run(); + + assertAll(() -> assertTrue(dictatorHasRun.get()), () -> assertTrue(dictatorWasPolled.get())); + } + } + @Test void alongWithTest() { try (CommandScheduler scheduler = new CommandScheduler()) { From d3e91c5a9cca5a4e9db2b669f8ae25f2e299d1dc Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Mon, 18 Nov 2024 14:34:31 -0500 Subject: [PATCH 10/15] Removed java unit tests for now --- .../command/CommandDecoratorTest.java | 65 ------------------- 1 file changed, 65 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index aea48e43b6b..1f9605d010c 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -271,71 +271,6 @@ void deadlineForOrderTest() { } } - @Test - void withDeadlineTest() { - try (CommandScheduler scheduler = new CommandScheduler()) { - AtomicBoolean finish = new AtomicBoolean(false); - - Command endsBeforeGroup = Commands.none().withDeadline( - Commands.waitUntil(finish::get) - ); - Command endsAfterGroup = Commands.idle().withDeadline( - Commands.waitUntil(finish::get) - ); - - scheduler.schedule(endsBeforeGroup); - scheduler.run(); - - assertTrue(scheduler.isScheduled(endsBeforeGroup)); - - finish.set(true); - scheduler.run(); - - assertFalse(scheduler.isScheduled(endsBeforeGroup)); - - finish.set(false); - scheduler.schedule(endsAfterGroup); - scheduler.run(); - - assertTrue(scheduler.isScheduled(endsAfterGroup)); - - finish.set(true); - scheduler.run(); - - assertFalse(scheduler.isScheduled(endsAfterGroup)); - } - } - - @Test - void withDeadlineOrderTest() { - try (CommandScheduler scheduler = new CommandScheduler()) { - AtomicBoolean dictatorHasRun = new AtomicBoolean(false); - AtomicBoolean dictatorWasPolled = new AtomicBoolean(false); - - Command dictator = - new FunctionalCommand( - () -> {}, - () -> dictatorHasRun.set(true), - interrupted -> {}, - () -> { - dictatorWasPolled.set(true); - return true; - }); - Command other = - Commands.run( - () -> - assertAll( - () -> assertTrue(dictatorHasRun.get()), - () -> assertTrue(dictatorWasPolled.get()))); - - Command group = other.withDeadline(dictator); - scheduler.schedule(group); - scheduler.run(); - - assertAll(() -> assertTrue(dictatorHasRun.get()), () -> assertTrue(dictatorWasPolled.get())); - } - } - @Test void alongWithTest() { try (CommandScheduler scheduler = new CommandScheduler()) { From 9580f02b8bbade0682810910c45d5eb2e92d78d9 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Mon, 18 Nov 2024 14:42:50 -0500 Subject: [PATCH 11/15] Add c++ tests and java tests --- .../command/CommandDecoratorTest.java | 52 +++++++++++++++++++ .../cpp/frc2/command/CommandDecoratorTest.cpp | 48 +++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index 1f9605d010c..f649a3151fa 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -270,6 +270,58 @@ void deadlineForOrderTest() { assertAll(() -> assertTrue(dictatorHasRun.get()), () -> assertTrue(dictatorWasPolled.get())); } } + + @Test + void withDeadlineTest() { + try (CommandScheduler scheduler = new CommandScheduler()) { + AtomicBoolean finish = new AtomicBoolean(false); + Command endsBeforeGroup = Commands.none().withDeadline( + Commands.waitUntil(finish::get) + ); + Command endsAfterGroup = Commands.idle().withDeadline( + Commands.waitUntil(finish::get) + ); + scheduler.schedule(endsBeforeGroup); + scheduler.run(); + assertTrue(scheduler.isScheduled(endsBeforeGroup)); + finish.set(true); + scheduler.run(); + assertFalse(scheduler.isScheduled(endsBeforeGroup)); + finish.set(false); + scheduler.schedule(endsAfterGroup); + scheduler.run(); + assertTrue(scheduler.isScheduled(endsAfterGroup)); + finish.set(true); + scheduler.run(); + assertFalse(scheduler.isScheduled(endsAfterGroup)); + } + } + @Test + void withDeadlineOrderTest() { + try (CommandScheduler scheduler = new CommandScheduler()) { + AtomicBoolean dictatorHasRun = new AtomicBoolean(false); + AtomicBoolean dictatorWasPolled = new AtomicBoolean(false); + Command dictator = + new FunctionalCommand( + () -> {}, + () -> dictatorHasRun.set(true), + interrupted -> {}, + () -> { + dictatorWasPolled.set(true); + return true; + }); + Command other = + Commands.run( + () -> + assertAll( + () -> assertTrue(dictatorHasRun.get()), + () -> assertTrue(dictatorWasPolled.get()))); + Command group = other.withDeadline(dictator); + scheduler.schedule(group); + scheduler.run(); + assertAll(() -> assertTrue(dictatorHasRun.get()), () -> assertTrue(dictatorWasPolled.get())); + } + } @Test void alongWithTest() { diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp index 3a31308a3f0..a0b7726f5d6 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandDecoratorTest.cpp @@ -221,6 +221,27 @@ TEST_F(CommandDecoratorTest, DeadlineFor) { EXPECT_FALSE(scheduler.IsScheduled(group)); } +TEST_F(CommandDecoratorTest, WithDeadline) { + CommandScheduler scheduler = GetScheduler(); + + bool finish = false; + + auto dictator = WaitUntilCommand([&finish] { return finish; }); + auto endsAfter = WaitUntilCommand([] { return false; }); + + auto group = std::move(endsAfter).WithDeadline(std::move(dictator).ToPtr()); + + scheduler.Schedule(group); + scheduler.Run(); + + EXPECT_TRUE(scheduler.IsScheduled(group)); + + finish = true; + scheduler.Run(); + + EXPECT_FALSE(scheduler.IsScheduled(group)); +} + TEST_F(CommandDecoratorTest, AlongWith) { CommandScheduler scheduler = GetScheduler(); @@ -283,6 +304,33 @@ TEST_F(CommandDecoratorTest, DeadlineForOrder) { EXPECT_TRUE(dictatorWasPolled); } +TEST_F(CommandDecoratorTest, WithDeadlineOrder) { + CommandScheduler scheduler = GetScheduler(); + + bool dictatorHasRun = false; + bool dictatorWasPolled = false; + + auto dictator = + FunctionalCommand([] {}, [&dictatorHasRun] { dictatorHasRun = true; }, + [](bool interrupted) {}, + [&dictatorWasPolled] { + dictatorWasPolled = true; + return true; + }); + auto other = RunCommand([&dictatorHasRun, &dictatorWasPolled] { + EXPECT_TRUE(dictatorHasRun); + EXPECT_TRUE(dictatorWasPolled); + }); + + auto group = std::move(other).WithDeadline(std::move(dictator).ToPtr()); + + scheduler.Schedule(group); + scheduler.Run(); + + EXPECT_TRUE(dictatorHasRun); + EXPECT_TRUE(dictatorWasPolled); +} + TEST_F(CommandDecoratorTest, AlongWithOrder) { CommandScheduler scheduler = GetScheduler(); From f37f09fdf7b106018794ee39264aeef954f2ccac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:23:28 +0000 Subject: [PATCH 12/15] Formatting fixes --- .../first/wpilibj2/command/CommandDecoratorTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index f649a3151fa..5475a1d166b 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -270,17 +270,13 @@ void deadlineForOrderTest() { assertAll(() -> assertTrue(dictatorHasRun.get()), () -> assertTrue(dictatorWasPolled.get())); } } - + @Test void withDeadlineTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean finish = new AtomicBoolean(false); - Command endsBeforeGroup = Commands.none().withDeadline( - Commands.waitUntil(finish::get) - ); - Command endsAfterGroup = Commands.idle().withDeadline( - Commands.waitUntil(finish::get) - ); + Command endsBeforeGroup = Commands.none().withDeadline(Commands.waitUntil(finish::get)); + Command endsAfterGroup = Commands.idle().withDeadline(Commands.waitUntil(finish::get)); scheduler.schedule(endsBeforeGroup); scheduler.run(); assertTrue(scheduler.isScheduled(endsBeforeGroup)); @@ -296,6 +292,7 @@ void withDeadlineTest() { assertFalse(scheduler.isScheduled(endsAfterGroup)); } } + @Test void withDeadlineOrderTest() { try (CommandScheduler scheduler = new CommandScheduler()) { From 183a921e8a835b0703c16f2affa07adb93fd5915 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Mon, 18 Nov 2024 18:24:19 -0500 Subject: [PATCH 13/15] Last-minute docs updates --- .../main/java/edu/wpi/first/wpilibj2/command/Command.java | 6 ++++-- .../src/main/native/include/frc2/command/Command.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 513237c7a29..936938474d5 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -288,8 +288,8 @@ public SequentialCommandGroup andThen(Command... next) { } /** - * Creates a new command that runs this command and the deadline in parallel, finishing when the - * deadline finishes. + * Creates a new command that runs this command and the deadline in parallel, finishing + * (and interrupting this command) when the deadline finishes. * *

Note: This decorator works by adding this command to a composition. The command the * decorator was called on cannot be scheduled independently or be added to a different @@ -299,6 +299,7 @@ public SequentialCommandGroup andThen(Command... next) { * * @param deadline the deadline of the command group * @return the decorated command + * @see Command#deadlineFor */ public ParallelDeadlineGroup withDeadline(Command deadline) { return new ParallelDeadlineGroup(deadline, this); @@ -338,6 +339,7 @@ public ParallelDeadlineGroup deadlineWith(Command... parallel) { * @param parallel the commands to run in parallel. Note the parallel commands will be interrupted * when the deadline command ends * @return the decorated command + * @see Command#withDeadline */ public ParallelDeadlineGroup deadlineFor(Command... parallel) { return new ParallelDeadlineGroup(this, parallel); diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index 018b15717cf..2ebc950cfcf 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -311,11 +311,12 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { /** * Creates a new command that runs this command - * and the deadline in parallel, finishing when - * the deadline finishes. + * and the deadline in parallel, finishing + * (and interrupting this command) when the deadline finishes. * * @param deadline the deadline of the command group * @return the decorated command + * @see DeadlineFor */ CommandPtr WithDeadline(CommandPtr&& deadline) &&; @@ -328,6 +329,7 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { * @param parallel the commands to run in parallel. Note the parallel commands * will be interupted when the deadline command ends * @return the decorated command + * @see WithDeadline */ [[nodiscard]] CommandPtr DeadlineFor(CommandPtr&& parallel) &&; From b641858fb65852a6817b823f286529b409cebe00 Mon Sep 17 00:00:00 2001 From: Daniel Chen Date: Mon, 18 Nov 2024 18:26:25 -0500 Subject: [PATCH 14/15] Test formatting --- .../edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index 5475a1d166b..e71c89a002e 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -275,8 +275,8 @@ void deadlineForOrderTest() { void withDeadlineTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean finish = new AtomicBoolean(false); + Command endsBeforeGroup = Commands.none().withDeadline(Commands.waitUntil(finish::get)); - Command endsAfterGroup = Commands.idle().withDeadline(Commands.waitUntil(finish::get)); scheduler.schedule(endsBeforeGroup); scheduler.run(); assertTrue(scheduler.isScheduled(endsBeforeGroup)); @@ -284,6 +284,8 @@ void withDeadlineTest() { scheduler.run(); assertFalse(scheduler.isScheduled(endsBeforeGroup)); finish.set(false); + + Command endsAfterGroup = Commands.idle().withDeadline(Commands.waitUntil(finish::get)); scheduler.schedule(endsAfterGroup); scheduler.run(); assertTrue(scheduler.isScheduled(endsAfterGroup)); From ee5c0c6745df7d8758c5540614b57a4eea9fabe1 Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Mon, 18 Nov 2024 19:32:04 -0500 Subject: [PATCH 15/15] formatting fixes --- .../main/java/edu/wpi/first/wpilibj2/command/Command.java | 4 ++-- .../src/main/native/include/frc2/command/Command.h | 5 ++--- .../src/main/native/include/frc2/command/CommandPtr.h | 6 +++--- .../wpi/first/wpilibj2/command/CommandDecoratorTest.java | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 936938474d5..d6cd4c8860d 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -288,8 +288,8 @@ public SequentialCommandGroup andThen(Command... next) { } /** - * Creates a new command that runs this command and the deadline in parallel, finishing - * (and interrupting this command) when the deadline finishes. + * Creates a new command that runs this command and the deadline in parallel, finishing (and + * interrupting this command) when the deadline finishes. * *

Note: This decorator works by adding this command to a composition. The command the * decorator was called on cannot be scheduled independently or be added to a different diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h index 2ebc950cfcf..4dea3eb1a5f 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/Command.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/Command.h @@ -310,9 +310,8 @@ class Command : public wpi::Sendable, public wpi::SendableHelper { CommandPtr OnlyIf(std::function condition) &&; /** - * Creates a new command that runs this command - * and the deadline in parallel, finishing - * (and interrupting this command) when the deadline finishes. + * Creates a new command that runs this command and the deadline in parallel, + * finishing (and interrupting this command) when the deadline finishes. * * @param deadline the deadline of the command group * @return the decorated command diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h index 0900ac00d38..81a255a9a73 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -183,12 +183,12 @@ class CommandPtr final { CommandPtr OnlyIf(std::function condition) &&; /** - * Creates a new command that runs this command - * and the deadline in parallel, finishing when - * the deadline finishes. + * Creates a new command that runs this command and the deadline in parallel, + * finishing (and interrupting this command) when the deadline finishes. * * @param deadline the deadline of the command group * @return the decorated command + * @see DeadlineFor */ CommandPtr WithDeadline(CommandPtr&& deadline) &&; diff --git a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java index e71c89a002e..4d9ad2c06f9 100644 --- a/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java +++ b/wpilibNewCommands/src/test/java/edu/wpi/first/wpilibj2/command/CommandDecoratorTest.java @@ -275,7 +275,7 @@ void deadlineForOrderTest() { void withDeadlineTest() { try (CommandScheduler scheduler = new CommandScheduler()) { AtomicBoolean finish = new AtomicBoolean(false); - + Command endsBeforeGroup = Commands.none().withDeadline(Commands.waitUntil(finish::get)); scheduler.schedule(endsBeforeGroup); scheduler.run(); @@ -284,7 +284,7 @@ void withDeadlineTest() { scheduler.run(); assertFalse(scheduler.isScheduled(endsBeforeGroup)); finish.set(false); - + Command endsAfterGroup = Commands.idle().withDeadline(Commands.waitUntil(finish::get)); scheduler.schedule(endsAfterGroup); scheduler.run();