Files
allwpilib/commandsv2/src/main/python/commands2/schedulecommand.py
PJ Reiniger 1a99a348cb [robotpy] Mirror robotpy's commands-v2 (#8369)
Project import generated by Copybara.

GitOrigin-RevId: 715c8e8372d936f447f2937aab6b1a22dc619126
2025-11-13 21:55:54 -08:00

32 lines
952 B
Python

# validated: 2024-01-19 DS aaea85ff1656 ScheduleCommand.java
from __future__ import annotations
from .command import Command
class ScheduleCommand(Command):
"""
Schedules the given commands when this command is initialized. Useful for forking off from
CommandGroups. Note that if run from a composition, the composition will not know about the
status of the scheduled commands, and will treat this command as finishing instantly.
"""
def __init__(self, *commands: Command):
"""
Creates a new ScheduleCommand that schedules the given commands when initialized.
:param toSchedule: the commands to schedule
"""
super().__init__()
self._toSchedule = set(commands)
def initialize(self):
for command in self._toSchedule:
command.schedule()
def isFinished(self) -> bool:
return True
def runsWhenDisabled(self) -> bool:
return True