Skip to content

Commit

Permalink
DOCS-2950: Make fixups from QA to gantry, input controller (#773)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguequierre authored Oct 31, 2024
1 parent b204349 commit 3cde16a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/viam/components/gantry/gantry.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ async def is_moving(self) -> bool:
await my_gantry.stop()
# Print if the gantry is currently moving.
print(my_gantry.is_moving())
print(await my_gantry.is_moving())
Returns:
bool: Whether the gantry is moving.
Expand Down
16 changes: 11 additions & 5 deletions src/viam/components/input/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async def get_controls(self, *, extra: Optional[Dict[str, Any]] = None, timeout:
# Get the controller from the machine.
my_controller = Controller.from_robot(
robot=myRobotWithController, name="my_controller")
myRobotWithController, "my_controller")
# Get the list of Controls provided by the controller.
controls = await my_controller.get_controls()
Expand All @@ -183,7 +183,7 @@ async def get_events(
# Get the controller from the machine.
my_controller = Controller.from_robot(
robot=myRobotWithController, name="my_controller")
myRobotWithController, "my_controller")
# Get the most recent Event for each Control.
recent_events = await my_controller.get_events()
Expand Down Expand Up @@ -214,6 +214,8 @@ def register_control_callback(
::
from viam.components.input import Control, EventType
# Define a function to handle pressing the Start Menu Button "BUTTON_START" on
# your controller, printing out the start time.
def print_start_time(event):
Expand Down Expand Up @@ -245,10 +247,10 @@ async def main():
# Get your controller from the machine.
my_controller = Controller.from_robot(
robot=myRobotWithController, name="my_controller")
myRobotWithController, "my_controller")
# Run the handleController function.
await handleController(my_controller)
await handle_controller(my_controller)
# ... < INSERT ANY OTHER CODE FOR MAIN FUNCTION >
Expand All @@ -275,13 +277,17 @@ async def trigger_event(
::
# Get your controller from the machine.
my_controller = Controller.from_robot(
myRobotWithController, "my_controller")
# Define a "Button is Pressed" event for the control BUTTON_START.
button_is_pressed_event = Event(
time(), EventType.BUTTON_PRESS, Control.BUTTON_START, 1.0)
# Trigger the event on your controller. Set this trigger to timeout if it has
# not completed in 7 seconds.
await myController.trigger_event(event=my_event, timeout=7.0)
await my_controller.trigger_event(event=button_is_pressed_event, timeout=7.0)
Args:
event (Event): The event to trigger
Expand Down

0 comments on commit 3cde16a

Please sign in to comment.