Skip to content

Commit

Permalink
make derivative part of gain control
Browse files Browse the repository at this point in the history
  • Loading branch information
robotastic committed Apr 8, 2024
1 parent 63ef62b commit 3904358
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions axis-ptz-controller/axis_ptz_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,16 +585,16 @@ def _track_object(self, time_since_last_update: float) -> None:
)

# Compute slew rate differences
self.rho_c_gain = self.pan_gain * self.delta_rho
self.tau_c_gain = self.tilt_gain * self.delta_tau
self.rho_c_gain = self.pan_gain * self.delta_rho * abs(self.object.rho_derivative)
self.tau_c_gain = self.tilt_gain * self.delta_tau * abs(self.object.tau_derivative)

# Compute position and velocity in the camera fixed (rst)
# coordinate system of the object relative to the tripod at
# time zero after pointing the camera at the object

# Update camera pan and tilt rate
self.rho_dot_c = self.object.rho_rate + self.rho_c_gain
self.tau_dot_c = self.object.tau_rate + self.tau_c_gain
self.rho_dot_c = self.object.rho_rate + self.rho_c_gain #- (self.object.rho_derivative ** 2)
self.tau_dot_c = self.object.tau_rate + self.tau_c_gain #- (self.object.tau_derivative ** 2)

# Get, or compute and set focus, command camera pan and tilt
# rates, and begin capturing images, if needed
Expand Down
1 change: 1 addition & 0 deletions axis-ptz-controller/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ def slew_camera(self, rho_target: float, tau_target: float) -> None:
)
/ (self.tilt_rate_max),
)
duration = duration + 0.5
logging.info(f"Sleeping: {duration} [s]")
sleep(duration)

Expand Down
15 changes: 12 additions & 3 deletions axis-ptz-controller/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def __init__(

# Distance between the object and the tripod at time one
self.distance_to_tripod3d = 0.0 # [m]
self.rho_derivative = 0.0 # [deg/s]
self.tau_derivative = 0.0 # [deg/s]

# Position and velocity in the geocentric (XYZ) coordinate
# system of the object relative to the tripod at time zero
Expand Down Expand Up @@ -91,6 +93,7 @@ def __init__(
self.uvw_point_now_relative_to_tripod = np.zeros((3,))
self.uvw_point_lead_relative_to_tripod = np.zeros((3,))
self.location_update_time = time()
self.uninitialized = True

def _config_log(self) -> None:
"""Print to Logging the object configuration"""
Expand Down Expand Up @@ -262,9 +265,15 @@ def recompute_location(self) -> None:

time_delta = time() - self.location_update_time
self.location_update_time = time()
self.rho_derivative = (self.rho - self.rho_lead) / time_delta
self.tau_derivative = (self.tau - self.tau_lead) / time_delta

if not self.uninitialized:
self.rho_derivative = (self.rho - self.rho_lead) / time_delta
self.tau_derivative = (self.tau - self.tau_lead) / time_delta

if self.rho_derivative > 100:
self.rho_derivative = 100
if self.tau_derivative > 100:
self.tau_derivative = 100
self.rho = self.rho_lead
self.tau = self.tau_lead

Expand Down Expand Up @@ -315,7 +324,7 @@ def recompute_location(self) -> None:

self.rho_rate = math.degrees(-omega[2])
self.tau_rate = math.degrees(omega[0])

self.uninitialized = False

# Compute object slew rate
# omega = (
Expand Down

0 comments on commit 3904358

Please sign in to comment.