@@ -156,7 +156,7 @@ async def get_controls(self, *, extra: Optional[Dict[str, Any]] = None, timeout:
156
156
157
157
# Get the controller from the machine.
158
158
my_controller = Controller.from_robot(
159
- robot= myRobotWithController, name= "my_controller")
159
+ myRobotWithController, "my_controller")
160
160
161
161
# Get the list of Controls provided by the controller.
162
162
controls = await my_controller.get_controls()
@@ -183,7 +183,7 @@ async def get_events(
183
183
184
184
# Get the controller from the machine.
185
185
my_controller = Controller.from_robot(
186
- robot= myRobotWithController, name= "my_controller")
186
+ myRobotWithController, "my_controller")
187
187
188
188
# Get the most recent Event for each Control.
189
189
recent_events = await my_controller.get_events()
@@ -214,6 +214,8 @@ def register_control_callback(
214
214
215
215
::
216
216
217
+ from viam.components.input import Control, EventType
218
+
217
219
# Define a function to handle pressing the Start Menu Button "BUTTON_START" on
218
220
# your controller, printing out the start time.
219
221
def print_start_time(event):
@@ -245,10 +247,10 @@ async def main():
245
247
246
248
# Get your controller from the machine.
247
249
my_controller = Controller.from_robot(
248
- robot= myRobotWithController, name= "my_controller")
250
+ myRobotWithController, "my_controller")
249
251
250
252
# Run the handleController function.
251
- await handleController (my_controller)
253
+ await handle_controller (my_controller)
252
254
253
255
# ... < INSERT ANY OTHER CODE FOR MAIN FUNCTION >
254
256
@@ -275,13 +277,17 @@ async def trigger_event(
275
277
276
278
::
277
279
280
+ # Get your controller from the machine.
281
+ my_controller = Controller.from_robot(
282
+ myRobotWithController, "my_controller")
283
+
278
284
# Define a "Button is Pressed" event for the control BUTTON_START.
279
285
button_is_pressed_event = Event(
280
286
time(), EventType.BUTTON_PRESS, Control.BUTTON_START, 1.0)
281
287
282
288
# Trigger the event on your controller. Set this trigger to timeout if it has
283
289
# 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)
285
291
286
292
Args:
287
293
event (Event): The event to trigger
0 commit comments