Skip to content

Commit

Permalink
Update axis_ptz_controller.py
Browse files Browse the repository at this point in the history
  • Loading branch information
robotastic committed Mar 3, 2024
1 parent 7ee0a7b commit 90daadf
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions axis-ptz-controller/axis_ptz_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,32 +970,32 @@ def _manual_control_callback(self, _client: Union[mqtt.Client, None],
None
"""
data = self.decode_payload(msg, "Manual Control")
if not set( ["pan", "tilt", "zoom"] ) <= set(data.keys()):
if not set( ["azimuth", "elevation", "zoom"] ) <= set(data.keys()):
logging.info(f"Required keys missing from manual control message data: {data}")
return

pan = data["pan"]
tilt = data["tilt"]
azimuth = data["azimuth"]
elevation = data["elevation"]
self.zoom = data["zoom"]
logging.info(f"Setting zoom to: {self.zoom}")
# Get camera pan and tilt
# Get camera azimuth and elevation
self.rho_c, self.tau_c, _zoom, _focus = self.camera_control.get_ptz()
logging.info(f"Camera pan and tilt: {self.rho_c}, {self.tau_c} [deg]")
logging.info(
f"Absolute move to pan: {self.rho_o}, and tilt: {self.tau_o}, with zoom: {self.zoom}"
)
try:
self.camera_control.absolute_move(
pan, tilt, self.zoom, 50
azimuth, elevation, self.zoom, 50
)
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}")
if tilt > 0 and pan > 0:
logging.info(f"rho_c: {self.rho_c}, rho_o: {azimuth}, tau_c: {self.tau_c}, tau_o: {elevation}, azimuth_rate_max: {self.azimuth_rate_max}, tilt_rate_max: {self.tilt_rate_max}")
if elevation > 0 and azimuth > 0:
duration = max(
math.fabs(self._compute_angle_delta(self.rho_c, pan))
math.fabs(self._compute_angle_delta(self.rho_c, azimuth))
/ (self.pan_rate_max / 2),
math.fabs(self._compute_angle_delta(self.tau_c, tilt))
math.fabs(self._compute_angle_delta(self.tau_c, elevation))
/ (self.tilt_rate_max / 2),
)
logging.info(f"Sleeping: {duration} [s]")
Expand Down

0 comments on commit 90daadf

Please sign in to comment.