@@ -226,6 +226,15 @@ def import_scenario(scn_filename):
226
226
float (line [6 ]), float (line [7 ]), float (line [8 ]),
227
227
float (line [9 ]), float (line [10 ]))
228
228
229
+ elif line [2 ] == "impulsive" :
230
+ if (line [5 ] in preset_orientations ):
231
+ new_maneuver = maneuver_impulsive (line [1 ], find_obj_by_name (line [3 ]), find_obj_by_name (line [4 ]),
232
+ line [5 ], float (line [6 ]), float (line [7 ]))
233
+ else :
234
+ line [5 ] = eval (line [5 ])
235
+ new_maneuver = maneuver_impulsive (line [1 ], find_obj_by_name (line [3 ]), find_obj_by_name (line [4 ]),
236
+ vec3 (lst = line [5 ]), float (line [6 ]), float (line [7 ]))
237
+
229
238
maneuvers .append (new_maneuver )
230
239
print ("Loading maneuver:" , new_maneuver .get_name ())
231
240
@@ -318,6 +327,8 @@ def export_scenario(scn_filename):
318
327
time_save_string = "T|" + str (sim_time ) + "\n "
319
328
scn_file .write (time_save_string )
320
329
330
+ scn_file .write ("\n " )
331
+
321
332
print ("Writing bodies..." )
322
333
for b in bodies :
323
334
body_save_string = "B|" + b .get_name () + "|" + b .get_model_path () + "|" + str (b .get_mass ()) + "|" + \
@@ -327,12 +338,16 @@ def export_scenario(scn_filename):
327
338
str (b .atmos_scale_height ) + "\n "
328
339
scn_file .write (body_save_string )
329
340
341
+ scn_file .write ("\n " )
342
+
330
343
print ("Writing vessels..." )
331
344
for v in vessels :
332
345
vessel_save_string = "V|" + v .get_name () + "|" + v .get_model_path () + "|" + str (v .get_color ()) + "|" + \
333
346
str (v .get_pos ().tolist ()) + "|" + str (v .get_vel ().tolist ()) + "\n "
334
347
scn_file .write (vessel_save_string )
335
348
349
+ scn_file .write ("\n " )
350
+
336
351
print ("Writing maneuvers..." )
337
352
for m in maneuvers :
338
353
maneuver_save_string = "M|" + m .get_name () + "|"
@@ -343,13 +358,21 @@ def export_scenario(scn_filename):
343
358
maneuver_save_string += "const_thrust|" + m .get_vessel ().get_name () + "|" + m .frame_body .get_name () + "|" + \
344
359
str (m .orientation_input ) + "|" + str (m .thrust ) + "|" + str (m .mass_init ) + "|" + str (m .mass_flow ) + "|" + \
345
360
str (m .t_start ) + "|" + str (m .duration ) + "\n "
361
+
362
+ elif m .get_type () == "impulsive" :
363
+ maneuver_save_string += "impulsive|" + m .get_vessel ().get_name () + "|" + m .frame_body .get_name () + "|" + \
364
+ str (m .orientation_input ) + "|" + str (m .delta_v ) + "|" + str (m .t_perform ) + "\n "
346
365
scn_file .write (maneuver_save_string )
347
366
367
+ scn_file .write ("\n " )
368
+
348
369
print ("Writing surface points..." )
349
370
for s in surface_points :
350
371
sp_save_string = "S|" + s .get_name () + "|" + s .get_body ().get_name () + "|" + str (s .get_color ()) + "|" + str (s .get_gpos ()) + "\n "
351
372
scn_file .write (sp_save_string )
352
373
374
+ scn_file .write ("\n " )
375
+
353
376
print ("Writing barycenters..." )
354
377
for bc in barycenters :
355
378
bc_save_string = "C|" + bc .get_name () + "|"
@@ -358,18 +381,24 @@ def export_scenario(scn_filename):
358
381
bc_save_string = bc_save_string [:- 1 ]+ "\n "
359
382
scn_file .write (bc_save_string )
360
383
384
+ scn_file .write ("\n " )
385
+
361
386
print ("Writing radiation pressures..." )
362
387
for rp in radiation_pressures :
363
388
rp_save_string = "R|" + rp .get_name () + "|" + rp .vessel .get_name () + "|" + rp .body .get_name () + "|" + str (rp .get_area ()) + \
364
389
"|" + rp .orientation_frame .get_name () + "|" + str (rp .direction_input ) + "|" + str (rp .mass ) + "|" + str (rp .mass_auto_update ) + "\n "
365
390
scn_file .write (rp_save_string )
366
391
392
+ scn_file .write ("\n " )
393
+
367
394
print ("Writing atmospheric drags..." )
368
395
for ad in atmospheric_drags :
369
396
ad_save_string = "A|" + ad .get_name () + "|" + ad .vessel .get_name () + "|" + ad .body .get_name () + "|" + str (ad .get_area ()) + \
370
397
"|" + str (ad .get_drag_coeff ()) + "|" + str (ad .get_mass ()) + "|" + str (ad .mass_auto_update ) + "\n "
371
398
scn_file .write (ad_save_string )
372
399
400
+ scn_file .write ("\n " )
401
+
373
402
print ("Scenario export complete!" )
374
403
time .sleep (2 )
375
404
@@ -402,6 +431,17 @@ def create_maneuver_const_thrust(mnv_name, mnv_vessel, mnv_frame, mnv_orientatio
402
431
403
432
maneuvers .append (new_maneuver )
404
433
434
+ def create_maneuver_impulsive (mnv_name , mnv_vessel , mnv_frame , mnv_orientation , mnv_deltav , mnv_t_perform ):
435
+ global maneuvers
436
+
437
+ if find_maneuver_by_name (mnv_name ):
438
+ print ("A maneuver with this name already exists. Please pick another name for the new maneuver.\n " )
439
+ input ("Press Enter to continue..." )
440
+ return
441
+
442
+ new_maneuver = maneuver_impulsive (mnv_name , mnv_vessel , mnv_frame , mnv_orientation , mnv_deltav , mnv_t_perform )
443
+ maneuvers .append (new_maneuver )
444
+
405
445
def delete_maneuver (mnv_name ):
406
446
global maneuvers
407
447
@@ -1199,6 +1239,15 @@ def main(scn_filename=None, start_time=0):
1199
1239
1200
1240
float (command [6 ]), float (command [7 ]), float (command [8 ]),
1201
1241
float (command [9 ]), float (command [10 ]))
1242
+
1243
+ elif len (command ) == 8 and command [2 ] == "impulsive" :
1244
+ # name, type, vessel, frame, orientation, delta_v, perform_time
1245
+ if (not command [5 ] in preset_orientations ):
1246
+ create_maneuver_impulsive (command [1 ], find_obj_by_name (command [3 ]), find_obj_by_name (command [4 ]),
1247
+ eval (command [5 ]), float (command [6 ]), float (command [7 ]))
1248
+ else :
1249
+ create_maneuver_impulsive (command [1 ], find_obj_by_name (command [3 ]), find_obj_by_name (command [4 ]),
1250
+ command [5 ], float (command [6 ]), float (command [7 ]))
1202
1251
else :
1203
1252
print ("Wrong syntax for command 'create_maneuver'.\n " )
1204
1253
time .sleep (2 )
@@ -1544,6 +1593,7 @@ def main(scn_filename=None, start_time=0):
1544
1593
print ("Maneuver types: const_accel, const_thrust" )
1545
1594
print ("const_accel params: <vessel> <frame_of_reference> <orientation> <acceleration> <start_time> <duration>" )
1546
1595
print ("const_thrust params: <vessel> <frame_of_reference> <orientation> <thrust> <initial_mass> <mass_flow> <start_time> <duration>" )
1596
+ print ("impulsive params: <vessel> <frame_of_reference> <orientation> <delta_v> <perform_time>" )
1547
1597
input ("Press Enter to continue..." )
1548
1598
elif command [1 ] == "delete_maneuver" :
1549
1599
print ("\n 'delete_maneuver' command removes a maneuver from the simulation.\n " )
@@ -1952,7 +2002,7 @@ def main(scn_filename=None, start_time=0):
1952
2002
# do the actual drawing
1953
2003
1954
2004
# drawOrigin() -- maybe it'll be useful for debugging one day
1955
- drawScene (bodies , vessels , surface_points , barycenters , projections , maneuvers , get_active_cam (), show_trajectories , draw_mode , labels_visible , scene_lock )
2005
+ drawScene (bodies , vessels , surface_points , barycenters , projections , maneuvers , get_active_cam (), show_trajectories , draw_mode , labels_visible , scene_lock , point_size )
1956
2006
glfw .swap_buffers (window )
1957
2007
1958
2008
cycle_dt = time .perf_counter () - cycle_start
0 commit comments