Source code for mds_api.mds_constellations
"""Additional functionality for MDS: creating constellations"""
import json
import math
import re
from mds_api import client
from mds_api.NetworkConfiguration import NetworkConfiguration
[docs]
def add_multiple_sats_from_elements(constellation_name: str, num_spacecraft: float, mass: float, a: float, e: float, i: float, Omega: float, omega: float,
nu_offset: float, central_body: str) -> bytes:
""" Instantiate multiple satellites in the same orbit. The true anomaly of the first satellite is nu_offset and the rest of satellites are spaced evenly with respect to true anomaly.
Args:
constellation_name (str): name of the new spacecraft to be instantiated
num_spacecraft (int): number of spacecraft
mass (float): mass of the spacecraft [kg]
a (float): semi-major axis [m]
e (float): eccentricity [-]
i (float): inclination [deg]
Omega (float): right ascension of the ascending node [deg]
omega (float): argument of periapsis [deg]
nu_offset (float): true anomaly offset for the first spacecraft [deg]
central_body (str): name of central body
"""
data = {}
data['constellationType'] = 0
data['constellationName'] = constellation_name
data['spacecraftMass'] = mass
data['numSpacecraft'] = num_spacecraft
data['semiMajorAxis'] = a
data['eccentricity'] = e
data['inclination'] = i
data['ascendingNodeLongitude'] = Omega
data['periapsisArgument'] = omega
data['trueAnomalyOffset'] = nu_offset
data['centralBody'] = central_body
json_data = json.dumps(data)
response = client.create_constellation(json_data, NetworkConfiguration.MDS_HOST, NetworkConfiguration.MDS_HOST_PORT)
return response
[docs]
def create_walker_constellation(constellation_name: str, mass: float,
i: float, t: int, p: int, f: float,
ANLongitude: float, orbitRadius: float,
central_body: str, ta_offset: float = 0,
referenceArea: float = 1.0,
coefficientDrag: float = 2.2,
coefficientSRP: float = 1.2) -> bytes:
""" Create satellites in a walker constallation
Args:
constellation_name (str): name of the new spacecraft to be instantiated
mass (float): mass of the spacecraft [kg]
i (float): inclination [deg]
t (int): number of spacecraft
p (int): number of planes
f (float): relative spacing between satellites in adjacent planes.
actual spacing in degrees is calculated by formula f*360/t
ANLongitude (float): right ascension of the ascending node [deg]
orbitRadius (float): orbit radius [m]
central_body (str): name of central body
ta_offset (float): true anomaly offset for the first spacecraft [deg],
defaults to 0
"""
data = {}
data['constellationType'] = 1
data['constellationName'] = constellation_name
data['spacecraftMass'] = mass
data['numSpacecraft'] = t
data['numPlanes'] = p
data['orbitRadius'] = orbitRadius
data['inclination'] = i
data['ascendingNodeLongitude'] = ANLongitude
data['trueAnomalyOffset'] = ta_offset
data['relativeSpacing'] = f
data['centralBody'] = central_body
data['referenceArea'] = referenceArea
data['coefficientDrag'] = coefficientDrag
data['coefficientSRP'] = coefficientSRP
json_data = json.dumps(data)
response = client.create_constellation(json_data, NetworkConfiguration.MDS_HOST, NetworkConfiguration.MDS_HOST_PORT)
return response