Skip to content

Conversation

@lizlooney
Copy link
Collaborator

Change placeholder python code (OpMode, etc) to match Peter's API.

Fixes #347

Added upgrade code to rename 'update' to 'opmode_periodic' in mechanism modules.
Removed staticFunctionName and mrcStaticFunctionName.
Changed code that generates the type decorator to use the full decorator name (including the module blocks_base_class) so the Teleop decorator doesn't collide with the Teleop class.
Generate code that was in robot_base.py, but is not in wpilib.OpModeRobot.
Generate code that was in opmode.py, but is not in wpilib.PeriodicOpMode.
@lizlooney lizlooney requested a review from alan412 December 10, 2025 06:42
@lizlooney lizlooney marked this pull request as draft December 10, 2025 07:03
@lizlooney
Copy link
Collaborator Author

I found a problem when I ran through the testing checklist, so I changed this to a draft pr.

Feel free to start reviewing the code.

@lizlooney lizlooney marked this pull request as ready for review December 10, 2025 18:02
@lizlooney
Copy link
Collaborator Author

The problem I noticed was not caused by this PR. I filed issue #354 and create a separate pr #355 to fix it.

Copy link
Collaborator

@alan412 alan412 left a comment

Choose a reason for hiding this comment

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

One question I have, but if it was intentional I am fine with it merging. It just seems unrelated to everything else being changed

const body = mechanisms + components;
if (body) {
code += body;
generator.addClassMethodDefinition('define_hardware', code);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this changed to always create define_hardware even if there is no hardware?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was intentional. Previously, we had blocks_base_classes.RobotBase that declared the define_hardware method and called it from its init method. I figured it was easier to always generate the define_hardware method declaration and always generate the call to it from the init method, than it was to conditionally generate the define_hardware method declaration (if body isn't empty) and then conditionally generate the call to it from the init method.

@lizlooney lizlooney merged commit 65dbc95 into wpilibsuite:main Dec 11, 2025
1 check passed
@lizlooney lizlooney deleted the pr_issue_347 branch December 11, 2025 02:34
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.

Change placeholder python code (OpMode, etc) to match Peter's API

2 participants