仿真容器,进程,任务,航天器,引力。
基本轨道设计
# setup orbit and simulation time
#
# setup the orbit using classical orbit elements
oe = orbitalMotion.ClassicElements()
# 创建了一个轨道元素对象oe,用于存储轨道的参数。
rLEO = 7000. * 1000 # meters
rGEO = 42000. * 1000 # meters
if orbitCase == 'GEO':
oe.a = rGEO
oe.e = 0.00001
oe.i = 0.0 * macros.D2R
elif orbitCase == 'GTO':
oe.a = (rLEO + rGEO) / 2.0
oe.e = 1.0 - rLEO / oe.a
oe.i = 0.0 * macros.D2R
else: # LEO case, default case 0
oe.a = rLEO
oe.e = 0.0001
oe.i = 33.3 * macros.D2R
# 设置轨道的半长轴(a)、偏心率(e)和轨道倾角(i)。
oe.Omega = 48.2 * macros.D2R
oe.omega = 347.8 * macros.D2R
oe.f = 85.3 * macros.D2R
# 设置了轨道的平近点角(Omega)、升交点赤经(omega)和真近点角(f)。
# 这些角度的单位是弧度,macros.D2R是一个宏,用于将度转换为弧度。
rN, vN = orbitalMotion.elem2rv(mu, oe)
oe = orbitalMotion.rv2elem(mu, rN, vN)
# 轨道元素(oe)和万有引力常数(mu)计算轨道的位置(rN)和速度(vN)。
# this stores consistent initial orbit elements
# with circular or equatorial orbit, some angles are arbitrary
航天器初始化
scObject.hub.r_CN_NInit = rN # m - r_BN_N
scObject.hub.v_CN_NInit = vN # m/s - v_BN_N
# set the simulation time
# 天体运动的模拟时间,轨道周期
n = np.sqrt(mu / oe.a / oe.a / oe.a)#轨道周期的倒数,开普勒第三定律。
P = 2. * np.pi / n #周期
if useSphericalHarmonics: #球谐函数
simulationTime = macros.sec2nano(3. * P)
else:
simulationTime = macros.sec2nano(0.75 * P)
# Setup data logging before the simulation is initialized
if useSphericalHarmonics:
numDataPoints = 400
else:
numDataPoints = 100
samplingTime = unitTestSupport.samplingTime(simulationTime, simulationTimeStep, numDataPoints)
# create a logging task object of the spacecraft output message at #the desired down sampling ratio
dataRec = scObject.scStateOutMsg.recorder(samplingTime)
scSim.AddModelToTask(simTaskName, dataRec)