Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update commands.rst #2939

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions source/docs/software/commandbased/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,20 @@ The ``startEnd`` factory, backed by the ``StartEndCommand`` ([Java](https://gith
// Requires the drive subsystem
{&m_drive}
)
.. code-block:: python
commands2.cmd.functional_command(
# Reset encoders on command start
lambda: robot_drive.reset_encoders(),
# Start driving forward at the start of the command
lambda: robot_drive.arcade_drive(ac.kAutoDriveSpeed, 0),
# Stop driving at the end of the command
lambda interrupted: robot_drive.arcade_drive(0, 0),
# End the command when the robot's driven distance exceeds the desired value
lambda: robot_drive.get_average_encoder_distance() >= ac.kAutoDriveDistanceInches,
# Require the drive subsystem
robot_drive)

```python
commands2.cmd.functional_command(
# Reset encoders on command start
lambda: robot_drive.reset_encoders(),
# Start driving forward at the start of the command
lambda: robot_drive.arcade_drive(ac.kAutoDriveSpeed, 0),
# Stop driving at the end of the command
lambda interrupted: robot_drive.arcade_drive(0, 0),
# End the command when the robot's driven distance exceeds the desired value
lambda: robot_drive.get_average_encoder_distance() >= ac.kAutoDriveDistanceInches,
# Require the drive subsystem
robot_drive
)
```

To print a string and ending immediately, the library offers the ``Commands.print(String)``/``frc2::cmd::Print(std::string_view)``/``commands2.cmd.print(String)`` factory, backed by the ``PrintCommand`` ([Java](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj2/command/PrintCommand.html), [C++](https://github.wpilib.org/allwpilib/docs/release/cpp/classfrc2_1_1_print_command.html), :external:py:class:`Python <commands2.PrintCommand>`) subclass of ``InstantCommand``.
Expand Down
Loading