Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #116: Add observation of angle between instrument and target #117

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def __init__(
* window_open
* window_mid
* window_close
* target_angle
args: Passed through to satellite
kwargs: Passed through to satellite
"""
Expand Down Expand Up @@ -246,6 +247,17 @@ def target_obs(self):
value = sum(opportunity["window"]) / 2 - self.simulator.sim_time
elif name == "window_close":
value = opportunity["window"][1] - self.simulator.sim_time
elif name == "target_angle":
vector_target_spacecraft_P = (
opportunity["target"].location - self.dynamics.r_BN_P
)
vector_target_spacecraft_P_hat = (
vector_target_spacecraft_P
/ np.linalg.norm(vector_target_spacecraft_P)
)
value = np.arccos(
np.dot(vector_target_spacecraft_P_hat, self.fsw.c_hat_P)
)
else:
raise ValueError(
f"Invalid target property: {prop_spec['prop']}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def test_target_state_normed(self, sat_init):
dict(prop="window_open", norm=10.0),
dict(prop="window_mid"),
dict(prop="window_close"),
dict(prop="target_angle"),
],
)

Expand All @@ -163,6 +164,17 @@ def test_target_state_normed(self, sat_init):
for target in sat.upcoming_targets()
]
sat.simulator = MagicMock(sim_time=5.0)
sat.dynamics = MagicMock(r_BN_P=np.array([5.0, 5.0, 0.0]))
sat.fsw = MagicMock(c_hat_P=np.array([0.0, 1.0, 0.0]))

vector_target_sat = [
sat.upcoming_targets()[i].location - sat.dynamics.r_BN_P
for i in range(n_ahead)
]
vector_target_sat_hat = [
vector_target_sat[i] / np.linalg.norm(vector_target_sat[i])
for i in range(n_ahead)
]

expected = dict(
target_0=dict(
Expand All @@ -171,13 +183,19 @@ def test_target_state_normed(self, sat_init):
window_open_normd=5.0 / 10.0,
window_mid=10.0,
window_close=15.0,
target_angle=np.arccos(
np.dot(vector_target_sat_hat[0], sat.fsw.c_hat_P)
),
),
target_1=dict(
priority=1.0,
location_normd=np.array([0.1, 0.1, 0.0]),
window_open_normd=5.0 / 10.0,
window_mid=10.0,
window_close=15.0,
target_angle=np.arccos(
np.dot(vector_target_sat_hat[1], sat.fsw.c_hat_P)
),
),
)
for k1, v1 in sat.target_obs().items():
Expand Down
Loading