Skip to content

Commit

Permalink
ACU: permit scans on LAT even when Sun Avoidance is not to be enabled (
Browse files Browse the repository at this point in the history
…#586)

* ACU: full sun policy for LAT, though avoidance remains disabled

* ACU: better behavior if Sun avoidance isn't configured

* ACU: add proper return when monitor_sun exits on request
  • Loading branch information
mhasself authored Dec 8, 2023
1 parent 37bc3f2 commit 6815d59
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions socs/agents/acu/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@
}


#: Default Sun avoidance params by platform type (enabled, policy)
#: Default Sun avoidance params by platform type (enabled, policy). If
#: either of escape *or* monitoring is enabled, then the full policy
#: must be specified.
SUN_CONFIGS = {
'ccat': {
'enabled': False,
'policy': {},
'policy': {
'exclusion_radius': 20,
'el_horizon': 10,
'min_sun_time': 1800,
'response_time': 7200,
},
},
'satp': {
'enabled': True,
Expand Down Expand Up @@ -1713,7 +1720,7 @@ def generate_scan(self, session, params):
ok, msg = self._check_scan_sunsafe(az_endpoint1, az_endpoint2, el_endpoint1,
az_speed, az_accel)
if ok:
self.log.info('Sun safety check passes: {msg}', msg=msg)
self.log.info('Sun safety check: {msg}', msg=msg)
else:
self.log.error('Sun safety check fails: {msg}', msg=msg)
return False, 'Scan is not Sun Safe.'
Expand Down Expand Up @@ -2201,6 +2208,8 @@ def lookup(keys, tree):

yield dsleep(1)

return True, 'monitor_sun exited cleanly.'

@ocs_agent.param('reset', type=bool, default=None)
@ocs_agent.param('enable', type=bool, default=None)
@ocs_agent.param('temporary_disable', type=float, default=None)
Expand Down Expand Up @@ -2363,6 +2372,17 @@ def _leg_done(result):
return True, "Exited."

def _check_scan_sunsafe(self, az1, az2, el, v_az, a_az):
"""This will return True if active avoidance is disabled. If active
avoidance is enabled, then it will only return true if the
planned scan seems to currently be sun-safe.
"""
if not self._get_sun_policy('sunsafe_moves'):
return True, 'Sun-safety checking is not enabled.'

if not self._get_sun_policy('map_valid'):
return False, 'Sun Safety Map not computed or stale; run the monitor_sun process.'

# Include a bit of buffer for turn-arounds.
az1, az2 = min(az1, az2), max(az1, az2)
turn = v_az**2 / a_az
Expand All @@ -2378,10 +2398,7 @@ def _check_scan_sunsafe(self, az1, az2, el, v_az, a_az):
else:
msg = 'Scan will be unsafe in %.1f hours' % (info['sun_time'] / 3600)

if self._get_sun_policy('sunsafe_moves'):
return safe, msg
else:
return True, 'Sun-safety not active; %s' % msg
return safe, msg

def _get_sunsafe_moves(self, target_az, target_el):
"""Given a target position, find a Sun-safe way to get there. This
Expand Down

0 comments on commit 6815d59

Please sign in to comment.