diff --git a/go_to_starting_line.py b/go_to_starting_line.py index 784be13..c977736 100644 --- a/go_to_starting_line.py +++ b/go_to_starting_line.py @@ -9,9 +9,9 @@ """ import time -from okon_client import OkonClient +from okon_sim_client import OkonSimClient -oc = OkonClient(ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False) +oc = OkonSimClient(ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False) okon = oc.okon sim = oc.simulation diff --git a/okon.py b/okon.py new file mode 100644 index 0000000..92873b8 --- /dev/null +++ b/okon.py @@ -0,0 +1,44 @@ +""" Implementation of an Abstract Base Class (ABC) Okon + +Okon ABC implementation provides unified communication between +the autonomy module and simulation/TCM. +""" +from abc import ABC, abstractmethod + + +class Okon(ABC): + @abstractmethod + def set_depth(self, depth: float, add: bool = False) -> None: + pass + + @abstractmethod + def set_stable_vel(self, x: float = None, y: float = None, z: float = None) -> None: + pass + + @abstractmethod + def arm_motors(self) -> None: + pass + + @abstractmethod + def disarm_motors(self) -> None: + pass + + @abstractmethod + def setMode(self, mode: str) -> None: + pass + + @abstractmethod + def reachedTargetRotation(self, delta): + pass + + @abstractmethod + def reachedTargetDepth(self, delta): + pass + + @abstractmethod + def get_detection(self, className: str): + pass + + @abstractmethod + def set_stable_rot(self, x: float = None, y: float = None, z: float = None, add=False) -> None: + pass diff --git a/okon_actions.py b/okon_actions.py index 5e54dda..8611080 100644 --- a/okon_actions.py +++ b/okon_actions.py @@ -5,7 +5,7 @@ import py_trees -from okon_client import Okon +from okon_sim_client import Okon class Status: diff --git a/okon_actions_example.py b/okon_actions_example.py index ece5620..f79a7bc 100644 --- a/okon_actions_example.py +++ b/okon_actions_example.py @@ -10,9 +10,9 @@ import py_trees from okon_actions import Rotate, SetDepth -from okon_client import OkonClient +from okon_sim_client import OkonSimClient -oc = OkonClient(ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False) +oc = OkonSimClient(ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False) oc.connect() time.sleep(1.0) diff --git a/okon_client.py b/okon_sim_client.py similarity index 99% rename from okon_client.py rename to okon_sim_client.py index 3aec8a0..037447a 100644 --- a/okon_client.py +++ b/okon_sim_client.py @@ -4,7 +4,7 @@ from queue import Queue from threading import Thread -from numpy import number +from okon import Okon class PacketType: # PacketType.PING @@ -61,7 +61,7 @@ def get(val: int) -> str: # PacketFlag.get(1|2) return flags -class Okon: +class OkonSim(Okon): def __init__(self, okon_client) -> None: self._okon_client = okon_client self.sens = { @@ -218,9 +218,9 @@ def angle_norm(a: dict) -> dict: return {"x": x, "y": y, "z": z} -class OkonClient: +class OkonSimClient: def __init__(self, ip, port, options=None, sync_interval=0.05, debug=True) -> None: - self.okon = Okon(self) + self.okon = OkonSim(self) self.simulation = Simulation(self) self.ip = ip diff --git a/okon_client_example.py b/okon_sim_client_example.py similarity index 95% rename from okon_client_example.py rename to okon_sim_client_example.py index c29da19..226f4a7 100644 --- a/okon_client_example.py +++ b/okon_sim_client_example.py @@ -1,6 +1,6 @@ import time -from okon_client import OkonClient, PacketFlag, PacketType +from okon_sim_client import OkonSimClient, PacketFlag, PacketType def handle_simulation_reset(args=None) -> None: @@ -14,7 +14,7 @@ def handle_ping(args=None) -> None: n += 1 -oc = OkonClient( +oc = OkonSimClient( ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False ) # ping simRST hitNGZ hitFZ packet error disconnect # run on separate thread oc.on_event("simRST", handle_simulation_reset) diff --git a/qualification_task_behavior_tree.py b/qualification_task_behavior_tree.py index fdf77d5..175225d 100644 --- a/qualification_task_behavior_tree.py +++ b/qualification_task_behavior_tree.py @@ -13,9 +13,9 @@ TryDetectNTimes, Wait, ) -from okon_client import OkonClient +from okon_sim_client import OkonSimClient -oc = OkonClient(ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False) +oc = OkonSimClient(ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False) oc.connect() time.sleep(1.0)