Skip to content

Custom Constraint Computer

The AccessConstraintComputer base class allows you to create custom constraint logic for access computation. Subclass this class and implement the evaluate and name methods to define custom constraints that can be combined with built-in constraints using logical operators.

AccessConstraintComputer

AccessConstraintComputer()

Base class for custom access constraint computers.

Subclass this class and implement the evaluate and name methods to create custom constraint logic that can be applied to access computation.

The evaluate method is called at each time step during access search to determine if the constraint is satisfied. Return True if the constraint is satisfied (access is allowed), False otherwise.

Example
import brahe as bh
import numpy as np

class NorthernHemisphereConstraint(bh.AccessConstraintComputer):
    '''Only allows access when satellite is in northern hemisphere.'''

    def evaluate(self, epoch: bh.Epoch, satellite_state_ecef: np.ndarray, location_ecef: np.ndarray) -> bool:
        '''
        Args:
            epoch (Epoch): Current evaluation time
            satellite_state_ecef (ndarray): Satellite state [x,y,z,vx,vy,vz] in ECEF (m, m/s)
            location_ecef (ndarray or list): Location position [x,y,z] in ECEF (m)

        Returns:
            bool: True if constraint is satisfied, False otherwise
        '''
        # Check if satellite Z-coordinate (ECEF) is positive (northern hemisphere)
        return satellite_state_ecef[2] >= 0.0

    def name(self) -> str:
        '''Return name of this constraint.'''
        return "NorthernHemisphereConstraint"

# Use with access computation
custom_constraint = NorthernHemisphereConstraint()
# Then combine with other constraints using ConstraintAll or ConstraintAny
Notes
  • The evaluate method receives ECEF coordinates in SI units (meters, m/s)
  • Return True to allow access, False to reject
  • The constraint is checked at each time step during access search
  • Custom constraints can be combined with built-in constraints using ConstraintAll/ConstraintAny

Initialize instance.

evaluate method descriptor

evaluate(epoch: Epoch, satellite_state_ecef: ndarray, location_ecef: Union[ndarray, List]) -> bool

Evaluate whether the constraint is satisfied.

Override this method in your subclass to implement custom constraint logic.

Parameters:

Name Type Description Default
epoch Epoch

Current evaluation time

required
satellite_state_ecef ndarray

Satellite state in ECEF [x,y,z,vx,vy,vz] (meters, m/s)

required
location_ecef ndarray or list

Location position in ECEF [x,y,z] (meters)

required

Returns:

Name Type Description
bool bool

True if constraint is satisfied (access allowed), False otherwise

name method descriptor

name() -> str

Return name of this constraint computer.

Override this method to return a descriptive name for your constraint.

Returns:

Name Type Description
str str

Constraint name