From 7ee0a7bad9adb1b685032100c9625feafc09604d Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Sun, 3 Mar 2024 07:55:08 -0500 Subject: [PATCH] Update axis_ptz_controller.py --- axis-ptz-controller/axis_ptz_controller.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/axis-ptz-controller/axis_ptz_controller.py b/axis-ptz-controller/axis_ptz_controller.py index 7a4af84..74e9a0f 100644 --- a/axis-ptz-controller/axis_ptz_controller.py +++ b/axis-ptz-controller/axis_ptz_controller.py @@ -991,14 +991,15 @@ def _manual_control_callback(self, _client: Union[mqtt.Client, None], except Exception as e: logging.error(f"Error: {e}") logging.info(f"rho_c: {self.rho_c}, rho_o: {pan}, tau_c: {self.tau_c}, tau_o: {tilt}, pan_rate_max: {self.pan_rate_max}, tilt_rate_max: {self.tilt_rate_max}") - duration = max( - math.fabs(self._compute_angle_delta(self.rho_c, pan)) - / (self.pan_rate_max / 2), - math.fabs(self._compute_angle_delta(self.tau_c, tilt)) - / (self.tilt_rate_max / 2), - ) - logging.info(f"Sleeping: {duration} [s]") - sleep(duration) + if tilt > 0 and pan > 0: + duration = max( + math.fabs(self._compute_angle_delta(self.rho_c, pan)) + / (self.pan_rate_max / 2), + math.fabs(self._compute_angle_delta(self.tau_c, tilt)) + / (self.tilt_rate_max / 2), + ) + logging.info(f"Sleeping: {duration} [s]") + sleep(duration) def _send_data(self, data: Dict[str, str]) -> bool: """Leverages edgetech-core functionality to publish a JSON