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.

policy.py 1.2 kB

123456789101112131415161718192021222324252627282930313233343536373839
  1. """Module for implementing robot control policies.
  2. This module provides functionality for implementing and managing robot control policies,
  3. including action selection and state management.
  4. """
  5. from dora import DoraStatus
  6. class Operator:
  7. """A class for implementing robot control policies.
  8. This class handles the selection and execution of robot actions based on
  9. input events and current state.
  10. """
  11. def __init__(self):
  12. """Initialize the operator with available actions."""
  13. self.actions = ["get_food", "get_hat"]
  14. def on_event(self, event: dict, send_output) -> DoraStatus:
  15. """Handle incoming events and generate appropriate actions.
  16. Args:
  17. event: Dictionary containing event information
  18. send_output: Function to send output to the dataflow
  19. Returns:
  20. DoraStatus: Status indicating whether to continue processing
  21. """
  22. if event["type"] == "INPUT":
  23. id = event["id"]
  24. # On initialization
  25. if id == "speech":
  26. text: str = event["value"][0].as_py().lower()
  27. # send_output("action", pa.array([""]))
  28. return DoraStatus.CONTINUE