Skip to content

add opmoderobot framework - #3328

Open
zachwaffle4 wants to merge 6 commits into
wpilibsuite:mainfrom
zachwaffle4:add-opmode
Open

add opmoderobot framework#3328
zachwaffle4 wants to merge 6 commits into
wpilibsuite:mainfrom
zachwaffle4:add-opmode

Conversation

@zachwaffle4

Copy link
Copy Markdown

I didn't include any Python examples because I don't even know if we have Python examples with OpModeRobot rn

@ThadHouse

Copy link
Copy Markdown
Member

Update the DS used for screenshots.

@sciencewhiz
sciencewhiz changed the base branch from 2027 to main July 23, 2026 03:21
@sciencewhiz

Copy link
Copy Markdown
Collaborator

PRs for 2027 should be targeted to main now. I retargetted the PR

@sciencewhiz sciencewhiz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to have a short section describing why opmodes (ie similar to the motivation section from the design document). It would also be helpful to have a section on differences from the FTC implementation, to help teams migrating.


.. note:: Selecting a different opmode while the robot is enabled automatically disables the robot first, so ``end()`` is always called before the switch.

**If a different opmode is selected while the robot is already disabled**, ``close()`` is called (or the object is destroyed) with no ``end()`` call, since the opmode was never enabled.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is worded a little weird. Does the behavior change if the opmode was or wasn't enabled?


- Replace per-mode methods in ``Robot`` (``autonomousInit``, ``teleopPeriodic``, etc.) with separate ``@Autonomous`` and ``@Teleop`` opmode classes.
- Replace ``SendableChooser`` with multiple ``@Autonomous`` classes.
- Replace ``utilityInit``/``utilityPeriodic`` with ``@Utility`` opmode classes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to combine Utility into the Autonomous/Teleop bullet above?

.. tab-set-code::

.. rli:: https://raw.githubusercontent.com/wpilibsuite/allwpilib/v2027.0.0-alpha-6/wpilibjExamples/src/main/java/org/wpilib/templates/opmode/Robot.java
:language: java

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the :lines: and :lineno-match: directive to avoid boilerplate (like the copyright notice). See below for examples

@zachwaffle4

Copy link
Copy Markdown
Author

It would also be helpful to have a section on differences from the FTC implementation, to help teams migrating.

I agree; Amanda's PR adds a special FTC section to the sidebar, so I was going to add some migration info there once that lands instead of putting program-specific transition info on a page for both programs.

@j5155 j5155 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for writing this. I think this is overall a pretty great explanation already from the perspective of an experienced FRC and Java programmer, but I have some nitpicky feedback to make it understandable for new programmers.

The biggest thing is that I'd love to see more explanations of the use cases for the functions so it's clear what they're actually for. Also, I would recommend avoiding semicolons and em dashes entirely, since they make the text look AI generated.

Comment thread source/docs/software/basic-programming/opmodes.rst Outdated
Comment thread source/docs/software/basic-programming/opmodes.rst
Comment thread source/docs/software/basic-programming/opmodes.rst Outdated
Comment thread source/docs/software/basic-programming/opmodes.rst Outdated
Comment thread source/docs/software/basic-programming/opmodes.rst Outdated
Comment thread source/docs/software/basic-programming/opmodes.rst Outdated
Comment thread source/docs/software/basic-programming/opmodes.rst Outdated
Comment thread source/docs/software/basic-programming/opmodes.rst Outdated
Comment thread source/docs/software/vscode-overview/creating-robot-program.rst Outdated
Comment thread source/docs/software/vscode-overview/creating-robot-program.rst
@sciencewhiz

Copy link
Copy Markdown
Collaborator

I didn't include any Python examples because I don't even know if we have Python examples with OpModeRobot rn

There's a Python OpMode example PR, but it isn't a template like what's used for Java/C++ on this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants