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.

op.py 942 B

123456789101112131415161718192021222324252627282930
  1. from typing import Callable
  2. class Operator:
  3. """
  4. Example operator incrementing a counter every times its been called.
  5. The current value of the counter is sent back to dora on `counter`.
  6. """
  7. def __init__(self, counter=0):
  8. self.counter = counter
  9. def on_input(
  10. self,
  11. input_id: str,
  12. value: bytes,
  13. send_output: Callable[[str, bytes], None],
  14. ):
  15. """Handle input by incrementing count by one.
  16. Args:
  17. input_id (str): Id of the input declared in the yaml configuration
  18. value (bytes): Bytes message of the input
  19. send_output (Callable[[str, bytes]]): Function enabling sending output back to dora.
  20. """
  21. val_len = len(value)
  22. print(f"PYTHON received input {input_id}; value length: {val_len}")
  23. send_output("counter", self.counter.to_bytes(1, "little"))
  24. self.counter = (self.counter + 1) % 256

DORA (Dataflow-Oriented Robotic Architecture) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed datafl