-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommands.py
8821 lines (7639 loc) · 478 KB
/
Commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import FreeCAD
import FreeCADGui
import sys
import os
import math
import re
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import csv
from scipy.optimize import curve_fit
import numpy
import warnings
from datetime import timedelta
from os.path import exists
from datetime import datetime
import zipfile
FreeCADPath = FreeCAD.__path__[1]
FreeCADPathbin = FreeCADPath.replace("lib","bin")
FreeCADPath = FreeCADPathbin + "\\Scripts\\pip"
# import FreeSimpleGUI as sg
try:
import FreeSimpleGUI as sg
except:
import subprocess
print("pip installing necessary packages for Spacecraft Designer\n"
"This may take a minute...")
def install_requirements():
try:
FreeCAD.Console.PrintMessage("Installing requirements...\n") # Use FreeCAD's console
subprocess.check_call([FreeCADPath, "install", "FreeSimpleGUI"])
subprocess.check_call([FreeCADPath, "install", "requests"])
FreeCAD.Console.PrintMessage("Installation complete!\n")
except subprocess.CalledProcessError as e:
FreeCAD.Console.PrintError(f"Error installing requirements: {e}\n")
install_requirements()
import requests
# We also need to download tcl/tk which is what is necessary for FreeSimpleGUI for this workbench GUI
url = "https://github.com/VallesMarinerisExplorer/tcl/archive/refs/heads/main.zip"
response = requests.get(url)
response.raise_for_status() # Raise an exception for HTTP errors
filename = url.split("/")[-1] # Extract filename from URL
with open(filename, 'wb') as file:
file.write(response.content)
with zipfile.ZipFile(filename, 'r') as zip_ref:
zip_ref.extractall(FreeCADPathbin)
import shutil
# Define the source and destination directories
source_dir = FreeCADPathbin + "\\tcl-main\\tcl"
destination_dir = FreeCADPathbin.replace("bin","lib")
# Get the subfolders of the source parent directory
subfolders = [f for f in os.listdir(source_dir) if os.path.isdir(os.path.join(source_dir, f))]
# Copy each subfolder to the destination directory
for subfolder in subfolders:
source_subfolder = os.path.join(source_dir, subfolder)
try:
shutil.copytree(source_subfolder, os.path.join(destination_dir, subfolder))
except shutil.Error as e:
print(f"Error copying {subfolder}: {e}")
except OSError as e:
print(f"OS error encountered for {subfolder}: {e}")
src_files = os.listdir(source_dir)
for file_name in src_files:
full_file_name = os.path.join(source_dir, file_name)
if os.path.isfile(full_file_name):
shutil.copy(full_file_name, destination_dir)
shutil.rmtree(source_dir)
os.remove(filename)
import FreeSimpleGUI as sg
username = str(os.getlogin())
sg.ChangeLookAndFeel('Black')
App=FreeCAD
SCDesignerPath = "C:\\Users\\" + username + "\\AppData\\Roaming\\FreeCAD\\Mod\\SpacecraftDesigner"
class vehicle:
def __init__(self):
self.name = ""
self.destination = ""
self.launch_date = ""
self.launch_vehicle = ""
self.cost = ""
self.mass = 0
self.system_list = {}
self.TargetLatitude = 0
self.TargetLongitude = 0
new_vehicle = vehicle()
def addPowerSystem(Name,Volts,PeakAmps):
with open(SCDesignerPath + "\\Vehicles\\" + new_vehicle.name + "PowerBudget.csv", "a") as f:
f.write(Name + "," + Volts + "," + PeakAmps + "\n")
f.close()
def MeridionalStress(pressure, axialradius, thickness):
MeridStress = pressure*axialradius/(2*thickness)
return MeridStress
def HoopStress(pressure, axialradius, thickness, merradius):
# Hoop stress according to eqn 11-47 of Space Mission Analysis and Design Second Edition
HoopStressReturn = (pressure*axialradius/(2*thickness))*(2-(axialradius/merradius))
return HoopStressReturn
def Properties(Name, Selector):
import pandas as pd
xls_file = pd.ExcelFile('MECHANICAL\\Materials.xlsx')
df = xls_file.parse('Sheet1')
Name = df[df['NAME'].str.match(Name)]
Columns = ['MATERIAL', 'NAME', 'GEOMETRY', 'DENSITY_(kg/m^3)', 'TENSILE_ULT_STRENGTH', 'TENSILE_YIELD_STRENGTH',
'YOUNGS_MODULUS', 'ELONGATION_PERCENT', 'COEFF_THERMAL_EXP', 'POISSONS RATIO', 'HEAT TRANSFER COEFF', 'VICKERS HARDNESS']
Column = Columns.index(Selector)
return Name.iloc[0,Column]
class Body():
def __init__(self, Name):
self.Name = Name
if self.Name == "Mercury":
self.orbit_rad = 0.38709893
self.orbit_per = self.orbit_rad**1.5
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 252.25084
self.mass = 3.3e23
self.radius = 2440
self.soi = 111631
if self.Name == "Venus":
self.orbit_rad = 0.72333199
self.orbit_per = self.orbit_rad**1.5
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 181.97973
self.mass = 4.869e24
self.radius = 6052
self.soi = 612171
if self.Name == "Earth":
self.orbit_rad = 1
self.orbit_per = 1
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 100.46435
self.mass = 5.972e24
self.radius = 6378
self.soi = 918347
if self.Name == "Mars":
self.orbit_rad = 1.52366231
self.orbit_per = self.orbit_rad**1.5
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 355.45332
self.mass = 6.4219e23
self.radius = 3397
self.soi = 573473
if self.Name == "Jupiter":
self.orbit_rad = 5.20336301
self.orbit_per = self.orbit_rad**1.5
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 34.40438
self.mass = 1.9e27
self.radius = 71492
self.soi = 47901004
if self.Name == "Saturn":
self.orbit_rad = 9.53707032
self.orbit_per = self.orbit_rad**1.5
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 49.94432
self.mass = 5.68e26
self.radius = 60268
self.soi = 54164329
if self.Name == "Uranus":
self.orbit_rad = 19.19126393
self.orbit_per = self.orbit_rad**1.5
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 313.23218
self.mass = 8.683e25
self.radius = 25559
self.soi = 51419820
if self.Name == "Neptune":
self.orbit_rad = 30.06896348
self.orbit_per = self.orbit_rad**1.5
self.orbit_vel = 2*math.pi*self.orbit_rad/self.orbit_per
self.mean_longJ2000 = 304.8803
self.mass = 1.0247e26
self.radius = 24766
self.soi = 86082764
def AtlasMass(apogeealt, config, inclination):
x = [5000, 7500, 10000, 12500, 15000, 17500, 20000, 22500, 25000, 27500, 30000, 35000, 35786, 40000, 45000,
50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000, 105000, 110000, 115000,
120000, 125000, 130000, 135000, 140000, 145000, 150000]
if config == 401:
y = [7827, 7135, 6625, 6238, 5933, 5688, 5487, 5318, 5176, 5054, 4948, 4774, 4750, 4636, 4525, 4433, 4356,
4290, 4234, 4184, 4141, 4103, 4069, 4038, 4011, 3986, 3963, 3942, 3923, 3905, 3889, 3874, 3860, 3847,
3835, 3823]
if config == 411:
y = [9729, 8869, 8242, 7766, 7394, 7095, 6847, 6642, 6468, 6321, 6191, 5978, 5950, 5810, 5674, 5562, 5467,
5387, 5318, 5258, 5205, 5158, 5117, 5079, 5046, 5015, 4987, 4962, 4939, 4917, 4897, 4879, 4862, 4846,
4831, 4817]
if config == 421:
y = [11263, 10260, 9529, 8977, 8545, 8199, 7915, 7680, 7481, 7311, 7164, 6922, 6890, 6732, 6579, 6452, 6348,
6258, 6181, 6113, 6054, 6001, 5955, 5913, 5875, 5841, 5810, 5781, 5755, 5731, 5709, 5688, 5669, 5651,
5634, 5619]
if config == 431:
y = [12573, 11453, 10637, 10021, 9541, 9156, 8841, 8579, 8358, 8169, 8005, 7736, 7700, 7525, 7355, 7215,
7097, 6997, 6912, 6837, 6771, 6713, 6662, 6615, 6573, 6536, 6501, 6470, 6441, 6414, 6389, 6367, 6348,
6329, 6310, 6293]
if config == 501:
y = [6392, 5783, 5335, 5002, 4773, 4570, 4401, 4262, 4115, 4021, 3940, 3796, 3775, 3682, 3583, 3506, 3442,
3382, 3337, 3295, 3253, 3223, 3195, 3168, 3145, 3123, 3104, 3085, 3069, 3054, 3040, 3027, 3014, 3003,
2992, 2982]
if config == 511:
y = [8807, 7988, 7394, 6944, 6594, 6313, 6083, 5893, 5731, 5593, 5473, 5277, 5250, 5123, 4998, 4895, 4809,
4735, 4672, 4617, 4569, 4526, 4488, 4454, 4423, 4395, 4370, 4347, 4326, 4306, 4288, 4271, 4255, 4241,
4227, 4215]
if config == 521:
y = [10790, 9785, 9058, 8512, 8088, 7749, 7475, 7245, 7051, 6885, 6742, 6507, 6475, 6322, 6173, 6050, 5947,
5860, 5784, 5719, 5662, 5611, 5566, 5525, 5489, 5456, 5425, 5398, 5373, 5349, 5328, 5308, 5289, 5272,
5256, 5241]
if config == 531:
y = [12455, 11288, 10446, 9806, 9323, 8933, 8614, 8350, 8129, 7940, 7776, 7508, 7475, 7301, 7131, 6991,
6875, 6775, 6690, 6616, 6551, 6493, 6442, 6396, 6354, 6317, 6283, 6252, 6223, 6197, 6172, 6150, 6129,
6109, 6091, 6074]
if config == 541:
y = [13885, 12561, 11610, 10901, 10345, 9913, 9562, 9268, 9021, 8810, 8627, 8330, 8290, 8096, 7909, 7754,
7624, 7514, 7424, 7342, 7270, 7206, 7150, 7099, 7053, 7012, 6974, 6940, 6908, 6879, 6852, 6827, 6804,
6783, 6763, 6744]
if config == 551:
y = [14988, 13534, 12497, 11726, 11131, 10659, 10275, 9955, 9690, 9461, 9265, 8944, 8900, 8691, 8488, 8322,
8181, 8064, 7962, 7873, 7796, 7727, 7666, 7611, 7562, 7517, 7481, 7444, 7410, 7379, 7350, 7323, 7298,
7275, 7253, 7233]
with warnings.catch_warnings():
warnings.simplefilter('ignore', np.RankWarning)
coeff = numpy.polyfit(x, y, 21)
p = np.poly1d(coeff)
masslim = p(apogeealt)
return masslim
def AntaresMass(apogeealt, config, inclination):
if config == 232:
x = [1375.026864, 1681.203525, 1885.321298, 2242.527402, 2586.976144, 3001.590372, 3246.106455, 3639.458414,
4054.072641, 4436.793467, 4819.514292, 5266.021921, 5776.316355, 6286.610789, 6796.905222, 7370.98646,
8008.854502, 8710.509349, 9475.950999, 10305.17945, 11261.98152, 12410.14399, 13749.66688, 15152.97657,
16556.28627, 17959.59596, 19362.90565, 20766.21534, 22169.52504, 23572.83473, 24976.14442, 26379.45412,
27782.76381, 29186.0735, 30589.38319, 31992.69289, 33396.00258, 34799.31227, 36202.62196, 37605.93166,
39009.24135, 40412.55104, 41815.86074, 43219.17043, 44622.48012, 46025.78981, 47429.09951, 48832.4092,
50235.71889, 51639.02858, 53042.33828, 54445.64797, 55848.95766, 57252.26735, 58655.57705, 60058.88674,
61462.19643, 62865.50613, 64268.81582, 65672.12551, 67075.4352, 68478.7449, 69882.05459, 71285.36428,
72688.67397, 74091.98367, 75495.29336, 76898.60305, 78301.91274, 79705.22244, 81108.53213, 82511.84182,
83915.15152, 85318.46121, 86721.7709, 88125.08059, 89528.39029, 90931.69998, 92335.00967, 93738.31936,
95141.62906, 96544.93875, 97948.24844, 99287.77133]
y = [6884.159239, 6705.16221, 6557.908497, 6389.051693, 6215.124777, 6021.688948, 5894.385027, 5735.668449,
5572.543078, 5422.644088, 5274.949495, 5115.681818, 4945.392157, 4788.328877, 4639.532086, 4483.130125,
4327.058824, 4172.75104, 4023.954248, 3882.085561, 3742.618093, 3596.962567, 3449.909253, 3321.853832,
3210.030789, 3112.035327, 3026.063847, 2949.711554, 2880.573651, 2819.852536, 2764.542214, 2712.839086,
2667.14795, 2626.266407, 2584.783666, 2549.914114, 2513.842165, 2483.181008, 2448.912656, 2421.858694,
2389.995139, 2367.75077, 2343.702803, 2321.458435, 2304.624858, 2290.196078, 2270.356506, 2256.528926,
2246.909739, 2237.290553, 2228.272565, 2218.653379, 2204.825798, 2194.004213, 2181.98023, 2172.962243,
2162.140658, 2152.521471, 2140.497488, 2129.675903, 2122.461514, 2115.247124, 2108.032734, 2103.22314,
2096.60995, 2091.199157, 2080.377573, 2073.764382, 2065.347594, 2058.734403, 2052.722411, 2047.311619,
2041.900826, 2038.894831, 2032.28164, 2027.472047, 2023.263653, 2013.043267, 2007.632474, 1999.215686,
1993.804894, 1988.995301, 1985.989305, 1979.376114]
if config == 233:
x = [609.5852138, 915.7618741, 1119.879648, 1438.813669, 1706.718246, 2140.468515, 2446.645175, 2905.910165,
3288.630991, 3798.925424, 4245.433054, 4691.940683, 5138.448313, 5648.742747, 6159.03718, 6733.118418,
7370.98646, 8008.854502, 8646.722545, 9348.377391, 10177.60585, 11134.40791, 12282.57038, 13622.09327,
15025.40297, 16428.71266, 17832.02235, 19235.33204, 20638.64174, 22041.95143, 23445.26112, 24848.57081,
26251.88051, 27655.1902, 29058.49989, 30461.80959, 31865.11928, 33268.42897, 34671.73866, 36075.04836,
37478.35805, 38881.66774, 40284.97743, 41688.28713, 43091.59682, 44494.90651, 45898.2162, 47301.5259,
48704.83559, 50108.14528, 51511.45498, 52914.76467, 54318.07436, 55721.38405, 57124.69375, 58528.00344,
59931.31313, 61334.62282, 62737.93252, 64141.24221, 65544.5519, 66947.86159, 67777.09005]
y = [6773.939394, 6607.286988, 6456.506239, 6311.016043, 6141.71836, 5960.516934, 5789.896613, 5590.178253,
5426.171123, 5230.861557, 5054.509804, 4889.180036, 4735.423351, 4571.746881, 4413.030303, 4247.700535,
4081.048128, 3927.622103, 3788.745098, 3647.002377, 3505.13369, 3365.666221, 3221.994652, 3078.368174,
2951.515152, 2839.090909, 2738.089451, 2649.713175, 2566.747691, 2494.002593, 2426.668287, 2364.744774,
2308.232053, 2255.927726, 2209.635391, 2165.747853, 2124.86631, 2091.800357, 2055.127208, 2028.674445,
1998.013288, 1976.971317, 1956.530546, 1934.286177, 1915.047804, 1900.017825, 1878.374656, 1857.332685,
1842.302706, 1828.475126, 1811.641549, 1794.807973, 1784.587587, 1773.164803, 1760.539621, 1744.307244,
1728.676065, 1719.056879, 1710.038892, 1701.622103, 1693.806514, 1682.38373, 1678.475936]
with warnings.catch_warnings():
warnings.simplefilter('ignore', np.RankWarning)
coeff = numpy.polyfit(x, y, 30)
p = np.poly1d(coeff)
masslim = p(apogeealt)
return masslim
def Falcon9MassCirc(apogeealt, config, inclination):
if config == "RTLS" and inclination == 28.5:
x = [399.9794132, 481.7548257, 506.1310516, 556.9202175, 654.4280656, 721.4628421, 754.9802304, 797.6395401,
822.0150069, 855.5323951, 948.4618062, 998.7348981, 1041.388227, 1086.073094, 1113.495868, 1149.548193,
1196.771841, 1231.807543, 1298.915736, 1349.100459, 1431.356819, 1497.650438, 1600.867641, 1697.77789,
1796.718181, 1896.797531, 1996.607575]
y = [11680.50006, 11365.56956, 11286.36111, 11101.76376, 10774.17717, 10555.78611, 10446.59058, 10304.6364,
10228.19952, 10119.004, 9835.09562, 9682.221879, 9562.106797, 9434.712013, 9347.355589, 9245.439762,
9111.285255, 9016.129151, 8844.271282, 8699.462116, 8481.071058, 8317.277764, 8320.917615, 8322.737541,
8322.737541, 8310.866329, 8313.554521]
if config == "ASDS" and inclination == 28.5:
x = [399.4351444, 430.9309628, 483.7609219, 501.0279989, 616.8361376, 656.4556164, 699.1250938, 744.8305145,
796.6392219, 848.4419483, 894.1521538, 924.6246273, 999.5000358, 1067.842083, 1099.835319, 1151.635553,
1193.987441, 1220.192488, 1253.709876, 1295.354912, 1323.78897, 1379.647296, 1407.577954, 1433.474084,
1488.32038, 1508.629032, 1544.681357, 1592.919921, 1620.849084, 1672.134954, 1708.287959, 1738.14499,
1791.243666, 1818.879192, 1862.03891, 1898.8568, 1947.339586, 1998.620971]
y = [15520.54284, 15382.2285, 15156.55774, 15098.32013, 14645.15868, 14486.82516, 14307.74449, 14159.23857,
13957.22685, 13777.05422, 13611.07702, 13504.0654, 13240.43619, 13012.68552, 12910.76969, 12739.6967,
12608.66206, 12521.30564, 12412.11011, 12268.33599, 12193.71905, 12026.2859, 11937.10956, 11866.13246,
11688.68973, 11640.4617, 11538.54587, 11403.87139, 11320.15482, 11174.56078, 11075.55683, 10992.56823,
10844.3743, 10774.17717, 10657.70194, 10539.40678, 10439.31088, 10310.09617]
if config == "RTLS" and inclination == 38:
x = [404.6643957, 467.3105337, 505.3767633, 596.5181932, 643.9378393, 700.2758592, 741.3873873, 802.2933548,
844.927532, 918.0146929, 954.5582734, 1007.546465, 1083.475905, 1103.777894, 1146.412071, 1195.745905,
1219.499232, 1264.163608, 1301.722288, 1345.879114, 1396.735597, 1423.534223, 1499.734812, 1598.638879,
1699.133726, 1799.846093, 1900.123418, 1996.050317]
y = [11379.78846, 11155.35308, 11040.79752, 10714.96628, 10555.30015, 10362.95777, 10227.99855, 10036.29333,
9900.696949, 9682.495883, 9573.39535, 9426.071401, 9209.325008, 9144.592025, 9016.98263, 8883.007175,
8809.691617, 8693.317715, 8585.315049, 8471.479964, 8328.275957, 8264.188951, 8084.2113, 8106.902349,
8102.356493, 8106.772467, 8111.448204, 8092.686441]
if config == "ASDS" and inclination == 38:
x = [397.2686711, 496.2408682, 604.3489605, 696.2154614, 753.5685808, 815.9971974, 875.3805157, 903.2957508,
953.0356242, 1000.237749, 1048.962523, 1097.687297, 1115.959087, 1149.457369, 1198.182143, 1219.499232,
1254.520163, 1324.562026, 1377.854747, 1402.217134, 1435.715416, 1491.292112, 1508.802577, 1548.391456,
1595.593581, 1626.046565, 1675.278889, 1705.224323, 1761.562342, 1796.583274, 1833.126854, 1884.389377,
1907.736664, 1954.938789, 1995.441258]
y = [15137.52255, 14747.48814, 14313.81352, 13968.3285, 13773.76588, 13533.74471, 13337.36375, 13240.99161,
13064.61241, 12886.9344, 12737.31081, 12577.2967, 12519.10975, 12410.00921, 12246.35841, 12191.80815,
12082.70761, 11864.50655, 11700.85575, 11641.94146, 11537.20495, 11373.55415, 11326.27725, 11209.90335,
11077.16437, 10991.70228, 10853.50827, 10778.95624, 10620.76047, 10529.38877, 10435.28956, 10311.64229,
10244.36363, 10118.89802, 10009.79748]
if config == "RTLS" and inclination == 45:
x = [402.2547626, 444.0819221, 500.9050035, 538.4488251, 602.5044322, 702.8298818, 739.3590055, 791.8696209,
842.8581894, 896.6371771, 952.4455606, 1000.716188, 1027.025855, 1073.448283, 1125.958898, 1165.532116,
1202.737705, 1244.67855, 1276.134185, 1346.655687, 1398.405279, 1499.767034, 1599.31546, 1699.77055,
1800.22564, 1899.158684, 1998.091727]
y = [11112.98892, 10966.49631, 10797.6009, 10639.47025, 10434.57542, 10136.63531, 9985.520864, 9832.980184,
9658.571852, 9495.114467, 9331.674203, 9182.219869, 9113.755278, 8970.724716, 8830.477368, 8721.537166,
8606.890747, 8503.656763, 8412.860421, 8242.259346, 8106.103355, 7845.584364, 7843.112269, 7842.745597,
7850.216941, 7850.411779, 7852.547304]
if config == "ASDS" and inclination == 45:
x = [400.7035877, 441.0378285, 500.3976545, 555.1913401, 606.0277039, 663.2566644, 698.9160471, 804.8070189,
855.034564, 897.651875, 931.1369051, 979.8424034, 1002.673106, 1046.812464, 1080.297494, 1103.635545,
1132.047086, 1184.811375, 1203.075937, 1235.546269, 1290.339955, 1322.302938, 1343.611594, 1396.883233,
1416.669841, 1456.243059, 1497.947142, 1530.823353, 1588.661132, 1605.403647, 1647.513609, 1698.248503,
1776.633915, 1808.705616, 1855.019326, 1898.651335, 1943.298042, 1997.787318]
y = [14779.795, 14638.079, 14401.81933, 14191.01841, 13979.45562, 13776.68868, 13652.10488, 13264.29478,
13089.88003, 12935.0704, 12828.26432, 12664.76413, 12599.39231, 12446.781, 12326.86203, 12257.85202,
12174.31493, 11999.92158, 11919.94136, 11847.36592, 11665.70476, 11585.8401, 11520.45543, 11360.63624,
11302.52367, 11193.58347, 11060.62095, 10975.66454, 10831.91073, 10785.06413, 10656.11175, 10525.4109,
10305.70285, 10238.06739, 10104.20713, 9989.837467, 9886.403771, 9753.549115]
if config == "RTLS" and inclination == 51.6:
x = [403.1141961, 450.2996276, 544.6617355, 626.8513825, 660.3365939, 730.35378, 784.1327494, 823.2027206,
946.4988645, 998.2500632, 1019.562814, 1059.141552, 1138.299027, 1217.456503, 1275.304146, 1347.362235,
1398.614882, 1430.584008, 1500.844524, 1599.63267, 1700.175855, 1800.388131, 1900.917705, 1998.841428]
y = [10838.94817, 10691.71297, 10364.52362, 10091.86583, 9982.802716, 9764.676485, 9588.357782, 9475.659229,
9110.297792, 8946.703119, 8892.171561, 8783.108446, 8564.982215, 8346.855984, 8194.167622, 8012.395763,
7883.337743, 7801.540406, 7628.323093, 7627.039421, 7627.039421, 7618.004723, 7623.403984, 7629.498976]
if config == "ASDS" and inclination == 51.6:
x = [405.5994905, 467.9906988, 506.0387592, 539.5166747, 609.5236465, 664.3084758, 702.3579953, 792.9087309,
825.6351699, 895.0365829, 923.0438837, 982.4004743, 1005.229482, 1035.672136, 1087.421389, 1139.174534,
1244.200313, 1315.74088, 1352.272855, 1399.246289, 1428.383567, 1478.922055, 1499.927053, 1544.073018,
1596.847586, 1624.753875, 1674.227297, 1701.373354, 1746.536851, 1797.645178, 1832.293702, 1886.898079,
1914.299103, 1966.263731, 2000.771145, 1203.985641]
y = [14433.75371, 14181.73266, 14045.40377, 13909.07487, 13652.77655, 13440.10348, 13309.22774, 12971.13208,
12872.97528, 12630.85516, 12545.19799, 12338.56601, 12257.41051, 12164.06503, 11993.19948, 11836.87568,
11509.68633, 11291.5601, 11182.49699, 11056.29538, 10964.37076, 10823.17665, 10757.15084, 10637.18141,
10502.67023, 10419.05518, 10282.72628, 10204.56438, 10091.86583, 9965.664227, 9866.468726, 9738.501338,
9664.338419, 9539.27938, 9454.937237, 11620.68966]
if config == "RTLS" and inclination == 60:
x = [401.4119958, 466.8933014, 504.2482525, 538.4658912, 601.8250984, 648.1090075, 721.2044184, 754.7064817,
827.8018925, 883.6386647, 938.9678299, 995.3122091, 1019.677346, 1101.909683, 1141.503031, 1194.294161,
1260.283073, 1424.747748, 1498.858373, 1600.379777, 1642.511159, 1694.287076, 1735.403244, 1831.340971,
1902.139836, 1930.32434, 2001.722482]
y = [8446.432031, 12024.26004, 8124.154558, 8034.342912, 7870.481111, 7746.838876, 7555.169519, 7459.33484,
7267.665483, 7127.107954, 6980.161447, 6845.992896, 6788.492089, 6611.546658, 6500.988053, 6385.986438,
6213.484017, 5830.145302, 5670.420837, 5439.186309, 5350.971908, 5245.553762, 5159.302551, 4967.633193,
4833.464643, 4775.963836, 4641.795286]
if config == "ASDS" and inclination == 60:
x = [406.2850232, 503.9486138, 597.8559125, 698.6666667, 757.7521238, 901.9125174, 1002.164904, 1056.225051,
1096.427527, 1127.797641, 1179.573557, 1240.4864, 1283.632996, 1315.104632, 1398.098379, 1427.79339,
1479.569306, 1542.00497, 1592.867193, 1622.714486, 1680.581686, 1798.346515, 1837.432255, 1894.211726,
1925.755877, 1983.623077]
y = [10855.71585, 10522.85007, 10219.37359, 9878.202131, 9711.44979, 9280.193736, 8959.147562, 8801.020342,
8689.852115, 8609.350985, 8475.182435, 8321.846949, 8206.845334, 8130.177591, 7921.737165, 7842.673555,
7698.921537, 7555.169519, 7421.000969, 7363.500161, 7219.748143, 6986.550425, 6884.326768, 6763.848886,
6692.65741, 6577.655796]
if config == "RTLS" and inclination == 70:
x = [399.4367401, 425.3856612, 460.7282991, 481.3535394, 501.8804108, 529.1732942, 590.214924, 632.9544017,
698.5875098, 742.8430875, 793.709774, 861.8670389, 903.0582898, 941.2163398, 994.6272627, 1054.145764,
1096.884024, 1131.971433, 1188.41326, 1223.509789, 1300.377006, 1399.333665, 1498.229129, 1575.900339,
1617.993128, 1680.390067, 1716.233055, 1774.190281, 1820.974881, 1841.3154, 1898.770774, 1941.989524,
1999.951766]
y = [9269.349891, 9183.617486, 14177.41333, 8999.400232, 14151.87895, 8855.31827, 8680.225355, 8538.876762,
8326.381924, 8198.71984, 8055.240923, 7870.420624, 7773.764576, 7651.554481, 7499.26258, 7323.255265,
7184.118931, 7104.389122, 6981.824081, 6885.522978, 6697.852634, 6474.241933, 6274.519202, 6101.25263,
6027.567695, 5881.474544, 5813.078874, 5705.474603, 5596.644577, 5550.439502, 5431.887008, 5342.516666,
5225.797888]
if config == "ASDS" and inclination == 70:
x = [400.899151, 492.8361803, 598.4953749, 699.0547544, 741.397745, 797.5589351, 820.747046, 861.9453283,
900.0903246, 942.818261, 995.2038927, 1022.167562, 1074.055356, 1096.564536, 1135.096986, 1183.937517,
1251.073674, 1293.810643, 1327.375711, 1398.598975, 1446.399662, 1497.263672, 1533.367122, 1591.12662,
1621.858214, 1674.241841, 1703.734857, 1754.594852, 1797.942919, 1891.902386, 1952.913904, 1998.678066]
y = [12149.25373, 11759.672, 11399.63227, 10940.01829, 10825.11356, 10658.77529, 10606.24742, 10496.81435,
10398.32458, 10277.9482, 10142.98566, 10059.08206, 9905.87576, 9839.301516, 9730.782845, 9577.576544,
9402.483629, 9265.69229, 9183.617486, 8964.751342, 8855.31827, 8716.703046, 8636.452127, 8492.625804,
8417.585983, 8286.266297, 8220.606454, 8089.286768, 7996.273573, 7760.987552, 7640.611173, 7540.292608]
if config == "RTLS" and inclination == 90:
x = [401.6348271, 453.7177977, 502.9691165, 532.7631242, 599.6476312, 651.331114, 706.5615023, 795.7408451,
827.6629962, 900.3083227, 999.875032, 1057.198464, 1101.281434, 1149.924712, 1203.634998, 1248.73137,
1301.934955, 1355.13854, 1398.981818, 1479.026889, 1516.269398, 1594.402663, 1631.797183, 1695.134784,
1745.804866, 1801.541955, 1846.131626, 1902.882117, 1955.579001, 1998.221767]
y = [9012.973347, 8861.09762, 8728.55608, 8642.692098, 8459.119608, 8315.083815, 8151.279674, 7853.70215,
7769.07001, 7582.277363, 7160.264618, 7004.650684, 6885.925795, 6786.245162, 6678.862447, 6567.83964,
6472.677234, 6349.434118, 6263.080048, 6117.378251, 6032.746111, 5885.952286, 5803.420313, 5679.657184,
5574.094515, 5472.171938, 5366.609269, 5250.126324, 5148.203747, 5080.96016]
if config == "ASDS" and inclination == 90:
x = [403.0477166, 465.8786172, 502.3610755, 607.7548442, 698.4542894, 757.7382843, 818.5423816, 883.4000854,
908.9884763, 977.6464362, 1006.021682, 1049.597951, 1100.521383, 1125.603073, 1198.56799, 1233.530346,
1283.693726, 1312.575672, 1396.941357, 1428.103457, 1479.280239, 1507.655484, 1548.191549, 1624.196671,
1657.638924, 1699.188391, 1745.804866, 1799.768502, 1844.611524, 1898.935723, 1940.377977, 1994.594964]
y = [12108.05971, 11886.0141, 11741.32044, 11412.22816, 11101.57427, 10881.3487, 10652.0229, 10442.04552,
10348.98524, 10146.05011, 10076.88836, 9953.12523, 9816.621779, 9734.719708, 9505.39391, 9407.111425,
9265.147836, 9188.705903, 8951.189898, 8861.09762, 8738.482445, 8664.53265, 8533.489337, 8315.083815,
8205.881054, 8067.557557, 7987.475532, 7879.420725, 7769.07001, 7638.026697, 7562.158741, 7426.901359]
if config == "RTLS" and inclination == "SSO":
x = [403.2985471, 438.2847577, 498.1176581, 550.846695, 608.648206, 660.3641193, 702.9569973, 739.4647614,
794.2286706, 823.132173, 882.465983, 906.0434228, 1058.934521, 1100.382871, 1138.040832, 1197.375173,
1235.408552, 1295.393719, 1332.776272, 1391.801271, 1439.271861, 1484.911208, 1516.864772, 1590.650454,
1608.143115, 1682.692578, 1722.250931, 1743.553073, 1799.118086, 1843.969085, 1898.739609, 1947.427721,
1997.631003]
y = [8946.842299, 8835.611453, 8651.494957, 8467.378461, 8275.839958, 8099.145469, 7967.931448, 7853.656807,
7692.043439, 7608.168146, 7460.114001, 7384.184556, 6969.897626, 6839.731289, 6748.957831, 6603.198938,
6503.46917, 6350.915502, 6257.980508, 6091.048219, 5987.942981, 5865.19865, 5805.348382, 5615.880432,
5558.337823, 5380.358544, 5292.391774, 5251.476997, 5135.630831, 5022.354246, 4889.381221, 4785.04854,
4650.029776]
if config == "ASDS" and inclination == "SSO":
x = [407.8325413, 506.5385429, 557.6444064, 603.2709971, 627.6115097, 661.0728048, 703.0545918, 731.039908,
764.5012032, 819.2542458, 884.6659186, 904.4382444, 942.4634742, 995.1926321, 1016.997347, 1053.503155,
1115.56643, 1199.53465, 1300.51559, 1325.788633, 1402.355961, 1450.023093, 1500.734387, 1538.762803,
1601.550298, 1676.182593, 1699.734165, 1788.734137, 1808.003768, 1849.076346, 1899.654279, 1935.78827,
2000.152797]
y = [12100.61065, 11717.64834, 11535.98673, 11358.00745, 11290.49807, 11167.75374, 11027.06425, 10922.26507,
10799.52074, 10590.85538, 10394.46445, 10320.81785, 10185.79909, 10002.20644, 9940.310429, 9817.566099,
9623.630056, 9362.364392, 9035.218217, 8958.355784, 8729.233033, 8598.305747, 8465.856564, 8344.63413,
8149.00415, 7951.852272, 7891.241055, 7538.613025, 7485.423815, 7362.679485, 7215.386288, 7117.190823,
6934.882959]
if apogeealt >= 400:
with warnings.catch_warnings():
warnings.simplefilter('ignore', np.RankWarning)
coeff = numpy.polyfit(x, y, 30)
p = np.poly1d(coeff)
masslim = p(apogeealt)
if masslim > y[0]:
masslim = y[0]
return masslim
# print(AtlasMass(5000, 541, 0))
# print(AntaresMass(5000, 233, 0))
# print(Falcon9MassCirc(1800, "ASDS", "SSO"))
# You need to add inclination information for the models!!! Currently not using it unless Falcon 9
def ParkingOrbitAlgorithm(testmass, circalt, inclination):
if circalt <= 2000 and circalt >= 400:
launchvehiclelist = []
Atlasconfigs = [551, 541, 531, 431, 521, 421, 511, 411, 501, 401]
Antaresconfigs = [232, 233]
for i in Atlasconfigs:
if AtlasMass(circalt, i, inclination) >= testmass:
launchvehiclelist.append("Atlas V " + str(i))
for i in Antaresconfigs:
if AntaresMass(circalt, i, inclination) >= testmass:
launchvehiclelist.append("Antares " + str(i))
if Falcon9MassCirc(circalt, "ASDS", inclination) >= testmass:
launchvehiclelist.append("Falcon 9 ASDS")
if Falcon9MassCirc(circalt, "RTLS", inclination) >= testmass:
launchvehiclelist.append("Falcon 9 RTLS")
return launchvehiclelist
else:
print("Not Achievable")
# ComponentsLoc = SCDesignerPath + "\\Component_Lists.xlsx"
# masses = []
# masses.append(Falcon9MassCirc(1000, "RTLS", 28.5))
# masses.append(Falcon9MassCirc(1000, "RTLS", 38))
# masses.append(Falcon9MassCirc(1000, "RTLS", 51.6))
#
#
# masses.append(Falcon9MassCirc(1000, "RTLS", 60))
# masses.append(Falcon9MassCirc(1000, "RTLS", 70))
# masses.append(Falcon9MassCirc(1000, "RTLS", 90))
#
# inclinations = [28.5, 38, 51.6, 60, 70, 90]
#
# # import matplotlib
# from matplotlib import pyplot as plt
#
# plt.plot(inclinations, masses)
# plt.show()
def CalculateAsmMass():
Vol = []
inertiafiles = []
totalMass = 0
densarray = []
skipheader = 1
with open(SCDesignerPath + str(App.ActiveDocument.Label) +
"\\" + str(App.ActiveDocument.Label) + "Inertia.csv", 'r') as f:
InertiaRows = csv.reader(f, delimiter=',')
for row in InertiaRows:
if skipheader == 0:
Vol.append(float(row[17])) # m^3
inertiafiles.append(row[0])
skipheader = 0
for filename in os.listdir(SCDesignerPath + "\\STRUCTURAL"):
for i in range(0, len(inertiafiles)):
if (inertiafiles[i] + ".csv") == filename:
with open(SCDesignerPath + "\\STRUCTURAL\\" + filename, 'r') as k:
matdata = csv.reader(k, delimiter=',')
for row in matdata:
densarray.append(27679.90471* float(row[15])) # Convert from MIL-HDBK 5J lbs/in^3 to kg/m^3
# print(matdata)
try:
for i in range(0, len(Vol)):
mass = Vol[i] * densarray[i]
totalMass = totalMass + mass
print(str(totalMass) + " kg") # kg
return totalMass
except:
pass
class Explore():
"""My new command"""
def GetResources(self):
return {'Pixmap' : SCDesignerPath + '\\Icons\\EXP.jpg',
'MenuText': "Explore",
'ToolTip' : "Explore Opportunities"}
def Activated(self):
layout = [[sg.Text('Opportunities', size=(30, 1))],
[sg.Listbox(values=('Lunar ISRU Challenge', 'Mars Sample Return Challenge', 'Asteroid Mining Challenge', 'Robotic Servicing Challenge'), size=(40, 10)), sg.Button('OK', key='-OPPORTUNITY-',)],
[sg.Text('Create an Opportunity'), sg.Button('OK',key='-CREATE-',)],
[sg.Text('Explore the Solar System'), sg.Button('OK',key='-EXPLORE-',)],
[sg.Cancel()]]
window = sg.Window('Explore Opportunities', layout, default_element_size=(80, 80), grab_anywhere=False)
event, values = window.read()
print(values)
window.close()
if event == "Cancel":
window.close()
elif event == "-EXPLORE-":
print("Explore")
window.close()
elif event == "-OPPORTUNITY-":
print("Opportunity")
window.close()
elif event == "-CREATE-":
print("Create")
window.close()
print(values)
return
class Payload():
"""My new command"""
def GetResources(self):
return {'Pixmap' : 'C:\\Users\\' + username + '\\AppData\\Roaming\\FreeCAD\\Mod\\SpacecraftDesigner\\Icons\\PLD.jpg',
'Accel' : "Shift+Y", # a default shortcut (optional)
'MenuText': "Payload",
'ToolTip' : "Select payload and payload characteristics"}
def Activated(self):
layout1 = [
[sg.Text('Name your mission', size=(25, 1)), sg.InputText('', size=(20, 1))],
[sg.Submit(tooltip='Click to submit'), sg.Cancel()]]
# https://web.archive.org/web/20180925131401/https://engineer.jpl.nasa.gov/practices/2404.pdf
window1 = sg.Window('Payload', layout1, default_element_size=(40, 1), grab_anywhere=False)
event1, values1 = window1.read()
# vehicle.name = values1[0]
global new_vehicle
new_vehicle.name = values1[0]
import FreeCADGui as Gui
SCDesignerPath = "C:\\Users\\" + username + "\\AppData\\Roaming\\FreeCAD\\Mod\\SpacecraftDesigner"
App.getDocument(FreeCAD.ActiveDocument.Name).saveAs(SCDesignerPath +
"/Vehicles/" + new_vehicle.name + "Assembly.FCStd")
window1.close()
if event1 == "Submit":
layout = [
[sg.Text('Target Body', size=(25, 1)), sg.InputCombo(('Sun', 'Mercury', 'Venus', 'Earth', 'Moon', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Pluto', 'Planetary Moon', 'Asteroid', 'Comet', 'Other Spacecraft'), size=(20, 1))],
[sg.Text('Select Scientific Payload', size=(25, 1)), sg.InputCombo(('Optical Telescope', 'Radio Telescope', 'X-ray Telescope', 'Infrared Telescope', 'Mass Spectrometer', 'Magnetometer', 'Radar Altimeter', 'Gas Chromatograph', 'X-ray Powder Diffraction', 'Fizeau Interferometer'), size=(25, 1)), sg.Button('Add', key="-INSTRUMENT-")],
[sg.Checkbox('Human Payload', default=True, key="-HUMAN-")],
[sg.Submit(tooltip='Click to submit'), sg.Cancel()]]
# https://web.archive.org/web/20180925131401/https://engineer.jpl.nasa.gov/practices/2404.pdf
window = sg.Window('Payload', layout, default_element_size=(40, 1), grab_anywhere=False)
event, values = window.read()
new_vehicle.destination = values[0]
window.close()
if event == "Quit":
window.close()
elif event == "-INSTRUMENT-":
window.close()
inst_type = values[1]
if inst_type == "Optical Telescope":
# https://en.wikipedia.org/wiki/List_of_space_telescopes
layout = [sg.Text('Telescope Type', size=(25, 1)), sg.InputCombo(('Cassegrain telescope', 'Schmidt–Cassegrain telescope'), size=(25, 1)),sg.Button('Add', key="-TELESCOPE-")],
window = sg.Window('Optical Telescope', layout, default_element_size=(40, 1), grab_anywhere=False)
event, values = window.read()
window.close()
# All this in mini SMAD starting pg 250
def GroundResNadir(altitude, centerwavelength, opticalaperture):
groundres = 1.22 * altitude * centerwavelength / opticalaperture
return groundres
# On page 252
# Include slant range in this as well later
def GroundResToAperture(groundres, wavelength, altitude):
Aperture = 1.22 * (altitude * wavelength) / groundres
return Aperture
def Magnification(focallength, altitude):
magnification = focallength / altitude
return magnification
def FocalLengthForImageDia(ImageDia, opticalaperture, wavelength):
focallength = ImageDia * opticalaperture / (2.44 * wavelength)
return focallength
# will give same info as above but in another way
def NumericalAperture(focallength, opticalaperture):
numericalaperture = opticalaperture / (2 * focallength)
fnumber = 1 / (2 * numericalaperture)
return numericalaperture, fnumber
# MiniSMAD Pg 253
def DepthOfFocus(wavelength, Fnumber):
depthofFocus1 = 2 * wavelength * (Fnumber ** 2)
depthofFocus2 = -2 * wavelength * (Fnumber ** 2)
return depthofFocus1, depthofFocus2
# Refer to MiniSMAD pg 253
def CassegrainTelescope(focallength, I2, I1):
effectivefocallength = focallength * (I2 / I1)
return effectivefocallength
# https://www.lumenera.com/blog/understanding-dynamic-range-and-signal-to-noise-ratio-when-comparing-cameras#:~:text=Dynamic%20range%20quantifies%20the%20working,capacity%20and%20its%20noise%20floor.
def DynamicRange(FullWellCapacity, readnoise):
dynrange = 20 * math.log10(FullWellCapacity / readnoise)
return dynrange
# https://stackoverflow.com/questions/51413068/calculate-signal-to-noise-ratio-in-python-scipy-version-1-1
def signaltonoise(a, axis=0, ddof=0):
a = np.asanyarray(a)
m = a.mean(axis)
sd = a.std(axis=axis, ddof=ddof)
return np.where(sd == 0, 0, m / sd)
'''Design Process
- Determine Instrument requirements such as resolution, band pass, swath width, and sensitivity
- Choose a preliminary diffraction-limited aperture to meet resolution, and select a compatible preliminary modulation
transfer function
- Determine dynamic range of the target radiance and apparent temperature levels and contrasts
- Select detector candidates - by wavelength, specific detectivity, band pass, time constant, operating temperature,
size and shape
- Determine optical link budget which yields required Noise Equipment Temperature Difference with sufficient signal
to noise
- Determine alternative focal plane architectures or scanning schemes to produce desired results
- Select system F# and compatible telescope design
- Complete preliminary design and analytically check for expected Modulation Transfer Function. Iterate
- Estimate power, weight, temperature constraints and other requirements
- Iterate and document'''
else:
window.close()
return
class Schedule():
"""My new command"""
def GetResources(self):
return {'Pixmap' : 'C:\\Users\\' + username + '\\AppData\\Roaming\\FreeCAD\\Mod\\SpacecraftDesigner\\Icons\\SCH.jpg',
'Accel' : "Shift+H", # a default shortcut (optional)
'MenuText': "Mission Scheduler",
'ToolTip' : "Set Mission Schedule"}
def Activated(self):
if not exists(SCDesignerPath + "\\Schedule.png"):
from PIL import Image
img = Image.new("RGB", (1, 1), (12, 9, 60))
img.save(SCDesignerPath + "\\Schedule.png", "PNG")
ActivitiesList = ['Solar Panel Deploy', 'Collect Sample']
import io
import FreeSimpleGUI as sg
from PIL import Image
import time
filename = SCDesignerPath + "\\Schedule.png"
image = Image.open(filename)
image.thumbnail((900, 900))
bio = io.BytesIO()
image.save(bio, format="PNG")
layout = [
[sg.Image(data=bio.getvalue(), key="-IMAGE-")],
[sg.Text('Select Event'), sg.InputCombo(ActivitiesList)],
[sg.Text('Start Date (mm-dd-yyyy)'), sg.InputText('', size=(20, 1))],
[sg.Text('Stop Date (mm-dd-yyyy)'), sg.InputText('', size=(20, 1))],
[sg.Button('Add Event'), sg.Button('Remove Event'), sg.Cancel(), sg.Button("Done", key="-DONE-")]]
window = sg.Window("Set Mission Schedule", layout)
if not exists(SCDesignerPath + "\\schedule.csv"):
with open(SCDesignerPath + "\\schedule.csv", "w+") as f:
f.write("task,start,end,milestone")
while True:
event, values = window.read()
print(event)
if event == "Cancel":
window.close()
break
elif event == "-DONE-":
window.close()
break
elif event == "Remove Event":
MissionEvent = values[0]
output = []
with open(SCDesignerPath + "\\schedule.csv",
'r') as f:
for row in csv.reader(f):
if row[0] != MissionEvent:
output.append(row)
f.close()
with open(SCDesignerPath + "\\schedule.csv",
'w+') as f:
header = 1
for row in output:
if header == 0:
f.write("\n")
f.write(row[0] + "," + row[1] + "," + row[2])
header = 0
f.close()
elif event == "Add Event":
with open(SCDesignerPath + "\\schedule.csv",
"a") as f:
f.write("\n" + values[0] + ',' + values[1] + ',' + values[2])
f.close()
if event == "Add Event" or event == "Remove Event":
import matplotlib.dates as mdates
start = []
stop = []
task = []
duration = []
pasttime = []
header = 1
with open(SCDesignerPath + "\\schedule.csv", "r") as f:
for row in csv.reader(f):
if header == 1:
header = 0
continue
start.append(datetime.strptime(row[1], '%m-%d-%Y')) # %H:%M:%S'))
stop.append(datetime.strptime(row[2], '%m-%d-%Y'))
task.append(row[0])
for i in range(0, len(start)):
duration.append(stop[i] - start[i] + timedelta(days=1))
pasttime.append(start[i] - start[0])
nrow = len(start)
plt.figure(num=1, figsize=[12, 8], dpi=100)
bar_width = 0.5
for i in range(nrow):
i_rev = nrow - 1 - i
plt.broken_barh([(start[i_rev], duration[i_rev])], (i - bar_width / 2, bar_width), color="b")
plt.broken_barh([(start[0], pasttime[i_rev])], (i - bar_width / 2, bar_width), color="w")
y_pos = np.arange(nrow)
plt.yticks(y_pos, labels=reversed(task))
plt.savefig(SCDesignerPath + "\\Schedule.png")
image = Image.open(SCDesignerPath + "\\Schedule.png")
image.thumbnail((1200, 1200))
bio = io.BytesIO()
image.save(bio, format="PNG")
window["-IMAGE-"].update(data=bio.getvalue())
else:
window.close()
break
class LaunchVehicle():
"""My new command"""
def GetResources(self):
return {'Pixmap' : 'C:\\Users\\' + username + '\\AppData\\Roaming\\FreeCAD\\Mod\\SpacecraftDesigner\\Icons\\Launch.jpg',
'Accel' : "Shift+W", # a default shortcut (optional)
'MenuText': "Launch Vehicle",
'ToolTip' : "Select a Launch Vehicle"}
def Activated(self):
layout = [
[sg.Text('Select Launch Vehicle', size=(25, 1)), sg.InputCombo(('Alpha','Antares 230', 'Antares 231', 'Antares 232','Antares 233', 'Electron', 'Electron Expanded','Falcon 9', 'Falcon Heavy', 'LauncherOne', 'Starship'), size=(20, 1)), sg.Button("OK", key="-LV-")],
[sg.Text('Select Payload Adapter', size=(25, 1)), sg.InputCombo(('609.6 mm diameter', '937 mm diameter','1194 mm diameter','1575 mm diameter','1666 mm diameter')),sg.Button("OK", key="-ADAPTER-")],
[sg.Text('Payload Fairing Fit Check', size=(25, 1)), sg.Button("OK", key="-FIT-")],
[sg.Text('Run In-Flight Loads Test', size=(25, 1)), sg.Button("OK")],
[sg.Text('Run Acoustics Test', size=(25, 1)), sg.Button("OK")],
[sg.Text('Run Vibration Test', size=(25, 1)), sg.Button("OK")],
[sg.Cancel()]
]
# https://web.archive.org/web/20180925131401/https://engineer.jpl.nasa.gov/practices/2404.pdf
window = sg.Window('Launch Vehicle', layout, default_element_size=(40, 1), grab_anywhere=False)
event, values = window.read()
window.close()
if event == "Quit":
window.close()
elif event == "-FIT-":
window.close()
import FreeCAD as App
if App.ActiveDocument.Name == "Unnamed":
layout = [[sg.Text('Please name your project first', size=(25, 1)), sg.Button("OK")],
[sg.Cancel()]]
# https://web.archive.org/web/20180925131401/https://engineer.jpl.nasa.gov/practices/2404.pdf
window = sg.Window('Launch Vehicle', layout, default_element_size=(40, 1), grab_anywhere=False)
window.close()
pass
launchvehicle = values[0].replace(" ", "")
launchvehicle = launchvehicle
with open(
SCDesignerPath + "\\AssemblyInclude.txt",
'w+') as f:
f.write("LaunchVehicles\\" + launchvehicle + "Fairing.fcstd")
import FreeCADGui as Gui
Gui.activateWorkbench("A2plusWorkbench") # A2p_import_part.py was modified
Gui.runCommand('a2p_ImportPart', 0)
os.remove(SCDesignerPath + "\\AssemblyInclude.txt")
fairingname = "b_" + launchvehicle + "_001_"
Gui.Selection.addSelection('Assembly2', fairingname, 'Edge29', 0.00, 0.00, 0.00)
Gui.activateWorkbench("SpacecraftDesigner")
class GNC():
"""My new command"""
def GetResources(self):
return {'Pixmap' : 'C:\\Users\\' + username + '\\AppData\\Roaming\\FreeCAD\\Mod\\SpacecraftDesigner\\Icons\\GNC.jpg',
'Accel' : "Shift+G", # a default shortcut (optional)
'MenuText': "Guidance, Navigation and Control",
'ToolTip' : "Define Spacecraft Guidance, Navigation and Control Scheme"}
def Activated(self):
import os
import FreeSimpleGUI as sg
layout = [
# [sg.Text('Expected Loiter Time at Mission Destination (optional, for return planning)'), sg.InputText('', size=(20, 1)), sg.Radio('Days', "RADIO1"), sg.Radio('Months', "RADIO1"), sg.Radio('Years', "RADIO1")],
# [sg.Text('Select Launch Vehicle', size=(25, 1)), sg.InputCombo('placeholder', 'placeholder2'), sg.Button('OK', key="-LAUNCH-")],
[sg.Text('Open Trajectory Designer'), sg.Button('OK', key="-TRAJ-")],
[sg.Text('Open Control Systems Designer'), sg.Button('OK', key="-CONTROLLER-")],
# [sg.Text('Select Landing Site'), sg.Button('OK', key="-LDG-")],
[sg.Text('Set Rocket-Powered Landing Sequence'), sg.Button('OK', key="-SEQUENCE-")],
[sg.Text('Add Vehicle Surface Path'), sg.Button('OK', key="-SURF-")],
[sg.Text('Add Robotic Arm'), sg.Button('OK', key="-ROBO-")],
[sg.Text('Add Spring/Damper/Actuator'), sg.InputCombo(('Linear Spring', 'Linear Damper', 'Linear Actuator', 'Rotary Spring', 'Rotary Damper', 'Rotary Actuator')), sg.Button('OK', key="-ACTUATOR-")],
[sg.Text('Add Sensor'), sg.InputCombo(('Angular Position Sensor', 'Angular Velocity Sensor', 'Angular Acceleration Sensor', 'Linear Position Sensor', 'Linear Velocity Sensor', 'Linear Acceleration Sensor')), sg.Button('OK')],
[sg.Text('Calculate Moment of Inertia'), sg.Button('OK', key='-INERTIA-',)],
[sg.Text('Implement Attitude Stabilization Method'), sg.InputCombo(('Spin Stabilization', '3-Axis Stabilization (Control Moment Gyros)',
'3-Axis Stabilization (Reaction Control Thrusters)', 'Magnetorquer', 'Solar Pressure Stabilization', 'Aerodynamic Stabilization', 'Yo-Yo Despin')),
sg.Button('OK', key='-STABILIZATION-',)],[sg.Cancel()]]
window = sg.Window('Guidance, Navigation and Control', layout, default_element_size=(40, 1), grab_anywhere=False)
event, values = window.read()
if event == "Exit" or event == sg.WIN_CLOSED:
window.close()
if event == "-LAUNCH-":
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import numpy as np
import numpy
import warnings
def AtlasMass(apogeealt, config, inclination):
x = [5000, 7500, 10000, 12500, 15000, 17500, 20000, 22500, 25000, 27500, 30000, 35000, 35786, 40000,
45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000, 105000,
110000, 115000, 120000, 125000, 130000, 135000, 140000, 145000, 150000]
if config == 401:
y = [7827, 7135, 6625, 6238, 5933, 5688, 5487, 5318, 5176, 5054, 4948, 4774, 4750, 4636, 4525, 4433,
4356, 4290, 4234, 4184, 4141, 4103, 4069, 4038, 4011, 3986, 3963, 3942, 3923, 3905, 3889, 3874,
3860, 3847, 3835, 3823]
if config == 411:
y = [9729, 8869, 8242, 7766, 7394, 7095, 6847, 6642, 6468, 6321, 6191, 5978, 5950, 5810, 5674, 5562,
5467, 5387, 5318, 5258, 5205, 5158, 5117, 5079, 5046, 5015, 4987, 4962, 4939, 4917, 4897, 4879,
4862, 4846, 4831, 4817]
if config == 421:
y = [11263, 10260, 9529, 8977, 8545, 8199, 7915, 7680, 7481, 7311, 7164, 6922, 6890, 6732, 6579,
6452, 6348, 6258, 6181, 6113, 6054, 6001, 5955, 5913, 5875, 5841, 5810, 5781, 5755, 5731, 5709,
5688, 5669, 5651, 5634, 5619]
if config == 431:
y = [12573, 11453, 10637, 10021, 9541, 9156, 8841, 8579, 8358, 8169, 8005, 7736, 7700, 7525, 7355,
7215, 7097, 6997, 6912, 6837, 6771, 6713, 6662, 6615, 6573, 6536, 6501, 6470, 6441, 6414, 6389,
6367, 6348, 6329, 6310, 6293]
if config == 501:
y = [6392, 5783, 5335, 5002, 4773, 4570, 4401, 4262, 4115, 4021, 3940, 3796, 3775, 3682, 3583, 3506,
3442, 3382, 3337, 3295, 3253, 3223, 3195, 3168, 3145, 3123, 3104, 3085, 3069, 3054, 3040, 3027,
3014, 3003, 2992, 2982]