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 789 B

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