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 1.0 kB

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

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