Skip to content

MagicbotSimple: Add magicbot.feedback usage #123

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

Merged
merged 1 commit into from
Jan 4, 2025
Merged
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
8 changes: 7 additions & 1 deletion MagicbotSimple/components/component2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import wpilib
from .component1 import Component1

from magicbot import will_reset_to
from magicbot import feedback, will_reset_to


class Component2:
Expand All @@ -29,6 +29,12 @@ def on_enable(self):
def do_something(self):
self.did_something = True

# Use @feedback to send state external to the robot code to NetworkTables.
# This will be called after execute().
@feedback
def get_motor_voltage(self) -> float:
return self.some_motor.getVoltage()

def execute(self):
if self.did_something:
self.some_motor.set(1)
Expand Down
Loading