Merge branch 'main' into 2027

This commit is contained in:
Peter Johnson
2025-01-16 23:17:59 -08:00
92 changed files with 2748 additions and 534 deletions

View File

@@ -7,6 +7,7 @@
#include <utility>
#include <vector>
#include <wpi/FunctionExtras.h>
#include <wpi/deprecated.h>
#include "frc2/command/ConditionalCommand.h"
@@ -73,15 +74,21 @@ CommandPtr cmd::Print(std::string_view msg) {
return PrintCommand(msg).ToPtr();
}
WPI_IGNORE_DEPRECATED
CommandPtr cmd::DeferredProxy(wpi::unique_function<Command*()> supplier) {
return ProxyCommand(std::move(supplier)).ToPtr();
return Defer(
[supplier = std::move(supplier)]() mutable {
// There is no non-owning version of AsProxy(), so use the non-owning
// ProxyCommand constructor instead.
return ProxyCommand{supplier()}.ToPtr();
},
{});
}
CommandPtr cmd::DeferredProxy(wpi::unique_function<CommandPtr()> supplier) {
return ProxyCommand(std::move(supplier)).ToPtr();
return Defer([supplier = std::move(
supplier)]() mutable { return supplier().AsProxy(); },
{});
}
WPI_UNIGNORE_DEPRECATED
CommandPtr cmd::Wait(units::second_t duration) {
return WaitCommand(duration).ToPtr();

View File

@@ -88,6 +88,10 @@ class CommandScheduler final : public wpi::Sendable,
* interruptible. If this is the case, they will be interrupted and the
* command will be scheduled.
*
* @warning Using this function directly can often lead to unexpected behavior
* and should be avoided. Instead Triggers should be used to schedule
* Commands.
*
* @param command the command to schedule
*/
void Schedule(const CommandPtr& command);
@@ -112,6 +116,10 @@ class CommandScheduler final : public wpi::Sendable,
*
* The pointer must remain valid through the entire lifecycle of the command.
*
* @warning Using this function directly can often lead to unexpected behavior
* and should be avoided. Instead Triggers should be used to schedule
* Commands.
*
* @param command the command to schedule
*/
void Schedule(Command* command);
@@ -120,6 +128,10 @@ class CommandScheduler final : public wpi::Sendable,
* Schedules multiple commands for execution. Does nothing for commands
* already scheduled.
*
* @warning Using this function directly can often lead to unexpected behavior
* and should be avoided. Instead Triggers should be used to schedule
* Commands.
*
* @param commands the commands to schedule
*/
void Schedule(std::span<Command* const> commands);
@@ -128,6 +140,10 @@ class CommandScheduler final : public wpi::Sendable,
* Schedules multiple commands for execution. Does nothing for commands
* already scheduled.
*
* @warning Using this function directly can often lead to unexpected behavior
* and should be avoided. Instead Triggers should be used to schedule
* Commands.
*
* @param commands the commands to schedule
*/
void Schedule(std::initializer_list<Command*> commands);

View File

@@ -169,15 +169,11 @@ CommandPtr Defer(wpi::unique_function<CommandPtr()> supplier,
/**
* Constructs a command that schedules the command returned from the supplier
* when initialized, and ends when it is no longer scheduled. The supplier is
* called when the command is initialized. As a replacement, consider using
* `Defer(supplier).AsProxy()`.
* called when the command is initialized.
*
* @param supplier the command supplier
*/
WPI_IGNORE_DEPRECATED
[[nodiscard]] [[deprecated(
"The ProxyCommand supplier constructor has been deprecated. Use "
"Defer(supplier).AsProxy() instead.")]]
[[nodiscard]]
CommandPtr DeferredProxy(wpi::unique_function<Command*()> supplier);
/**
@@ -187,11 +183,8 @@ CommandPtr DeferredProxy(wpi::unique_function<Command*()> supplier);
*
* @param supplier the command supplier
*/
[[nodiscard]] [[deprecated(
"The ProxyCommand supplier constructor has been deprecated. Use "
"Defer(supplier).AsProxy() instead.")]]
[[nodiscard]]
CommandPtr DeferredProxy(wpi::unique_function<CommandPtr()> supplier);
WPI_UNIGNORE_DEPRECATED
// Command Groups
namespace impl {