Browse Source

Monitor time, fuel directly

Petra Lamborn 6 years ago
parent
commit
bdc27103a0
2 changed files with 13 additions and 12 deletions
  1. 7
    3
      analysis.rmd
  2. 6
    9
      monitor.py

+ 7
- 3
analysis.rmd View File

@@ -16,12 +16,14 @@ flight <- read.csv("flight.csv", header=T)
16 16
 ```
17 17
 
18 18
 ```{r graph}
19
-baseg <- ggplot(flight, aes(x=timepoint / 10)) + xlab("Time (seconds)") + theme_classic()
19
+baseg <- ggplot(flight, aes(x=mission_time)) + xlab("Time (seconds)") + theme_classic()
20 20
 alt <- baseg + geom_line(aes(y=current_altitude)) + ylab("Altitude (m)") + ggtitle("Altitude")
21 21
 vspd <- baseg + geom_line(aes(y=v_speed)) + ylab("Vertical speed (m/s)") + ggtitle("Vertical speed")
22 22
 hspd <- baseg + geom_line(aes(y=h_speed)) + ylab("Horizontal speed (m/s)") + ggtitle("Horizontal speed")
23 23
 mass <- baseg + geom_line(aes(y=mass)) + ylab("Vessel mass (kg)") + ggtitle("Mass")
24
-fuel <- baseg + geom_line(aes(y=fuel)) + ylab("Fuel (kg)") + ggtitle("Fuel")
24
+ec <- baseg + geom_line(aes(y=electric_charge)) + ylab("Electric charge") + ggtitle("Electric charge")
25
+lf <- baseg + geom_line(aes(y=liquid_fuel)) + ylab("Liquid fuel (litres)") + ggtitle("Liquid fuel")
26
+ox <- baseg + geom_line(aes(y=oxidizer)) + ylab("Oxidizer (litres)") + ggtitle("Oxidizer")
25 27
 at <- baseg + geom_line(aes(y=available_thrust)) + ylab("Available thrust (Newtons)") + ggtitle("Available thrust")
26 28
 thrust <- baseg + geom_line(aes(y=current_thrust)) + ylab("Current thrust (Newtons)") + ggtitle("Current thrust")
27 29
 g_force <- baseg + geom_line(aes(y=g_force)) + ylab("G-force (m/s²)") + ggtitle("G-force")
@@ -32,7 +34,9 @@ alt
32 34
 vspd
33 35
 hspd
34 36
 mass
35
-fuel
37
+ec
38
+lf
39
+ox
36 40
 at
37 41
 thrust
38 42
 g_force

+ 6
- 9
monitor.py View File

@@ -42,8 +42,7 @@ button.rect_transform.position = (0, 0)
42 42
 button_clicked = conn.add_stream(getattr, button, 'clicked')
43 43
 
44 44
 f = open(datafile, 'w')
45
-f.write('timepoint, current_altitude, v_speed, h_speed, mass, fuel, available_thrust, current_thrust, g_force\n')
46
-timepoint = 0
45
+f.write('mission_time, current_altitude, v_speed, h_speed, mass, electric_charge, liquid_fuel, oxidizer, available_thrust, current_thrust, g_force\n')
47 46
 
48 47
 vessel = conn.space_center.active_vessel
49 48
 body = vessel.orbit.body
@@ -57,14 +56,12 @@ while button_clicked() == False:
57 56
     v_speed = vessel.flight(r_frame).vertical_speed
58 57
     h_speed = vessel.flight(r_frame).horizontal_speed
59 58
     c_thrust = vessel.thrust
59
+    e_charge = vessel.resources.amount('ElectricCharge')
60
+    lf = vessel.resources.amount('LiquidFuel')
61
+    ox = vessel.resources.amount('Oxidizer')
60 62
     g_force = vessel.flight(r_frame).g_force
61
-    f.write('{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}\n'.format(timepoint,
62
-                                                              current_altitude,
63
-                                                              v_speed, h_speed,
64
-                                                              vm, vm -
65
-                                                              dry_mass, at,
66
-                                                              c_thrust, g_force))
67
-    timepoint = timepoint + 1
63
+    timept = vessel.met
64
+    f.write('{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}\n'.format(timept, current_altitude, v_speed, h_speed, vm, e_charge, lf, ox, at, c_thrust, g_force))
68 65
     time.sleep(0.1)
69 66
 
70 67
 f.close()