Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Move wpilib.command -> commands1
Browse files Browse the repository at this point in the history
- Matches commands2
- Makes 'python setup.py develop' mostly work
  • Loading branch information
virtuald committed Jan 16, 2022
1 parent 95b0d46 commit cbbe49e
Show file tree
Hide file tree
Showing 53 changed files with 187 additions and 156 deletions.
24 changes: 15 additions & 9 deletions .gitignore
Expand Up @@ -9,13 +9,19 @@
/build
/dist

/wpilib/buttons/rpy-include
/wpilib/buttons/_init_commands_v1_buttons.py
/wpilib/buttons/pkgcfg.py
/commands1/buttons/rpy-include
/commands1/buttons/_init_commands_v1_buttons.py
/commands1/buttons/pkgcfg.py

/wpilib/command/_init_commands_v1.py
/wpilib/command/include
/wpilib/command/lib
/wpilib/command/rpy-include
/wpilib/command/pkgcfg.py
/wpilib/command/version.py
/commands1/_init_commands_v1.py
/commands1/include
/commands1/lib
/commands1/rpy-include
/commands1/pkgcfg.py
/commands1/version.py

/commands1/_impl/pkgcfg.py
/commands1/_impl/include
/commands1/_impl/rpy-include
/commands1/_impl/_init_commands_v1.py
/commands1/py.typed
2 changes: 1 addition & 1 deletion commandbased/cancelcommand.py
@@ -1,4 +1,4 @@
from wpilib.command import Command
from commands1 import Command


def checkIfCanceled(self):
Expand Down
8 changes: 4 additions & 4 deletions commandbased/commandbasedrobot.py
@@ -1,5 +1,5 @@
from wpilib import TimedRobot
from wpilib.command import Scheduler
from wpilib import DriverStation, TimedRobot, reportError
from commands1 import Scheduler


class CommandBasedRobot(TimedRobot):
Expand All @@ -23,7 +23,7 @@ def commandPeriodic(self):
try:
self.scheduler.run()
except Exception as error:
if not self.ds.isFMSAttached():
if not DriverStation.isFMSAttached():
raise

"""Just to be safe, stop all running commands."""
Expand All @@ -43,4 +43,4 @@ def handleCrash(self, error):
more complex behavior, override this method in your robot class.
"""

self.ds.reportError(str(error), printTrace=True)
reportError(str(error), printTrace=True)
2 changes: 1 addition & 1 deletion commandbased/flowcontrol.py
Expand Up @@ -3,7 +3,7 @@
intuitive. For more information, check each method's docstring.
"""

from wpilib.command import Command, CommandGroup, ConditionalCommand
from commands1 import Command, CommandGroup, ConditionalCommand
from commandbased.cancelcommand import CancelCommand

import inspect
Expand Down
69 changes: 69 additions & 0 deletions commands1/__init__.py
@@ -0,0 +1,69 @@
from ._impl import _init_commands_v1

# autogenerated by 'robotpy-build create-imports commands1 commands1._impl._commands_v1.command'
from ._impl._commands_v1.command import (
Command,
CommandGroup,
CommandGroupEntry,
ConditionalCommand,
InstantCommand,
PIDAnalogAccelerometer,
PIDAnalogGyro,
PIDAnalogInput,
PIDAnalogPotentiometer,
PIDBase,
PIDCommand,
PIDController,
PIDEncoder,
PIDInterface,
PIDMotorController,
PIDOutput,
PIDSource,
PIDSubsystem,
PIDUltrasonic,
PrintCommand,
Scheduler,
StartCommand,
Subsystem,
TimedCommand,
WaitCommand,
WaitForChildren,
WaitUntilCommand,
)

__all__ = [
"Command",
"CommandGroup",
"CommandGroupEntry",
"ConditionalCommand",
"InstantCommand",
"PIDAnalogAccelerometer",
"PIDAnalogGyro",
"PIDAnalogInput",
"PIDAnalogPotentiometer",
"PIDBase",
"PIDCommand",
"PIDController",
"PIDEncoder",
"PIDInterface",
"PIDMotorController",
"PIDOutput",
"PIDSource",
"PIDSubsystem",
"PIDUltrasonic",
"PrintCommand",
"Scheduler",
"StartCommand",
"Subsystem",
"TimedCommand",
"WaitCommand",
"WaitForChildren",
"WaitUntilCommand",
]

del _init_commands_v1

try:
from .version import version as __version__
except ImportError:
__version__ = "master"
Empty file added commands1/_impl/__init__.py
Empty file.
@@ -1,7 +1,6 @@

#include "rpygen_wrapper.hpp"

RPYBUILD_PYBIND11_MODULE(m)
{
initWrapper(m);
}
}
29 changes: 29 additions & 0 deletions commands1/buttons/__init__.py
@@ -0,0 +1,29 @@
from .._impl._commands_v1.button import (
Button,
ButtonScheduler,
CancelButtonScheduler,
HeldButtonScheduler,
InternalButton,
JoystickButton,
NetworkButton,
POVButton,
PressedButtonScheduler,
ReleasedButtonScheduler,
ToggleButtonScheduler,
Trigger,
)

__all__ = [
"Button",
"ButtonScheduler",
"CancelButtonScheduler",
"HeldButtonScheduler",
"InternalButton",
"JoystickButton",
"NetworkButton",
"POVButton",
"PressedButtonScheduler",
"ReleasedButtonScheduler",
"ToggleButtonScheduler",
"Trigger",
]
8 changes: 4 additions & 4 deletions docs/.gitignore
Expand Up @@ -5,7 +5,7 @@
/_sidebar.rst.inc
/_sidebar.toml

/wpilib.buttons.rst
/wpilib.buttons
/wpilib.command.rst
/wpilib.command
/commands1.buttons.rst
/commands1.buttons
/commands1.rst
/commands1
4 changes: 2 additions & 2 deletions docs/api.rst
Expand Up @@ -22,5 +22,5 @@ using this pattern, we recommend that you consult the Java version of the
.. toctree::

commandbased
wpilib.buttons
wpilib.command
commands1
commands1.buttons
10 changes: 5 additions & 5 deletions docs/conf.py
Expand Up @@ -10,7 +10,7 @@
from os.path import abspath, dirname

# Project must be built+installed to generate docs
import wpilib.command
import commands1

# -- RTD configuration ------------------------------------------------

Expand Down Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = ".".join(wpilib.command.__version__.split(".")[:2])
version = ".".join(commands1.__version__.split(".")[:2])
# The full version, including alpha/beta/rc tags.
release = wpilib.command.__version__
release = commands1.__version__

autoclass_content = "both"

Expand Down Expand Up @@ -140,5 +140,5 @@

root = abspath(dirname(__file__))

gen_package(root, "wpilib.buttons")
gen_package(root, "wpilib.command")
gen_package(root, "commands1")
gen_package(root, "commands1.buttons")
1 change: 1 addition & 0 deletions gen/Button.yml
Expand Up @@ -8,6 +8,7 @@ extra_includes:
classes:
Button:
shared_ptr: true
subpackage: button
methods:
Button:
WhenPressed:
Expand Down
1 change: 1 addition & 0 deletions gen/ButtonScheduler.yml
Expand Up @@ -9,6 +9,7 @@ extra_includes:
classes:
ButtonScheduler:
shared_ptr: true
subpackage: button
attributes:
m_pressedLast:
m_button:
Expand Down
1 change: 1 addition & 0 deletions gen/CancelButtonScheduler.yml
Expand Up @@ -9,6 +9,7 @@ extra_includes:
classes:
CancelButtonScheduler:
shared_ptr: true
subpackage: button
methods:
CancelButtonScheduler:
keepalive:
Expand Down
1 change: 1 addition & 0 deletions gen/Command.yml
Expand Up @@ -9,6 +9,7 @@ classes:
shared_ptr: true
ignored_bases:
- wpi::SendableHelper<Command>
subpackage: command
methods:
Command:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/CommandGroup.yml
Expand Up @@ -7,6 +7,7 @@ extra_includes:
classes:
CommandGroup:
shared_ptr: true
subpackage: command
methods:
CommandGroup:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/CommandGroupEntry.yml
Expand Up @@ -8,6 +8,7 @@ extra_includes:
classes:
CommandGroupEntry:
shared_ptr: true
subpackage: command
attributes:
m_timeout:
m_command:
Expand Down
1 change: 1 addition & 0 deletions gen/ConditionalCommand.yml
Expand Up @@ -8,6 +8,7 @@ extra_includes:
classes:
ConditionalCommand:
shared_ptr: true
subpackage: command
methods:
ConditionalCommand:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/HeldButtonScheduler.yml
Expand Up @@ -9,6 +9,7 @@ extra_includes:
classes:
HeldButtonScheduler:
shared_ptr: true
subpackage: button
methods:
HeldButtonScheduler:
keepalive:
Expand Down
1 change: 1 addition & 0 deletions gen/InstantCommand.yml
Expand Up @@ -8,6 +8,7 @@ extra_includes:
classes:
InstantCommand:
shared_ptr: true
subpackage: command
methods:
InstantCommand:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/InternalButton.yml
Expand Up @@ -9,6 +9,7 @@ extra_includes:
classes:
InternalButton:
shared_ptr: true
subpackage: button
methods:
InternalButton:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/JoystickButton.yml
Expand Up @@ -9,6 +9,7 @@ extra_includes:
classes:
JoystickButton:
shared_ptr: true
subpackage: button
methods:
JoystickButton:
keepalive:
Expand Down
1 change: 1 addition & 0 deletions gen/NetworkButton.yml
Expand Up @@ -9,6 +9,7 @@ extra_includes:
classes:
NetworkButton:
shared_ptr: true
subpackage: button
methods:
NetworkButton:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/PIDAnalogAccelerometer.yml
Expand Up @@ -2,6 +2,7 @@

classes:
PIDAnalogAccelerometer:
subpackage: command
methods:
PIDGet:

Expand Down
1 change: 1 addition & 0 deletions gen/PIDAnalogGyro.yml
Expand Up @@ -2,6 +2,7 @@

classes:
PIDAnalogGyro:
subpackage: command
methods:
PIDGet:

Expand Down
1 change: 1 addition & 0 deletions gen/PIDAnalogInput.yml
Expand Up @@ -2,6 +2,7 @@

classes:
PIDAnalogInput:
subpackage: command
methods:
PIDGet:

Expand Down
1 change: 1 addition & 0 deletions gen/PIDAnalogPotentiometer.yml
Expand Up @@ -2,6 +2,7 @@

classes:
PIDAnalogPotentiometer:
subpackage: command
methods:
PIDGet:

Expand Down
1 change: 1 addition & 0 deletions gen/PIDBase.yml
Expand Up @@ -6,6 +6,7 @@ extra_includes:
classes:
PIDBase:
shared_ptr: true
subpackage: command
ignored_bases:
- wpi::SendableHelper<PIDBase>
attributes:
Expand Down
1 change: 1 addition & 0 deletions gen/PIDCommand.yml
Expand Up @@ -9,6 +9,7 @@ extra_includes:
classes:
PIDCommand:
shared_ptr: true
subpackage: command
methods:
PIDCommand:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/PIDController.yml
Expand Up @@ -4,6 +4,7 @@ classes:
PIDController:
ignored_bases:
- Controller
subpackage: command
methods:
PIDController:
overloads:
Expand Down
1 change: 1 addition & 0 deletions gen/PIDEncoder.yml
Expand Up @@ -2,6 +2,7 @@

classes:
PIDEncoder:
subpackage: command
methods:
PIDGet:

Expand Down
1 change: 1 addition & 0 deletions gen/PIDInterface.yml
Expand Up @@ -2,6 +2,7 @@

classes:
PIDInterface:
subpackage: command
methods:
PIDInterface:
SetPID:
Expand Down

0 comments on commit cbbe49e

Please sign in to comment.