You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

control_node.py 817 B

10 months ago
10 months ago
10 months ago
10 months ago
1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python
  2. """TODO: Add docstring."""
  3. import random
  4. import pyarrow as pa
  5. from dora import Node
  6. node = Node()
  7. for i in range(500):
  8. event = node.next()
  9. if event is None:
  10. break
  11. if event["type"] == "INPUT":
  12. event_id = event["id"]
  13. if event_id == "turtle_pose":
  14. print(
  15. f"""Pose: {event["value"].tolist()}""".replace("\r", "").replace(
  16. "\n", " ",
  17. ),
  18. )
  19. elif event_id == "tick":
  20. direction = {
  21. "linear": {
  22. "x": 1.0 + random.random(),
  23. },
  24. "angular": {"z": (random.random() - 0.5) * 5},
  25. }
  26. node.send_output(
  27. "direction",
  28. pa.array([direction]),
  29. )