Orbital
bsk_rl.utils.orbital
:Utilities for computing orbital events.
- random_orbit(i: float | None = 45.0, alt: float = 500, r_body: float = 6371, e: float = 0, Omega: float | None = None, omega: float | None = 0, f: float | None = None) ClassicElements [source]
Create a set of orbit elements.
Parameters are fixed if specified and randomized if
None
. Defaults to a random circular orbit at 500 km altitude and 45 deg inclination.- Parameters:
i (float | None) – [deg] Inclination, randomized in
[-pi, pi]
.alt (float) – [km] Altitude above r_body.
r_body (float) – [km] Body radius.
e (float) – Eccentricity.
Omega (float | None) – [deg] LAN, randomized in
[0, 2pi]
.omega (float | None) – [deg] Argument of periapsis, randomized in
[0, 2pi]
.f (float | None) – [deg] True anomaly, randomized in
[0, 2pi]
.
- Returns:
orbital elements
- Return type:
ClassicElements
- random_epoch(start: int = 2000, end: int = 2022)[source]
Generate a random epoch in a year range.
Date will always be in the first 28 days of the month.
- Parameters:
start (int) – Initial year.
end (int) – Final year.
- Returns:
Epoch in
YYYY MMM DD HH:MM:SS.SSS (UTC)
format
- lla2ecef(lat: float, long: float, radius: float)[source]
Project LLA to Earth Centered, Earth Fixed location.
- Parameters:
lat (float) – [deg]
long (float) – [deg]
radius (float) – [any]
- elevation(r_sat: ndarray, r_target: ndarray) ndarray [source]
Find the elevation angle from a target to a satellite.
- Parameters:
r_sat (ndarray) – Satellite position(s).
r_target (ndarray) – Target position.
- Returns:
Elevation angle(s)
- Return type:
ndarray
- walker_delta(n_spacecraft: int, n_planes: int, rel_phasing: float, altitude: float, inc: float, clustersize: int = 1, clusterspacing: float = 0) list[ClassicElements] [source]
Compute the initial orbit conditions of a Walker-delta constellation.
- Parameters:
n_spacecraft (int) – Number of spacecraft.
n_planes (int) – Number of orbital planes.
rel_phasing (float) – [deg] Relative phasing between planes.
altitude (float) – [m] Altitude above Earth’s surface.
inc (float) – [deg] Inclination.
clustersize (int) – Number of spacecraft in each cluster.
clusterspacing (float) – [deg] Spacing between spacecraft in a cluster.
- Returns:
List of orbital elements
- Return type:
list
- walker_delta_args(n_planes: int, rel_phasing: float = 0.0, altitude: float = 500, inc: float = 45.0, randomize_true_anomaly=True, randomize_lan=True, **walker_delta_kwargs)[source]
Generate a function to generate a randomly phased Walker-delta constellation.
The output of this function should be used to set the
sat_arg_randomizer
of the environment.- Parameters:
n_planes (int) – Number of constellation planes.
rel_phasing (float) – [deg] Relative phasing between planes. Defaults to 0.0.
altitude (float) – [km] Orbit altitude above Earth’s surface.
inc (float) – [deg] Orbit inclination
randomize_true_anomaly – Add a random true anomaly phase shift that is the same for all constellation members on each call.
randomize_lan – Add a random LAN phase shift that is the same for all constellation members on each call.
walker_delta_kwargs – Additional arguments to pass to
walker_delta
.
- relative_to_chief(chief_name: str, chief_orbit: ClassicElements | Callable, deputy_relative_state: dict[str, ndarray | Callable])[source]
Generate a function to generate a satellite state relative to another satellite.
The output of this function should be used to set the
sat_arg_randomizer
of the environment.- Parameters:
chief_name (str) – Name of the chief satellite.
chief_orbit (ClassicElements | Callable) – Orbital elements of the chief satellite, or orbit randomizing function.
deputy_relative_state (dict[str, ndarray | Callable]) – Relative state of the deputy satellites. Should be a dict of deputy names and relative states as 6-element vector (rho_H, rho_dot_H) or function that returns such a vector.
- class TrajectorySimulator(utc_init: str, rN: Iterable[float] | None = None, vN: Iterable[float] | None = None, oe: ClassicElements | None = None, mu: float | None = None, dt: float = 30.0)[source]
Bases:
SimBaseClass
Class for propagating trajectory using a point mass simulation.
Simulated under the effect of Earth’s gravity. Returns interpolators for position as well as upcoming eclipse predictions. Specify either
(rN, vN)
or(oe, mu)
.- Parameters:
utc_init (str) – Simulation start time.
rN (Iterable[float] | None) – Initial position [m]
vN (Iterable[float] | None) – Initial velocity [m/s]
oe (ClassicElements | None) – Orbital elements.
mu (float | None) – Gravitational parameter
dt (float) – Simulation timestep.
- property sim_time: float
Current simulator end time.
- property times: ndarray
Recorder times in seconds.
- extend_to(t: float) None [source]
Compute the trajectory of the satellite up to t.
- Parameters:
t (float) – Computation end [s]
- Return type:
None
- next_eclipse(t: float, max_tries: int = 100) tuple[float, float] [source]
Find the soonest eclipse transitions.
The returned values are not necessarily from the same eclipse event, such as when the search start time is in eclipse.
- Parameters:
t (float) – Time to start searching [s]
max_tries (int) – Maximum number of times to search
- Returns:
Nearest upcoming eclipse beginning eclipse_end: Nearest upcoming eclipse end
- Return type:
eclipse_start
- property r_BN_N: interp1d
Interpolator for r_BN_N.
- property r_BP_P: interp1d
Interpolator for r_BP_P.
- rv2HN(r_N: ndarray, v_N: ndarray)[source]
Find the Hill frame rotation matrix from position and velocity.
- Parameters:
r_N (ndarray) – Position vector in the inertial frame
v_N (ndarray) – Velocity vector in the inertial frame
- Returns:
Hill frame rotation matrix HN
- rv2omega(r_N: ndarray, v_N: ndarray)[source]
Find the Hill frame rotation rate from position and velocity.
- Parameters:
r_N (ndarray) – Position vector in the inertial frame
v_N (ndarray) – Velocity vector in the inertial frame
- Returns:
Angular velocity of the Hill frame in the inertial frame
- Return type:
omega_HN_N
- cd2hill(rc_N: ndarray, vc_N: ndarray, rd_N: ndarray, vd_N: ndarray) Tuple[ndarray, ndarray] [source]
Convert from chief and deputy states to Hill frame relative states.
- Parameters:
rc_N (ndarray) – Inertial position of chief
vc_N (ndarray) – Inertial velocity of chief
rd_N (ndarray) – Inertial position of deputy
vd_N (ndarray) – Inertial velocity of deputy
- Returns:
Relative position in Hill frame rho_deriv_H: Relative velocity in Hill frame
- Return type:
rho_H
- hill2cd(rc_N: ndarray, vc_N: ndarray, rho_H: ndarray, rho_deriv_H: ndarray) Tuple[ndarray, ndarray] [source]
Convert from chief and Hill frame relative states to deputy inertial state.
- Parameters:
rc_N (ndarray) – Inertial position of chief
vc_N (ndarray) – Inertial velocity of chief
rho_H (ndarray) – Relative position in Hill frame
rho_deriv_H (ndarray) – Relative velocity in Hill frame
- Returns:
Inertial position of deputy vd_N: Inertial velocity of deputy
- Return type:
rd_N