Skip to content

Commit 3cde16a

Browse files
authored
DOCS-2950: Make fixups from QA to gantry, input controller (#773)
1 parent b204349 commit 3cde16a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/viam/components/gantry/gantry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async def is_moving(self) -> bool:
146146
await my_gantry.stop()
147147
148148
# Print if the gantry is currently moving.
149-
print(my_gantry.is_moving())
149+
print(await my_gantry.is_moving())
150150
151151
Returns:
152152
bool: Whether the gantry is moving.

src/viam/components/input/input.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async def get_controls(self, *, extra: Optional[Dict[str, Any]] = None, timeout:
156156
157157
# Get the controller from the machine.
158158
my_controller = Controller.from_robot(
159-
robot=myRobotWithController, name="my_controller")
159+
myRobotWithController, "my_controller")
160160
161161
# Get the list of Controls provided by the controller.
162162
controls = await my_controller.get_controls()
@@ -183,7 +183,7 @@ async def get_events(
183183
184184
# Get the controller from the machine.
185185
my_controller = Controller.from_robot(
186-
robot=myRobotWithController, name="my_controller")
186+
myRobotWithController, "my_controller")
187187
188188
# Get the most recent Event for each Control.
189189
recent_events = await my_controller.get_events()
@@ -214,6 +214,8 @@ def register_control_callback(
214214
215215
::
216216
217+
from viam.components.input import Control, EventType
218+
217219
# Define a function to handle pressing the Start Menu Button "BUTTON_START" on
218220
# your controller, printing out the start time.
219221
def print_start_time(event):
@@ -245,10 +247,10 @@ async def main():
245247
246248
# Get your controller from the machine.
247249
my_controller = Controller.from_robot(
248-
robot=myRobotWithController, name="my_controller")
250+
myRobotWithController, "my_controller")
249251
250252
# Run the handleController function.
251-
await handleController(my_controller)
253+
await handle_controller(my_controller)
252254
253255
# ... < INSERT ANY OTHER CODE FOR MAIN FUNCTION >
254256
@@ -275,13 +277,17 @@ async def trigger_event(
275277
276278
::
277279
280+
# Get your controller from the machine.
281+
my_controller = Controller.from_robot(
282+
myRobotWithController, "my_controller")
283+
278284
# Define a "Button is Pressed" event for the control BUTTON_START.
279285
button_is_pressed_event = Event(
280286
time(), EventType.BUTTON_PRESS, Control.BUTTON_START, 1.0)
281287
282288
# Trigger the event on your controller. Set this trigger to timeout if it has
283289
# not completed in 7 seconds.
284-
await myController.trigger_event(event=my_event, timeout=7.0)
290+
await my_controller.trigger_event(event=button_is_pressed_event, timeout=7.0)
285291
286292
Args:
287293
event (Event): The event to trigger

0 commit comments

Comments
 (0)