RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
org.wpilib.command3.Mechanism Interface Reference

Public Member Functions

default Scheduler getRegisteredScheduler ()
default boolean controllableDuringDisabled ()
default String getName ()
default void setDefaultCommand (Command defaultCommand)
default Command getDefaultCommand ()
default NeedsNameBuilderStage run (Consumer< Coroutine > commandBody)
default NeedsNameBuilderStage runRepeatedly (Runnable loopBody)
default Command idle ()
default Command idleFor (Time duration)
default List< Command > getRunningCommands ()

Detailed Description

Generic interface to represent mechanisms on a robot. Commands can require sole ownership of a mechanism; when a command that requires a mechanism is running, no other commands may use it at the same time.

Even though this interface is named "Mechanism", it may be used to represent other physical hardware on a robot that should be controlled with commands - for example, an LED strip or a vision processor that can switch between different pipelines could be represented as mechanisms.

Definition at line 21 of file Mechanism.java.

Member Function Documentation

◆ controllableDuringDisabled()

default boolean org.wpilib.command3.Mechanism.controllableDuringDisabled ( )

Marks this mechanism as being controllable when the robot is in a disabled mode. If a mechanism is not controllable, commands that require it cannot be scheduled when the robot is disabled and will be canceled when the robot enters a disabled mode.

By default, mechanisms are not controllable during disabled. Override this method to return true if the mechanism should be controllable during disabled modes.

Returns
Whether this mechanism is controllable during disabled modes.

Definition at line 42 of file Mechanism.java.

◆ getDefaultCommand()

default Command org.wpilib.command3.Mechanism.getDefaultCommand ( )

Gets the default command that was set by the latest call to setDefaultCommand(Command).

Returns
The currently configured default command

Definition at line 78 of file Mechanism.java.

◆ getName()

default String org.wpilib.command3.Mechanism.getName ( )

Gets the name of this mechanism. This will default to the name of this mechanism's class.

Returns
The name of the mechanism.

Definition at line 52 of file Mechanism.java.

◆ getRegisteredScheduler()

default Scheduler org.wpilib.command3.Mechanism.getRegisteredScheduler ( )

Returns the scheduler under which this subsystem and its default commands are registered. The scheduler is also used to fetch running commands for the subsystem.

Returns
The registered scheduler.

Definition at line 28 of file Mechanism.java.

◆ getRunningCommands()

default List< Command > org.wpilib.command3.Mechanism.getRunningCommands ( )

Gets all running commands that require this mechanism. Commands are returned in the order in which they were scheduled. The returned list is read-only. Every command in the list will have been scheduled by the previous entry in the list or by intermediate commands that do not require the mechanism.

Returns
The currently running commands that require the mechanism.

Definition at line 143 of file Mechanism.java.

◆ idle()

default Command org.wpilib.command3.Mechanism.idle ( )

Returns a command that idles this mechanism until another command claims it. The idle command has the lowest priority and can be interrupted by any other command.

The default command for every mechanism is an idle command unless a different default command has been configured.

Returns
A new idle command.

Definition at line 120 of file Mechanism.java.

◆ idleFor()

default Command org.wpilib.command3.Mechanism.idleFor ( Time duration)

Returns a command that idles this mechanism for the given duration of time.

Parameters
durationHow long the mechanism should idle for.
Returns
A new idle command.

Definition at line 130 of file Mechanism.java.

◆ run()

default NeedsNameBuilderStage org.wpilib.command3.Mechanism.run ( Consumer< Coroutine > commandBody)

Starts building a command that requires this mechanism.

Parameters
commandBodyThe main function body of the command.
Returns
The command builder, for further configuration.

Definition at line 88 of file Mechanism.java.

◆ runRepeatedly()

default NeedsNameBuilderStage org.wpilib.command3.Mechanism.runRepeatedly ( Runnable loopBody)

Starts building a command that requires this mechanism. The given function will be called repeatedly in an infinite loop. Useful for building commands that don't need state or multiple stages of logic.

Parameters
loopBodyThe body of the infinite loop.
Returns
The command builder, for further configuration.

Definition at line 100 of file Mechanism.java.

◆ setDefaultCommand()

default void org.wpilib.command3.Mechanism.setDefaultCommand ( Command defaultCommand)

Sets the default command to run on the mechanism when no other command is scheduled. The default command's priority is effectively the minimum allowable priority for any command requiring a mechanism. For this reason, it's recommended that a default command have a priority less than Command#DEFAULT_PRIORITY so it doesn't prevent low-priority commands from running.

The default command is initially an idle command that only owns the mechanism without doing anything. This command has the lowest possible priority to allow any other command to run.

Parameters
defaultCommandthe new default command

Definition at line 68 of file Mechanism.java.


The documentation for this interface was generated from the following file: