mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
calibrate connected to config
This commit is contained in:
parent
3ce3c24dd1
commit
6440ec1000
@ -1,6 +1,5 @@
|
||||
import math
|
||||
import traceback
|
||||
from enum import Enum
|
||||
from threading import Thread
|
||||
|
||||
import cv2
|
||||
@ -8,6 +7,7 @@ import logging
|
||||
import time
|
||||
|
||||
from fishy.constants import libgps, fishyqr, lam2
|
||||
from fishy.engine.fullautofisher.mode.calibrator import Calibrator
|
||||
from fishy.engine.fullautofisher.mode.imode import FullAutoMode
|
||||
from fishy.engine.fullautofisher.mode.player import Player
|
||||
from fishy.engine.fullautofisher.mode.recorder import Recorder
|
||||
@ -42,7 +42,7 @@ class FullAuto(IEngine):
|
||||
rotate_by = 30
|
||||
|
||||
def __init__(self, gui_ref):
|
||||
from fishy.engine.fullautofisher.calibrator import Calibrator
|
||||
from fishy.engine.fullautofisher.mode.calibrator import Calibrator
|
||||
from fishy.engine.fullautofisher.test import Test
|
||||
|
||||
super().__init__(gui_ref)
|
||||
@ -65,9 +65,15 @@ class FullAuto(IEngine):
|
||||
|
||||
self.gui.bot_started(True)
|
||||
self.window = WindowClient(color=cv2.COLOR_RGB2GRAY, show_name="Full auto debug")
|
||||
self.mode = Player(self) if FullAutoMode(config.get("full_auto_mode", 0)) == FullAutoMode.Player else Recorder(self)
|
||||
|
||||
# todo use config to run player or recorder
|
||||
self.mode = None
|
||||
if config.get("calibrate", False):
|
||||
self.mode = Calibrator(self)
|
||||
elif FullAutoMode(config.get("full_auto_mode", 0)) == FullAutoMode.Player:
|
||||
self.mode = Player(self)
|
||||
elif FullAutoMode(config.get("full_auto_mode", 0)) == FullAutoMode.Recorder:
|
||||
self.mode = Recorder(self)
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
if self.window.get_capture() is None:
|
||||
|
@ -4,10 +4,13 @@ import time
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
import typing
|
||||
|
||||
from fishy.engine.fullautofisher.engine import FullAuto
|
||||
if typing.TYPE_CHECKING:
|
||||
from fishy.engine.fullautofisher.engine import FullAuto
|
||||
from pynput import keyboard, mouse
|
||||
|
||||
from fishy.engine.fullautofisher.mode.imode import IMode
|
||||
from fishy.helper.config import config
|
||||
|
||||
mse = mouse.Controller()
|
||||
@ -44,8 +47,8 @@ def _get_factor(key):
|
||||
return config.get("full_auto_factors", {}).get(key)
|
||||
|
||||
|
||||
class Calibrator:
|
||||
def __init__(self, engine: FullAuto):
|
||||
class Calibrator(IMode):
|
||||
def __init__(self, engine: 'FullAuto'):
|
||||
self._callibrate_state = -1
|
||||
self.engine = engine
|
||||
|
||||
@ -86,9 +89,11 @@ class Calibrator:
|
||||
|
||||
move_factor = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) / walking_time
|
||||
_update_factor("move_factor", move_factor)
|
||||
logging.info("done")
|
||||
logging.info("walk calibrate done")
|
||||
|
||||
def _rotate_calibrate(self):
|
||||
from fishy.engine.fullautofisher.engine import FullAuto
|
||||
|
||||
rotate_times = 50
|
||||
|
||||
coods = self.engine.get_coods()
|
||||
@ -110,9 +115,11 @@ class Calibrator:
|
||||
|
||||
rot_factor = (rot3 - rot2) / rotate_times
|
||||
_update_factor("rot_factor", rot_factor)
|
||||
logging.info("done")
|
||||
logging.info("rotate calibrate done")
|
||||
|
||||
def calibrate(self):
|
||||
def run(self):
|
||||
self._walk_calibrate()
|
||||
self._rotate_calibrate()
|
||||
config.set("calibrate", False)
|
||||
logging.info("calibration done")
|
||||
|
@ -41,7 +41,9 @@ def start_fullfisher_config(gui: 'GUI'):
|
||||
file_name_label.set(file_name())
|
||||
|
||||
def start_calibrate():
|
||||
...
|
||||
top.quit_top()
|
||||
config.set("calibrate", True)
|
||||
gui.engine.toggle_fullfisher()
|
||||
|
||||
def mode_command():
|
||||
config.set("full_auto_mode", mode_var.get())
|
||||
|
Loading…
Reference in New Issue
Block a user