|
1 | 1 | """Dynamics models concerning the relative motion of spacecraft.""" |
2 | 2 |
|
3 | 3 | import types |
| 4 | +from typing import Optional |
4 | 5 |
|
5 | 6 | import numpy as np |
6 | 7 | from Basilisk.simulation import spacecraftLocation |
@@ -84,15 +85,23 @@ def conjunction_valid(self) -> bool: |
84 | 85 | """Check if conjunction has not occured.""" |
85 | 86 | return len(self.conjunctions) == 0 |
86 | 87 |
|
87 | | - @default_args(conjunction_radius=10) |
88 | | - def setup_conjunctions(self, conjunction_radius: float, **kwargs) -> None: |
| 88 | + @default_args(conjunction_radius=10, conjunction_check_rate=None) |
| 89 | + def setup_conjunctions( |
| 90 | + self, |
| 91 | + conjunction_radius: float, |
| 92 | + conjunction_check_rate: Optional[float], |
| 93 | + **kwargs, |
| 94 | + ) -> None: |
89 | 95 | """Set up conjunction checking between satellites. |
90 | 96 |
|
91 | 97 | Args: |
92 | 98 | conjunction_radius: [m] Minimum distance for a conjunction. |
| 99 | + conjunction_check_rate: [s] Rate at which to check for conjunctions. Defaults to sim rate. |
93 | 100 | kwargs: Passed to other setup functions. |
94 | 101 | """ |
95 | 102 | self.conjunction_radius = conjunction_radius |
| 103 | + if conjunction_check_rate is None: |
| 104 | + conjunction_check_rate = self.simulator.sim_rate |
96 | 105 |
|
97 | 106 | for sat_dyn in self.simulator.dynamics_list.values(): |
98 | 107 | if sat_dyn != self and isinstance(sat_dyn, ConjunctionDynModel): |
@@ -126,11 +135,12 @@ def side_effect(sim): |
126 | 135 | valid_func_name( |
127 | 136 | f"conjunction_{self.satellite.name}_{sat_dyn.satellite.name}" |
128 | 137 | ), |
129 | | - macros.sec2nano(self.simulator.sim_rate), |
| 138 | + macros.sec2nano(conjunction_check_rate), |
130 | 139 | True, |
131 | 140 | conditionFunction=condition, |
132 | 141 | actionFunction=side_effect, |
133 | 142 | terminal=True, |
| 143 | + exactRateMatch=False, |
134 | 144 | ) |
135 | 145 |
|
136 | 146 |
|
|
0 commit comments