mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Remove deprecated code (#8656)
This commit is contained in:
@@ -245,8 +245,8 @@ public class AprilTagFieldLayout {
|
||||
/**
|
||||
* Deserializes a field layout from a resource within a internal jar file.
|
||||
*
|
||||
* <p>Users should use {@link AprilTagFields#loadAprilTagLayoutField()} to load official layouts
|
||||
* and {@link #AprilTagFieldLayout(String)} for custom layouts.
|
||||
* <p>Users should use {@link #loadField(AprilTagFields)} to load official layouts and {@link
|
||||
* #AprilTagFieldLayout(String)} for custom layouts.
|
||||
*
|
||||
* @param resourcePath The absolute path of the resource
|
||||
* @return The deserialized layout
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
package org.wpilib.vision.apriltag;
|
||||
|
||||
import java.io.UncheckedIOException;
|
||||
|
||||
/** Loadable AprilTag field layouts. */
|
||||
public enum AprilTagFields {
|
||||
/** 2022 Rapid React. */
|
||||
@@ -37,16 +35,4 @@ public enum AprilTagFields {
|
||||
AprilTagFields(String resourceFile) {
|
||||
m_resourceFile = kBaseResourceDir + resourceFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link AprilTagFieldLayout} from the resource JSON.
|
||||
*
|
||||
* @return AprilTagFieldLayout of the field
|
||||
* @throws UncheckedIOException If the layout does not exist
|
||||
* @deprecated Use {@link AprilTagFieldLayout#loadField(AprilTagFields)} instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2025")
|
||||
public AprilTagFieldLayout loadAprilTagLayoutField() {
|
||||
return AprilTagFieldLayout.loadField(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,8 +177,3 @@ AprilTagFieldLayout AprilTagFieldLayout::LoadField(AprilTagField field) {
|
||||
wpi::util::json json = wpi::util::json::parse(fieldString);
|
||||
return json.get<AprilTagFieldLayout>();
|
||||
}
|
||||
|
||||
AprilTagFieldLayout wpi::apriltag::LoadAprilTagLayoutField(
|
||||
AprilTagField field) {
|
||||
return AprilTagFieldLayout::LoadField(field);
|
||||
}
|
||||
|
||||
@@ -161,15 +161,4 @@ void to_json(wpi::util::json& json, const AprilTagFieldLayout& layout);
|
||||
WPILIB_DLLEXPORT
|
||||
void from_json(const wpi::util::json& json, AprilTagFieldLayout& layout);
|
||||
|
||||
/**
|
||||
* Loads an AprilTagFieldLayout from a predefined field
|
||||
*
|
||||
* @param field The predefined field
|
||||
* @return AprilTagFieldLayout of the field
|
||||
* @deprecated Use AprilTagFieldLayout::LoadField() instead
|
||||
*/
|
||||
[[deprecated("Use AprilTagFieldLayout::LoadField() instead")]]
|
||||
WPILIB_DLLEXPORT AprilTagFieldLayout
|
||||
LoadAprilTagLayoutField(AprilTagField field);
|
||||
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -3,8 +3,6 @@ functions:
|
||||
ignore: true
|
||||
from_json:
|
||||
ignore: true
|
||||
LoadAprilTagLayoutField:
|
||||
ignore: true
|
||||
classes:
|
||||
wpi::apriltag::AprilTagFieldLayout:
|
||||
enums:
|
||||
|
||||
@@ -307,26 +307,6 @@ public abstract class Command implements Sendable {
|
||||
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
|
||||
* constructing a new {@link ParallelDeadlineGroup} explicitly.
|
||||
*
|
||||
* <p>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 parallel the commands to run in parallel
|
||||
* @return the decorated command
|
||||
* @deprecated Use {@link deadlineFor} instead.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public ParallelDeadlineGroup deadlineWith(Command... parallel) {
|
||||
return new ParallelDeadlineGroup(this, parallel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -535,16 +515,6 @@ public abstract class Command implements Sendable {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules this command.
|
||||
*
|
||||
* @deprecated Use CommandScheduler.getInstance().schedule(Command...) instead
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public void schedule() {
|
||||
CommandScheduler.getInstance().schedule(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels this command. Will call {@link #end(boolean) end(true)}. Commands will be canceled
|
||||
* regardless of {@link InterruptionBehavior interruption behavior}.
|
||||
|
||||
@@ -24,24 +24,6 @@ public class ProxyCommand extends Command {
|
||||
private final Supplier<Command> m_supplier;
|
||||
private Command m_command;
|
||||
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when
|
||||
* it is no longer scheduled. Use this for lazily creating <strong>proxied</strong> commands at
|
||||
* runtime. Proxying should only be done to escape from composition requirement semantics, so if
|
||||
* only initialization time command construction is needed, use {@link DeferredCommand} instead.
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
* @deprecated This constructor's similarity to {@link DeferredCommand} is confusing and opens
|
||||
* potential footguns for users who do not fully understand the semantics and implications of
|
||||
* proxying, but who simply want runtime construction. Users who do know what they are doing
|
||||
* and need a supplier-constructed proxied command should instead defer a proxy command.
|
||||
* @see DeferredCommand
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public ProxyCommand(Supplier<Command> supplier) {
|
||||
m_supplier = requireNonNullParam(supplier, "supplier", "ProxyCommand");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the given command when initialized, and ends when it
|
||||
* is no longer scheduled.
|
||||
|
||||
@@ -152,10 +152,6 @@ CommandPtr Command::WithName(std::string_view name) && {
|
||||
return std::move(*this).ToPtr().WithName(name);
|
||||
}
|
||||
|
||||
void Command::Schedule() {
|
||||
CommandScheduler::GetInstance().Schedule(this);
|
||||
}
|
||||
|
||||
void Command::Cancel() {
|
||||
CommandScheduler::GetInstance().Cancel(this);
|
||||
}
|
||||
|
||||
@@ -176,15 +176,6 @@ CommandPtr CommandPtr::WithDeadline(CommandPtr&& deadline) && {
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::DeadlineWith(CommandPtr&& parallel) && {
|
||||
AssertValid();
|
||||
std::vector<std::unique_ptr<Command>> vec;
|
||||
vec.emplace_back(std::move(parallel).Unwrap());
|
||||
m_ptr =
|
||||
std::make_unique<ParallelDeadlineGroup>(std::move(m_ptr), std::move(vec));
|
||||
return std::move(*this);
|
||||
}
|
||||
|
||||
CommandPtr CommandPtr::DeadlineFor(CommandPtr&& parallel) && {
|
||||
AssertValid();
|
||||
std::vector<std::unique_ptr<Command>> vec;
|
||||
@@ -268,11 +259,6 @@ std::unique_ptr<Command> CommandPtr::Unwrap() && {
|
||||
return std::move(m_ptr);
|
||||
}
|
||||
|
||||
void CommandPtr::Schedule() const& {
|
||||
AssertValid();
|
||||
CommandScheduler::GetInstance().Schedule(*this);
|
||||
}
|
||||
|
||||
void CommandPtr::Cancel() const& {
|
||||
AssertValid();
|
||||
CommandScheduler::GetInstance().Cancel(*this);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "wpi/commands2/WaitCommand.hpp"
|
||||
#include "wpi/commands2/WaitUntilCommand.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
using namespace wpi::cmd;
|
||||
|
||||
|
||||
@@ -9,23 +9,10 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
using namespace wpi::cmd;
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
ProxyCommand::ProxyCommand(wpi::util::unique_function<Command*()> supplier)
|
||||
: m_supplier(std::move(supplier)) {}
|
||||
|
||||
ProxyCommand::ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier)
|
||||
: ProxyCommand([supplier = std::move(supplier),
|
||||
holder = std::optional<CommandPtr>{}]() mutable {
|
||||
holder = supplier();
|
||||
return holder->get();
|
||||
}) {}
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
ProxyCommand::ProxyCommand(Command* command)
|
||||
: m_supplier([command] { return command; }) {
|
||||
SetName(fmt::format("Proxy({})", command->GetName()));
|
||||
|
||||
@@ -396,14 +396,6 @@ class Command : public wpi::util::Sendable,
|
||||
*/
|
||||
CommandPtr WithName(std::string_view name) &&;
|
||||
|
||||
/**
|
||||
* Schedules this command.
|
||||
*
|
||||
* @deprecated Use CommandScheduler::GetInstance().Schedule() instead
|
||||
*/
|
||||
[[deprecated("Use CommandScheduler::GetInstance().Schedule() instead.")]]
|
||||
void Schedule();
|
||||
|
||||
/**
|
||||
* Cancels this command. Will call End(true). Commands will be canceled
|
||||
* regardless of interruption behavior.
|
||||
|
||||
@@ -179,18 +179,6 @@ class [[nodiscard]] CommandPtr final {
|
||||
*/
|
||||
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
|
||||
* convenient/less-verbose than constructing a new {@link
|
||||
* ParallelDeadlineGroup} explicitly.
|
||||
*
|
||||
* @param parallel the commands to run in parallel
|
||||
* @return the decorated command
|
||||
*/
|
||||
[[deprecated("Replace with DeadlineFor")]]
|
||||
CommandPtr DeadlineWith(CommandPtr&& parallel) &&;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -274,17 +262,6 @@ class [[nodiscard]] CommandPtr final {
|
||||
*/
|
||||
std::unique_ptr<Command> Unwrap() &&;
|
||||
|
||||
/**
|
||||
* Schedules this command.
|
||||
*
|
||||
* @deprecated Use CommandScheduler::GetInstance().Schedule() instead
|
||||
*/
|
||||
[[deprecated("Use CommandScheduler::GetInstance().Schedule() instead.")]]
|
||||
void Schedule() const&;
|
||||
|
||||
// Prevent calls on a temporary, as the returned pointer would be invalid
|
||||
void Schedule() && = delete;
|
||||
|
||||
/**
|
||||
* Cancels this command. Will call End(true). Commands will be canceled
|
||||
* regardless of interruption behavior.
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "wpi/commands2/CommandPtr.hpp"
|
||||
#include "wpi/commands2/Requirements.hpp"
|
||||
#include "wpi/commands2/SelectCommand.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
class Subsystem;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "wpi/commands2/Command.hpp"
|
||||
#include "wpi/commands2/CommandHelper.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
@@ -27,46 +26,6 @@ namespace wpi::cmd {
|
||||
*/
|
||||
class ProxyCommand : public CommandHelper<Command, ProxyCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the supplied command when
|
||||
* initialized, and ends when it is no longer scheduled. Use this for lazily
|
||||
* creating <strong>proxied</strong> commands at runtime. Proxying should only
|
||||
* be done to escape from composition requirement semantics, so if only
|
||||
* initialization time command construction is needed, use {@link
|
||||
* DeferredCommand} instead.
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
* @deprecated This constructor's similarity to {@link DeferredCommand} is
|
||||
* confusing and opens potential footguns for users who do not fully
|
||||
* understand the semantics and implications of proxying, but who simply want
|
||||
* runtime construction. Users who do know what they are doing and need a
|
||||
* supplier-constructed proxied command should instead defer a proxy command.
|
||||
* @see DeferredCommand
|
||||
*/
|
||||
WPI_IGNORE_DEPRECATED
|
||||
[[deprecated("Defer a proxy command instead.")]]
|
||||
explicit ProxyCommand(wpi::util::unique_function<Command*()> supplier);
|
||||
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the supplied command when
|
||||
* initialized, and ends when it is no longer scheduled. Use this for lazily
|
||||
* creating <strong>proxied</strong> commands at runtime. Proxying should only
|
||||
* be done to escape from composition requirement semantics, so if only
|
||||
* initialization time command construction is needed, use {@link
|
||||
* DeferredCommand} instead.
|
||||
*
|
||||
* @param supplier the command supplier
|
||||
* @deprecated This constructor's similarity to {@link DeferredCommand} is
|
||||
* confusing and opens potential footguns for users who do not fully
|
||||
* understand the semantics and implications of proxying, but who simply want
|
||||
* runtime construction. Users who do know what they are doing and need a
|
||||
* supplier-constructed proxied command should instead defer a proxy command.
|
||||
* @see DeferredCommand
|
||||
*/
|
||||
[[deprecated("Defer a proxy command instead.")]]
|
||||
explicit ProxyCommand(wpi::util::unique_function<CommandPtr()> supplier);
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
/**
|
||||
* Creates a new ProxyCommand that schedules the given command when
|
||||
* initialized, and ends when it is no longer scheduled.
|
||||
|
||||
@@ -59,16 +59,3 @@ __all__ = [
|
||||
"WaitUntilCommand",
|
||||
"WrapperCommand",
|
||||
]
|
||||
|
||||
if not TYPE_CHECKING:
|
||||
|
||||
def __getattr__(attr):
|
||||
if attr == "SubsystemBase":
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"SubsystemBase is deprecated", DeprecationWarning, stacklevel=2
|
||||
)
|
||||
return Subsystem
|
||||
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")
|
||||
|
||||
@@ -260,35 +260,6 @@ class Command(Sendable):
|
||||
|
||||
return SequentialCommandGroup(self, *next)
|
||||
|
||||
def deadlineWith(self, *parallel: Command) -> ParallelDeadlineGroup:
|
||||
"""
|
||||
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
|
||||
constructing a new ParallelDeadlineGroup explicitly.
|
||||
|
||||
.. 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 :func:`commands2.CommandScheduler.removeComposedCommand`.
|
||||
The command composition returned from this method can be further
|
||||
decorated without issue.
|
||||
|
||||
:param parallel: the commands to run in parallel
|
||||
:returns: the decorated command
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"deadlineWith is deprecated use deadlineFor instead",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
from .paralleldeadlinegroup import ParallelDeadlineGroup
|
||||
|
||||
return ParallelDeadlineGroup(self, *parallel)
|
||||
|
||||
def deadlineFor(self, *parallel: Command) -> ParallelDeadlineGroup:
|
||||
"""
|
||||
Decorates this command with a set of commands to run parallel to it, ending when the calling
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
# validated: 2024-01-19 DS 192a28af4731 ProxyCommand.java
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, overload
|
||||
|
||||
from wpiutil import SendableBuilder
|
||||
|
||||
from .command import Command
|
||||
from .util import format_args_kwargs
|
||||
import warnings
|
||||
|
||||
|
||||
class ProxyCommand(Command):
|
||||
@@ -21,26 +17,8 @@ class ProxyCommand(Command):
|
||||
If this command is interrupted, it will cancel the command.
|
||||
"""
|
||||
|
||||
_supplier: Callable[[], Command]
|
||||
_command: Command
|
||||
|
||||
@overload
|
||||
def __init__(self, supplier: Callable[[], Command]):
|
||||
"""
|
||||
Creates a new ProxyCommand that schedules the supplied command when initialized, and ends when
|
||||
it is no longer scheduled. Use this for lazily creating **proxied** commands at
|
||||
runtime. Proxying should only be done to escape from composition requirement semantics, so if
|
||||
only initialization time command construction is needed, use DeferredCommand instead.
|
||||
|
||||
:param supplier: the command supplier
|
||||
This constructor's similarity to DeferredCommand is confusing and opens
|
||||
potential footguns for users who do not fully understand the semantics and implications of
|
||||
proxying, but who simply want runtime construction. Users who do know what they are doing
|
||||
and need a supplier-constructed proxied command should instead proxy a DeferredCommand
|
||||
using the ``asProxy`` decorator.
|
||||
"""
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, command: Command):
|
||||
"""
|
||||
Creates a new ProxyCommand that schedules the given command when initialized, and ends when it
|
||||
@@ -48,47 +26,12 @@ class ProxyCommand(Command):
|
||||
|
||||
:param command: the command to run by proxy
|
||||
"""
|
||||
...
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__()
|
||||
|
||||
def init_supplier(supplier: Callable[[], Command]):
|
||||
assert callable(supplier)
|
||||
self._supplier = supplier
|
||||
warnings.warn(
|
||||
"The ProxyCommand supplier constructor has been deprecated",
|
||||
DeprecationWarning,
|
||||
stacklevel=3,
|
||||
)
|
||||
|
||||
def init_command(command: Command):
|
||||
self.setName(f"Proxy({command.getName()})")
|
||||
self._supplier = lambda: command
|
||||
|
||||
num_args = len(args) + len(kwargs)
|
||||
|
||||
if num_args == 1 and len(kwargs) == 1:
|
||||
if "supplier" in kwargs:
|
||||
return init_supplier(kwargs["supplier"])
|
||||
elif "command" in kwargs:
|
||||
return init_command(kwargs["command"])
|
||||
elif num_args == 1 and len(args) == 1:
|
||||
if isinstance(args[0], Command):
|
||||
return init_command(args[0])
|
||||
elif callable(args[0]):
|
||||
return init_supplier(args[0])
|
||||
|
||||
raise TypeError(f"""
|
||||
TypeError: ProxyCommand(): incompatible function arguments. The following argument types are supported:
|
||||
1. (self: ProxyCommand, supplier: () -> Command)
|
||||
2. (self: ProxyCommand, command: Command)
|
||||
|
||||
Invoked with: {format_args_kwargs(self, *args, **kwargs)}
|
||||
""")
|
||||
self.setName(f"Proxy({command.getName()})")
|
||||
self._command = command
|
||||
|
||||
def initialize(self):
|
||||
self._command = self._supplier()
|
||||
self._command.schedule()
|
||||
|
||||
def end(self, interrupted: bool):
|
||||
|
||||
@@ -78,24 +78,6 @@ def test_andThen(scheduler: commands2.CommandScheduler):
|
||||
assert condition == True
|
||||
|
||||
|
||||
def test_deadlineWith(scheduler: commands2.CommandScheduler):
|
||||
condition = OOBoolean(False)
|
||||
condition.set(False)
|
||||
|
||||
dictator = commands2.WaitUntilCommand(condition)
|
||||
endsBefore = commands2.InstantCommand()
|
||||
endsAfter = commands2.WaitUntilCommand(lambda: False)
|
||||
|
||||
group = dictator.deadlineWith(endsBefore, endsAfter)
|
||||
|
||||
scheduler.schedule(group)
|
||||
scheduler.run()
|
||||
assert group.isScheduled()
|
||||
condition.set(True)
|
||||
scheduler.run()
|
||||
assert not group.isScheduled()
|
||||
|
||||
|
||||
def test_deadlineFor(scheduler: commands2.CommandScheduler):
|
||||
condition = OOBoolean(False)
|
||||
condition.set(False)
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
|
||||
using namespace wpi::util::java;
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
namespace wpi::nt {
|
||||
bool JNI_LoadTypes(JNIEnv* env);
|
||||
void JNI_UnloadTypes(JNIEnv* env);
|
||||
|
||||
@@ -53,45 +53,7 @@ bool {{ ConsoleName }}Controller::Get{{ capitalize_first(button.name) }}ButtonRe
|
||||
BooleanEvent {{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->Get{{ capitalize_first(button.name) }}Button(); });
|
||||
}
|
||||
{% endfor -%}
|
||||
{% if ConsoleName == "Xbox" or ConsoleName == "Stadia"%}
|
||||
bool {{ ConsoleName }}Controller::GetLeftBumper() const {
|
||||
return GetRawButton(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetRightBumper() const {
|
||||
return GetRawButton(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetLeftBumperPressed() {
|
||||
return GetRawButtonPressed(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetRightBumperPressed() {
|
||||
return GetRawButtonPressed(Button::kRightBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetLeftBumperReleased() {
|
||||
return GetRawButtonReleased(Button::kLeftBumper);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetRightBumperReleased() {
|
||||
return GetRawButtonReleased(Button::kRightBumper);
|
||||
}
|
||||
{%- elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
bool {{ ConsoleName }}Controller::GetTouchpad() const {
|
||||
return GetRawButton(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetTouchpadPressed() {
|
||||
return GetRawButtonPressed(Button::kTouchpad);
|
||||
}
|
||||
|
||||
bool {{ ConsoleName }}Controller::GetTouchpadReleased() {
|
||||
return GetRawButtonReleased(Button::kTouchpad);
|
||||
}
|
||||
{%- endif %}
|
||||
|
||||
{% endfor %}
|
||||
void {{ ConsoleName }}Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "{{ ConsoleName }}");
|
||||
|
||||
@@ -116,106 +116,7 @@ class {{ ConsoleName }}Controller : public GenericHID,
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
BooleanEvent {{ capitalize_first(button.name) }}(EventLoop* loop) const;
|
||||
{% endfor -%}
|
||||
{% if ConsoleName == "Xbox" or ConsoleName == "Stadia" %}
|
||||
/**
|
||||
* Read the value of the left bumper (LB) button on the controller.
|
||||
*
|
||||
* @return the state of the button
|
||||
* @deprecated Use GetLeftBumperButton instead. This function is deprecated
|
||||
* for removal to make function names consistent to allow the HID classes to
|
||||
* be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetLeftBumperButton instead")]]
|
||||
bool GetLeftBumper() const;
|
||||
|
||||
/**
|
||||
* Read the value of the right bumper (RB) button on the controller.
|
||||
*
|
||||
* @return the state of the button
|
||||
* @deprecated Use GetRightBumperButton instead. This function is deprecated
|
||||
* for removal to make function names consistent to allow the HID classes to
|
||||
* be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetRightBumperButton instead")]]
|
||||
bool GetRightBumper() const;
|
||||
|
||||
/**
|
||||
* Whether the left bumper (LB) was pressed since the last check.
|
||||
*
|
||||
* @return Whether the button was pressed since the last check
|
||||
* @deprecated Use GetLeftBumperButtonPressed instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetLeftBumperButtonPressed instead")]]
|
||||
bool GetLeftBumperPressed();
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was pressed since the last check.
|
||||
*
|
||||
* @return Whether the button was pressed since the last check
|
||||
* @deprecated Use GetRightBumperButtonPressed instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetRightBumperButtonPressed instead")]]
|
||||
bool GetRightBumperPressed();
|
||||
|
||||
/**
|
||||
* Whether the left bumper (LB) was released since the last check.
|
||||
*
|
||||
* @return Whether the button was released since the last check.
|
||||
* @deprecated Use GetLeftBumperButtonReleased instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetLeftBumperButtonReleased instead")]]
|
||||
bool GetLeftBumperReleased();
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was released since the last check.
|
||||
*
|
||||
* @return Whether the button was released since the last check.
|
||||
* @deprecated Use GetRightBumperButtonReleased instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetRightBumperButtonReleased instead")]]
|
||||
bool GetRightBumperReleased();
|
||||
{% elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
/**
|
||||
* Read the value of the touchpad button on the controller.
|
||||
*
|
||||
* @return The state of the button.
|
||||
* @deprecated Use GetTouchpadButton instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be
|
||||
* automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetTouchpadButton instead")]]
|
||||
bool GetTouchpad() const;
|
||||
/**
|
||||
* Whether the touchpad was pressed since the last check.
|
||||
*
|
||||
* @return Whether the touchpad was pressed since the last check.
|
||||
* @deprecated Use GetTouchpadButtonPressed instead. This function is
|
||||
* deprecated for removal to make function names consistent to allow the HID
|
||||
* classes to be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetTouchpadButtonPressed instead")]]
|
||||
bool GetTouchpadPressed();
|
||||
|
||||
/**
|
||||
* Whether the touchpad was released since the last check.
|
||||
*
|
||||
* @return Whether the touchpad was released since the last check.
|
||||
* @deprecated Use GetLeftBumperButton instead. This function is deprecated
|
||||
* for removal to make function names consistent to allow the HID classes to
|
||||
* be automatically generated.
|
||||
*/
|
||||
[[deprecated("Use GetTouchpadButtonReleased instead")]]
|
||||
bool GetTouchpadReleased();
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
/** Represents a digital button on an {{ ConsoleName }}Controller. */
|
||||
struct Button {
|
||||
{%- for button in buttons %}
|
||||
|
||||
@@ -265,7 +265,6 @@ BooleanEvent NiDsPS4Controller::Touchpad(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsPS4Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsPS4");
|
||||
|
||||
@@ -265,7 +265,6 @@ BooleanEvent NiDsPS5Controller::Touchpad(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetTouchpadButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsPS5Controller::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsPS5");
|
||||
|
||||
@@ -273,7 +273,6 @@ BooleanEvent NiDsStadiaController::Frame(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetFrameButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsStadiaController::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsStadia");
|
||||
|
||||
@@ -217,7 +217,6 @@ BooleanEvent NiDsXboxController::RightStick(EventLoop* loop) const {
|
||||
return BooleanEvent(loop, [this]() { return this->GetRightStickButton(); });
|
||||
}
|
||||
|
||||
|
||||
void NiDsXboxController::InitSendable(wpi::util::SendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("HID");
|
||||
builder.PublishConstString("ControllerType", "NiDsXbox");
|
||||
|
||||
@@ -86,10 +86,6 @@ void IterativeRobotBase::TeleopExit() {}
|
||||
|
||||
void IterativeRobotBase::TestExit() {}
|
||||
|
||||
void IterativeRobotBase::SetNetworkTablesFlushEnabled(bool enabled) {
|
||||
m_ntFlushEnabled = enabled;
|
||||
}
|
||||
|
||||
wpi::units::second_t IterativeRobotBase::GetPeriod() const {
|
||||
return m_period;
|
||||
}
|
||||
@@ -171,9 +167,7 @@ void IterativeRobotBase::LoopFunc() {
|
||||
m_watchdog.Disable();
|
||||
|
||||
// Flush NetworkTables
|
||||
if (m_ntFlushEnabled) {
|
||||
wpi::nt::NetworkTableInstance::GetDefault().FlushLocal();
|
||||
}
|
||||
wpi::nt::NetworkTableInstance::GetDefault().FlushLocal();
|
||||
|
||||
// Warn on loop time overruns
|
||||
if (m_watchdog.IsExpired()) {
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#include "wpi/system/Resource.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/system/Errors.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
using namespace wpi;
|
||||
|
||||
wpi::util::mutex Resource::m_createMutex;
|
||||
|
||||
void Resource::CreateResourceObject(std::unique_ptr<Resource>& r,
|
||||
uint32_t elements) {
|
||||
std::scoped_lock lock(m_createMutex);
|
||||
if (!r) {
|
||||
r = std::make_unique<Resource>(elements);
|
||||
}
|
||||
}
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
Resource::Resource(uint32_t elements) {
|
||||
m_isAllocated = std::vector<bool>(elements, false);
|
||||
}
|
||||
|
||||
uint32_t Resource::Allocate(const std::string& resourceDesc) {
|
||||
std::scoped_lock lock(m_allocateMutex);
|
||||
for (uint32_t i = 0; i < m_isAllocated.size(); i++) {
|
||||
if (!m_isAllocated[i]) {
|
||||
m_isAllocated[i] = true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw WPILIB_MakeError(err::NoAvailableResources, "{}", resourceDesc);
|
||||
}
|
||||
|
||||
uint32_t Resource::Allocate(uint32_t index, const std::string& resourceDesc) {
|
||||
std::scoped_lock lock(m_allocateMutex);
|
||||
if (index >= m_isAllocated.size()) {
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange, "{}", resourceDesc);
|
||||
}
|
||||
if (m_isAllocated[index]) {
|
||||
throw WPILIB_MakeError(err::ResourceAlreadyAllocated, "{}", resourceDesc);
|
||||
}
|
||||
m_isAllocated[index] = true;
|
||||
return index;
|
||||
}
|
||||
|
||||
void Resource::Free(uint32_t index) {
|
||||
std::unique_lock lock(m_allocateMutex);
|
||||
if (index == std::numeric_limits<uint32_t>::max()) {
|
||||
return;
|
||||
}
|
||||
if (index >= m_isAllocated.size()) {
|
||||
throw WPILIB_MakeError(err::NotAllocated, "index {}", index);
|
||||
}
|
||||
if (!m_isAllocated[index]) {
|
||||
throw WPILIB_MakeError(err::NotAllocated, "index {}", index);
|
||||
}
|
||||
m_isAllocated[index] = false;
|
||||
}
|
||||
@@ -187,16 +187,6 @@ class IterativeRobotBase : public RobotBase {
|
||||
*/
|
||||
virtual void TestExit();
|
||||
|
||||
/**
|
||||
* Enables or disables flushing NetworkTables every loop iteration.
|
||||
* By default, this is enabled.
|
||||
*
|
||||
* @param enabled True to enable, false to disable
|
||||
* @deprecated Deprecated without replacement.
|
||||
*/
|
||||
[[deprecated("Deprecated without replacement.")]]
|
||||
void SetNetworkTablesFlushEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* Gets time period between calls to Periodic() functions.
|
||||
*/
|
||||
@@ -229,7 +219,6 @@ class IterativeRobotBase : public RobotBase {
|
||||
int m_lastMode = -1;
|
||||
wpi::units::second_t m_period;
|
||||
Watchdog m_watchdog;
|
||||
bool m_ntFlushEnabled = true;
|
||||
bool m_calledDsConnected = false;
|
||||
|
||||
void PrintLoopOverrunMessage();
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* The Resource class is a convenient way to track allocated resources.
|
||||
*
|
||||
* It tracks them as indices in the range [0 .. elements - 1]. E.g. the library
|
||||
* uses this to track hardware channel allocation.
|
||||
*
|
||||
* The Resource class does not allocate the hardware channels or other
|
||||
* resources; it just tracks which indices were marked in use by Allocate and
|
||||
* not yet freed by Free.
|
||||
* @deprecated Use the HandleResource classes instead
|
||||
*/
|
||||
class [[deprecated("Use the HandleResource classes instead")]] Resource {
|
||||
public:
|
||||
virtual ~Resource() = default;
|
||||
|
||||
/**
|
||||
* Factory method to create a Resource allocation-tracker *if* needed.
|
||||
*
|
||||
* @param r address of the caller's Resource pointer. If *r == nullptr,
|
||||
* this will construct a Resource and make *r point to it. If
|
||||
* *r != nullptr, i.e. the caller already has a Resource
|
||||
* instance, this won't do anything.
|
||||
* @param elements the number of elements for this Resource allocator to
|
||||
* track, that is, it will allocate resource numbers in the
|
||||
* range [0 .. elements - 1].
|
||||
*/
|
||||
static void CreateResourceObject(std::unique_ptr<Resource>& r,
|
||||
uint32_t elements);
|
||||
|
||||
/**
|
||||
* Allocate storage for a new instance of Resource.
|
||||
*
|
||||
* Allocate a bool array of values that will get initialized to indicate that
|
||||
* no resources have been allocated yet. The indices of the resources are
|
||||
* [0 .. elements - 1].
|
||||
*/
|
||||
explicit Resource(uint32_t size);
|
||||
|
||||
/**
|
||||
* Allocate a resource.
|
||||
*
|
||||
* When a resource is requested, mark it allocated. In this case, a free
|
||||
* resource value within the range is located and returned after it is marked
|
||||
* allocated.
|
||||
*/
|
||||
uint32_t Allocate(const std::string& resourceDesc);
|
||||
|
||||
/**
|
||||
* Allocate a specific resource value.
|
||||
*
|
||||
* The user requests a specific resource value, i.e. channel number and it is
|
||||
* verified unallocated, then returned.
|
||||
*/
|
||||
uint32_t Allocate(uint32_t index, const std::string& resourceDesc);
|
||||
|
||||
/**
|
||||
* Free an allocated resource.
|
||||
*
|
||||
* After a resource is no longer needed, for example a destructor is called
|
||||
* for a channel assignment class, Free will release the resource value so it
|
||||
* can be reused somewhere else in the program.
|
||||
*/
|
||||
void Free(uint32_t index);
|
||||
|
||||
private:
|
||||
std::vector<bool> m_isAllocated;
|
||||
wpi::util::mutex m_allocateMutex;
|
||||
|
||||
static wpi::util::mutex m_createMutex;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
@@ -23,7 +23,6 @@ classes:
|
||||
AutonomousExit:
|
||||
TeleopExit:
|
||||
TestExit:
|
||||
SetNetworkTablesFlushEnabled:
|
||||
GetPeriod:
|
||||
PrintWatchdogEpochs:
|
||||
doc: |
|
||||
|
||||
@@ -186,123 +186,7 @@ public class {{ ConsoleName }}Controller extends GenericHID implements Sendable
|
||||
public BooleanEvent {{ button.name }}(EventLoop loop) {
|
||||
return button(Button.k{{ capitalize_first(button.name) }}.value, loop);
|
||||
}
|
||||
{% endfor -%}
|
||||
{% if ConsoleName == "Xbox" or ConsoleName == "Stadia" %}
|
||||
/**
|
||||
* Read the value of the left bumper (LB) button on the controller.
|
||||
*
|
||||
* @return The state of the button.
|
||||
* @deprecated Use {@link getLeftBumperButton} instead. This function is deprecated for removal
|
||||
* to make function names consistent to allow the HID classes to be automatically generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getLeftBumper() {
|
||||
return getRawButton(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the value of the right bumper (RB) button on the controller.
|
||||
*
|
||||
* @return The state of the button.
|
||||
* @deprecated Use {@link getRightBumperButton} instead. This function is deprecated for removal
|
||||
* to make function names consistent to allow the HID classes to be automatically generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getRightBumper() {
|
||||
return getRawButton(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the left bumper (LB) was pressed since the last check.
|
||||
*
|
||||
* @return Whether the button was pressed since the last check.
|
||||
* @deprecated Use {@link getLeftBumperButtonPressed} instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be automatically
|
||||
* generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getLeftBumperPressed() {
|
||||
return getRawButtonPressed(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was pressed since the last check.
|
||||
*
|
||||
* @return Whether the button was pressed since the last check.
|
||||
* @deprecated Use {@link getRightBumperButtonPressed} instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be automatically
|
||||
* generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getRightBumperPressed() {
|
||||
return getRawButtonPressed(Button.kRightBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the left bumper (LB) was released since the last check.
|
||||
*
|
||||
* @return Whether the button was released since the last check.
|
||||
* @deprecated Use {@link getLeftBumperButtonReleased} instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be automatically
|
||||
* generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getLeftBumperReleased() {
|
||||
return getRawButtonReleased(Button.kLeftBumper.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the right bumper (RB) was released since the last check.
|
||||
*
|
||||
* @return Whether the button was released since the last check.
|
||||
* @deprecated Use {@link getRightBumperButtonReleased} instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be automatically
|
||||
* generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getRightBumperReleased() {
|
||||
return getRawButtonReleased(Button.kRightBumper.value);
|
||||
}
|
||||
{%- elif ConsoleName == "PS4" or ConsoleName == "PS5" %}
|
||||
/**
|
||||
* Read the value of the touchpad on the controller.
|
||||
*
|
||||
* @return The state of the touchpad.
|
||||
* @deprecated Use {@link getTouchpadButton} instead. This function is deprecated for removal to
|
||||
* make function names consistent to allow the HID classes to be automatically generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getTouchpad() {
|
||||
return getRawButton(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the touchpad was pressed since the last check.
|
||||
*
|
||||
* @return Whether the touchpad was pressed since the last check.
|
||||
* @deprecated Use {@link getTouchpadButtonPressed} instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be automatically
|
||||
* generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getTouchpadPressed() {
|
||||
return getRawButtonPressed(Button.kTouchpad.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the touchpad was released since the last check.
|
||||
*
|
||||
* @return Whether the touchpad was released since the last check.
|
||||
* @deprecated Use {@link getTouchpadButtonReleased} instead. This function is deprecated for
|
||||
* removal to make function names consistent to allow the HID classes to be automatically
|
||||
* generated.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public boolean getTouchpadReleased() {
|
||||
return getRawButtonReleased(Button.kTouchpad.value);
|
||||
}
|
||||
{%- endif %}
|
||||
|
||||
{% endfor %}
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
|
||||
@@ -715,7 +715,6 @@ public class NiDsPS4Controller extends GenericHID implements Sendable {
|
||||
return button(Button.kTouchpad.value, loop);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
|
||||
@@ -715,7 +715,6 @@ public class NiDsPS5Controller extends GenericHID implements Sendable {
|
||||
return button(Button.kTouchpad.value, loop);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
|
||||
@@ -731,7 +731,6 @@ public class NiDsStadiaController extends GenericHID implements Sendable {
|
||||
return button(Button.kFrame.value, loop);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
|
||||
@@ -607,7 +607,6 @@ public class NiDsXboxController extends GenericHID implements Sendable {
|
||||
return button(Button.kRightStick.value, loop);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("HID");
|
||||
|
||||
@@ -60,7 +60,6 @@ public abstract class IterativeRobotBase extends RobotBase {
|
||||
private RobotMode m_lastMode;
|
||||
private final double m_period;
|
||||
private final Watchdog m_watchdog;
|
||||
private boolean m_ntFlushEnabled = true;
|
||||
private boolean m_calledDsConnected;
|
||||
|
||||
/**
|
||||
@@ -226,17 +225,6 @@ public abstract class IterativeRobotBase extends RobotBase {
|
||||
*/
|
||||
public void testExit() {}
|
||||
|
||||
/**
|
||||
* Enables or disables flushing NetworkTables every loop iteration. By default, this is enabled.
|
||||
*
|
||||
* @param enabled True to enable, false to disable
|
||||
* @deprecated Deprecated without replacement.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2025")
|
||||
public void setNetworkTablesFlushEnabled(boolean enabled) {
|
||||
m_ntFlushEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets time period between calls to Periodic() functions.
|
||||
*
|
||||
@@ -342,9 +330,7 @@ public abstract class IterativeRobotBase extends RobotBase {
|
||||
m_watchdog.disable();
|
||||
|
||||
// Flush NetworkTables
|
||||
if (m_ntFlushEnabled) {
|
||||
NetworkTableInstance.getDefault().flushLocal();
|
||||
}
|
||||
NetworkTableInstance.getDefault().flushLocal();
|
||||
|
||||
// Warn on loop time overruns
|
||||
if (m_watchdog.isExpired()) {
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
// 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.
|
||||
|
||||
package org.wpilib.system;
|
||||
|
||||
import org.wpilib.hardware.hal.util.AllocationException;
|
||||
import org.wpilib.hardware.hal.util.CheckedAllocationException;
|
||||
|
||||
/**
|
||||
* Track resources in the program. The Resource class is a convenient way of keeping track of
|
||||
* allocated arbitrary resources in the program. Resources are just indices that have a lower and
|
||||
* upper bound that are tracked by this class. In the library they are used for tracking allocation
|
||||
* of hardware channels but this is purely arbitrary. The resource class does not do any actual
|
||||
* allocation, but simply tracks if a given index is currently in use.
|
||||
*
|
||||
* <p><b>WARNING:</b> this should only be statically allocated. When the program loads into memory
|
||||
* all the static constructors are called. At that time a linked list of all the "Resources" is
|
||||
* created. Then, when the program actually starts - in the Robot constructor, all resources are
|
||||
* initialized. This ensures that the program is restartable in memory without having to
|
||||
* unload/reload.
|
||||
*
|
||||
* @deprecated Will be removed with no replacement.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2025")
|
||||
public final class Resource {
|
||||
private static Resource resourceList;
|
||||
private final boolean[] m_numAllocated;
|
||||
private final int m_size;
|
||||
private final Resource m_nextResource;
|
||||
|
||||
/** Clears all allocated resources. */
|
||||
public static void restartProgram() {
|
||||
for (Resource r = Resource.resourceList; r != null; r = r.m_nextResource) {
|
||||
for (int i = 0; i < r.m_size; i++) {
|
||||
r.m_numAllocated[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate storage for a new instance of Resource. Allocate a bool array of values that will get
|
||||
* initialized to indicate that no resources have been allocated yet. The indices of the resources
|
||||
* are 0..size-1.
|
||||
*
|
||||
* @param size The number of blocks to allocate
|
||||
*/
|
||||
public Resource(final int size) {
|
||||
m_size = size;
|
||||
m_numAllocated = new boolean[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
m_numAllocated[i] = false;
|
||||
}
|
||||
m_nextResource = Resource.resourceList;
|
||||
Resource.resourceList = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a resource. When a resource is requested, mark it allocated. In this case, a free
|
||||
* resource value within the range is located and returned after it is marked allocated.
|
||||
*
|
||||
* @return The index of the allocated block.
|
||||
* @throws CheckedAllocationException If there are no resources available to be allocated.
|
||||
*/
|
||||
public int allocate() throws CheckedAllocationException {
|
||||
for (int i = 0; i < m_size; i++) {
|
||||
if (!m_numAllocated[i]) {
|
||||
m_numAllocated[i] = true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
throw new CheckedAllocationException("No available resources");
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate a specific resource value. The user requests a specific resource value, i.e. channel
|
||||
* number, and it is verified unallocated, then returned.
|
||||
*
|
||||
* @param index The resource to allocate
|
||||
* @return The index of the allocated block
|
||||
* @throws CheckedAllocationException If there are no resources available to be allocated.
|
||||
*/
|
||||
public int allocate(final int index) throws CheckedAllocationException {
|
||||
if (index >= m_size || index < 0) {
|
||||
throw new CheckedAllocationException("Index " + index + " out of range");
|
||||
}
|
||||
if (m_numAllocated[index]) {
|
||||
throw new CheckedAllocationException("Resource at index " + index + " already allocated");
|
||||
}
|
||||
m_numAllocated[index] = true;
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free an allocated resource. After a resource is no longer needed, for example a destructor is
|
||||
* called for a channel assignment class, this method will release the resource value, so it can
|
||||
* be reused somewhere else in the program.
|
||||
*
|
||||
* @param index The index of the resource to free.
|
||||
*/
|
||||
public void free(final int index) {
|
||||
if (!m_numAllocated[index]) {
|
||||
throw new AllocationException("No resource available to be freed");
|
||||
}
|
||||
m_numAllocated[index] = false;
|
||||
}
|
||||
}
|
||||
@@ -222,28 +222,6 @@ public class PIDController implements Sendable, AutoCloseable {
|
||||
return m_period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position tolerance of this controller.
|
||||
*
|
||||
* @return the position tolerance of the controller.
|
||||
* @deprecated Use getErrorTolerance() instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2025")
|
||||
public double getPositionTolerance() {
|
||||
return m_errorTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the velocity tolerance of this controller.
|
||||
*
|
||||
* @return the velocity tolerance of the controller.
|
||||
* @deprecated Use getErrorDerivativeTolerance() instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2025")
|
||||
public double getVelocityTolerance() {
|
||||
return m_errorDerivativeTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error tolerance of this controller. Defaults to 0.05.
|
||||
*
|
||||
@@ -377,28 +355,6 @@ public class PIDController implements Sendable, AutoCloseable {
|
||||
m_errorDerivativeTolerance = errorDerivativeTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the difference between the setpoint and the measurement.
|
||||
*
|
||||
* @return The error.
|
||||
* @deprecated Use getError() instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2025")
|
||||
public double getPositionError() {
|
||||
return m_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the velocity error.
|
||||
*
|
||||
* @return The velocity error.
|
||||
* @deprecated Use getErrorDerivative() instead.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "2025")
|
||||
public double getVelocityError() {
|
||||
return m_errorDerivative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the difference between the setpoint and the measurement.
|
||||
*
|
||||
|
||||
@@ -6,34 +6,12 @@ package org.wpilib.math.trajectory.constraint;
|
||||
|
||||
import org.wpilib.math.geometry.Ellipse2d;
|
||||
import org.wpilib.math.geometry.Pose2d;
|
||||
import org.wpilib.math.geometry.Rotation2d;
|
||||
import org.wpilib.math.geometry.Translation2d;
|
||||
|
||||
/** Enforces a particular constraint only within an elliptical region. */
|
||||
public class EllipticalRegionConstraint implements TrajectoryConstraint {
|
||||
private final Ellipse2d m_ellipse;
|
||||
private final TrajectoryConstraint m_constraint;
|
||||
|
||||
/**
|
||||
* Constructs a new EllipticalRegionConstraint.
|
||||
*
|
||||
* @param center The center of the ellipse in which to enforce the constraint.
|
||||
* @param xWidth The width of the ellipse in which to enforce the constraint in meters.
|
||||
* @param yWidth The height of the ellipse in which to enforce the constraint in meters.
|
||||
* @param rotation The rotation to apply to all radii around the origin.
|
||||
* @param constraint The constraint to enforce when the robot is within the region.
|
||||
* @deprecated Use constructor taking Ellipse2d instead.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public EllipticalRegionConstraint(
|
||||
Translation2d center,
|
||||
double xWidth,
|
||||
double yWidth,
|
||||
Rotation2d rotation,
|
||||
TrajectoryConstraint constraint) {
|
||||
this(new Ellipse2d(new Pose2d(center, rotation), xWidth / 2.0, yWidth / 2.0), constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new EllipticalRegionConstraint.
|
||||
*
|
||||
|
||||
@@ -6,29 +6,12 @@ package org.wpilib.math.trajectory.constraint;
|
||||
|
||||
import org.wpilib.math.geometry.Pose2d;
|
||||
import org.wpilib.math.geometry.Rectangle2d;
|
||||
import org.wpilib.math.geometry.Translation2d;
|
||||
|
||||
/** Enforces a particular constraint only within a rectangular region. */
|
||||
public class RectangularRegionConstraint implements TrajectoryConstraint {
|
||||
private final Rectangle2d m_rectangle;
|
||||
private final TrajectoryConstraint m_constraint;
|
||||
|
||||
/**
|
||||
* Constructs a new RectangularRegionConstraint.
|
||||
*
|
||||
* @param bottomLeftPoint The bottom left point of the rectangular region in which to enforce the
|
||||
* constraint.
|
||||
* @param topRightPoint The top right point of the rectangular region in which to enforce the
|
||||
* constraint.
|
||||
* @param constraint The constraint to enforce when the robot is within the region.
|
||||
* @deprecated Use constructor taking Rectangle2d instead.
|
||||
*/
|
||||
@Deprecated(since = "2025", forRemoval = true)
|
||||
public RectangularRegionConstraint(
|
||||
Translation2d bottomLeftPoint, Translation2d topRightPoint, TrajectoryConstraint constraint) {
|
||||
this(new Rectangle2d(bottomLeftPoint, topRightPoint), constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new RectangularRegionConstraint.
|
||||
*
|
||||
|
||||
@@ -67,48 +67,6 @@ class WPILIB_DLLEXPORT ArmFeedforward {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the feedforward from the gains and setpoints assuming continuous
|
||||
* control.
|
||||
*
|
||||
* @param angle The angle setpoint, in radians. This angle should be
|
||||
* measured from the horizontal (i.e. if the provided
|
||||
* angle is 0, the arm should be parallel to the floor).
|
||||
* If your encoder does not follow this convention, an
|
||||
* offset should be added.
|
||||
* @param velocity The velocity setpoint.
|
||||
* @param acceleration The acceleration setpoint.
|
||||
* @return The computed feedforward, in volts.
|
||||
*/
|
||||
[[deprecated("Use the current/next velocity overload instead.")]]
|
||||
constexpr wpi::units::volt_t Calculate(
|
||||
wpi::units::unit_t<Angle> angle, wpi::units::unit_t<Velocity> velocity,
|
||||
wpi::units::unit_t<Acceleration> acceleration) const {
|
||||
return kS * wpi::util::sgn(velocity) + kG * wpi::units::math::cos(angle) +
|
||||
kV * velocity + kA * acceleration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the feedforward from the gains and setpoints assuming continuous
|
||||
* control.
|
||||
*
|
||||
* @param currentAngle The current angle in radians. This angle should be
|
||||
* measured from the horizontal (i.e. if the provided angle is 0, the arm
|
||||
* should be parallel to the floor). If your encoder does not follow this
|
||||
* convention, an offset should be added.
|
||||
* @param currentVelocity The current velocity setpoint.
|
||||
* @param nextVelocity The next velocity setpoint.
|
||||
* @param dt Time between velocity setpoints in seconds.
|
||||
* @return The computed feedforward in volts.
|
||||
*/
|
||||
[[deprecated("Use the current/next velocity overload instead.")]]
|
||||
wpi::units::volt_t Calculate(wpi::units::unit_t<Angle> currentAngle,
|
||||
wpi::units::unit_t<Velocity> currentVelocity,
|
||||
wpi::units::unit_t<Velocity> nextVelocity,
|
||||
wpi::units::second_t dt) const {
|
||||
return Calculate(currentAngle, currentVelocity, nextVelocity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the feedforward from the gains and setpoint assuming discrete
|
||||
* control. Use this method when the velocity does not change.
|
||||
|
||||
@@ -192,28 +192,6 @@ class WPILIB_DLLEXPORT PIDController
|
||||
return m_errorDerivativeTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the position tolerance of this controller.
|
||||
*
|
||||
* @return The position tolerance of the controller.
|
||||
* @deprecated Use GetErrorTolerance() instead.
|
||||
*/
|
||||
[[deprecated("Use the GetErrorTolerance method instead.")]]
|
||||
constexpr double GetPositionTolerance() const {
|
||||
return m_errorTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the velocity tolerance of this controller.
|
||||
*
|
||||
* @return The velocity tolerance of the controller.
|
||||
* @deprecated Use GetErrorDerivativeTolerance() instead.
|
||||
*/
|
||||
[[deprecated("Use the GetErrorDerivativeTolerance method instead.")]]
|
||||
constexpr double GetVelocityTolerance() const {
|
||||
return m_errorDerivativeTolerance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the accumulated error used in the integral calculation of this
|
||||
* controller.
|
||||
@@ -328,24 +306,6 @@ class WPILIB_DLLEXPORT PIDController
|
||||
*/
|
||||
constexpr double GetErrorDerivative() const { return m_errorDerivative; }
|
||||
|
||||
/**
|
||||
* Returns the difference between the setpoint and the measurement.
|
||||
* @deprecated Use GetError() instead.
|
||||
*/
|
||||
[[deprecated("Use GetError method instead.")]]
|
||||
constexpr double GetPositionError() const {
|
||||
return m_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the velocity error.
|
||||
* @deprecated Use GetErrorDerivative() instead.
|
||||
*/
|
||||
[[deprecated("Use GetErrorDerivative method instead.")]]
|
||||
constexpr double GetVelocityError() const {
|
||||
return m_errorDerivative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next output of the PID controller.
|
||||
*
|
||||
|
||||
@@ -21,26 +21,6 @@ namespace wpi::math {
|
||||
template <std::derived_from<TrajectoryConstraint> Constraint>
|
||||
class EllipticalRegionConstraint : public TrajectoryConstraint {
|
||||
public:
|
||||
/**
|
||||
* Constructs a new EllipticalRegionConstraint.
|
||||
*
|
||||
* @param center The center of the ellipse in which to enforce the constraint.
|
||||
* @param xWidth The width of the ellipse in which to enforce the constraint.
|
||||
* @param yWidth The height of the ellipse in which to enforce the constraint.
|
||||
* @param rotation The rotation to apply to all radii around the origin.
|
||||
* @param constraint The constraint to enforce when the robot is within the
|
||||
* region.
|
||||
* @deprecated Use constructor taking Ellipse2d instead.
|
||||
*/
|
||||
[[deprecated("Use constructor taking Ellipse2d instead.")]]
|
||||
constexpr EllipticalRegionConstraint(const Translation2d& center,
|
||||
wpi::units::meter_t xWidth,
|
||||
wpi::units::meter_t yWidth,
|
||||
const Rotation2d& rotation,
|
||||
const Constraint& constraint)
|
||||
: m_ellipse{Pose2d{center, rotation}, xWidth / 2.0, yWidth / 2.0},
|
||||
m_constraint(constraint) {}
|
||||
|
||||
/**
|
||||
* Constructs a new EllipticalRegionConstraint.
|
||||
*
|
||||
|
||||
@@ -19,23 +19,6 @@ namespace wpi::math {
|
||||
template <std::derived_from<TrajectoryConstraint> Constraint>
|
||||
class RectangularRegionConstraint : public TrajectoryConstraint {
|
||||
public:
|
||||
/**
|
||||
* Constructs a new RectangularRegionConstraint.
|
||||
*
|
||||
* @param bottomLeftPoint The bottom left point of the rectangular region in
|
||||
* which to enforce the constraint.
|
||||
* @param topRightPoint The top right point of the rectangular region in which
|
||||
* to enforce the constraint.
|
||||
* @param constraint The constraint to enforce when the robot is within the
|
||||
* region.
|
||||
* @deprecated Use constructor taking Rectangle2d instead.
|
||||
*/
|
||||
[[deprecated("Use constructor taking Rectangle2d instead.")]]
|
||||
constexpr RectangularRegionConstraint(const Translation2d& bottomLeftPoint,
|
||||
const Translation2d& topRightPoint,
|
||||
const Constraint& constraint)
|
||||
: m_rectangle{bottomLeftPoint, topRightPoint}, m_constraint(constraint) {}
|
||||
|
||||
/**
|
||||
* Constructs a new RectangularRegionConstraint.
|
||||
*
|
||||
|
||||
@@ -13,10 +13,6 @@ classes:
|
||||
wpi::units::volt_t, wpi::units::volt_t, wpi::units::unit_t<kv_unit>, wpi::units::unit_t<ka_unit>:
|
||||
Calculate:
|
||||
overloads:
|
||||
wpi::units::unit_t<Angle>, wpi::units::unit_t<Velocity>, wpi::units::unit_t<Acceleration> [const]:
|
||||
ignore: true
|
||||
wpi::units::unit_t<Angle>, wpi::units::unit_t<Velocity>, wpi::units::unit_t<Velocity>, wpi::units::second_t [const]:
|
||||
ignore: true
|
||||
wpi::units::unit_t<Angle>, wpi::units::unit_t<Velocity> [const]:
|
||||
wpi::units::unit_t<Angle>, wpi::units::unit_t<Velocity>, wpi::units::unit_t<Velocity> [const]:
|
||||
MaxAchievableVelocity:
|
||||
|
||||
@@ -10,20 +10,10 @@ classes:
|
||||
methods:
|
||||
EllipticalRegionConstraint:
|
||||
overloads:
|
||||
const Translation2d&, wpi::units::meter_t, wpi::units::meter_t, const Rotation2d&, const Constraint&:
|
||||
const Ellipse2d&, const Constraint&:
|
||||
MaxVelocity:
|
||||
MinMaxAcceleration:
|
||||
|
||||
template_inline_code: |
|
||||
cls_EllipticalRegionConstraint
|
||||
.def_static("fromFeet", [](const Translation2d& center, wpi::units::foot_t xWidth,
|
||||
wpi::units::foot_t yWidth, const Rotation2d& rotation,
|
||||
const Constraint& constraint) {
|
||||
return std::make_shared<EllipticalRegionConstraint<Constraint>>(center, xWidth, yWidth, rotation, constraint);
|
||||
}, py::arg("center"), py::arg("xWidth"), py::arg("yWidth"), py::arg("rotation"), py::arg("constraint"))
|
||||
;
|
||||
|
||||
templates:
|
||||
EllipticalRegionConstraint:
|
||||
qualname: wpi::math::EllipticalRegionConstraint
|
||||
|
||||
@@ -19,8 +19,6 @@ classes:
|
||||
GetPeriod:
|
||||
GetErrorTolerance:
|
||||
GetErrorDerivativeTolerance:
|
||||
GetPositionTolerance:
|
||||
GetVelocityTolerance:
|
||||
GetAccumulatedError:
|
||||
SetSetpoint:
|
||||
GetSetpoint:
|
||||
@@ -32,8 +30,6 @@ classes:
|
||||
SetTolerance:
|
||||
GetError:
|
||||
GetErrorDerivative:
|
||||
GetPositionError:
|
||||
GetVelocityError:
|
||||
Calculate:
|
||||
overloads:
|
||||
double:
|
||||
|
||||
@@ -10,7 +10,6 @@ classes:
|
||||
methods:
|
||||
RectangularRegionConstraint:
|
||||
overloads:
|
||||
const Translation2d&, const Translation2d&, const Constraint&:
|
||||
const Rectangle2d&, const Constraint&:
|
||||
MaxVelocity:
|
||||
MinMaxAcceleration:
|
||||
|
||||
@@ -62,25 +62,3 @@ wpi::units::radian_t XRPServo::GetAngle() const {
|
||||
|
||||
return 90_deg;
|
||||
}
|
||||
|
||||
void XRPServo::SetPosition(double pos) {
|
||||
if (pos < 0.0) {
|
||||
pos = 0.0;
|
||||
}
|
||||
|
||||
if (pos > 1.0) {
|
||||
pos = 1.0;
|
||||
}
|
||||
|
||||
if (m_simPosition) {
|
||||
m_simPosition.Set(pos);
|
||||
}
|
||||
}
|
||||
|
||||
double XRPServo::GetPosition() const {
|
||||
if (m_simPosition) {
|
||||
return m_simPosition.Get();
|
||||
}
|
||||
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
@@ -46,24 +46,6 @@ class XRPServo {
|
||||
*/
|
||||
wpi::units::radian_t GetAngle() const;
|
||||
|
||||
/**
|
||||
* Set the servo position.
|
||||
*
|
||||
* @param position Desired position (Between 0.0 and 1.0)
|
||||
* @deprecated Use SetAngle() instead
|
||||
*/
|
||||
[[deprecated("Use SetAngle() instead")]]
|
||||
void SetPosition(double position);
|
||||
|
||||
/**
|
||||
* Get the servo position.
|
||||
*
|
||||
* @return Current servo position
|
||||
* @deprecated Use GetAngle() instead
|
||||
*/
|
||||
[[deprecated("Use GetAngle() instead")]]
|
||||
double GetPosition() const;
|
||||
|
||||
private:
|
||||
hal::SimDevice m_simDevice;
|
||||
hal::SimDouble m_simPosition;
|
||||
|
||||
@@ -4,5 +4,3 @@ classes:
|
||||
XRPServo:
|
||||
SetAngle:
|
||||
GetAngle:
|
||||
SetPosition:
|
||||
GetPosition:
|
||||
|
||||
Reference in New Issue
Block a user