2021-08-02 01:34:19 +00:00
|
|
|
@lazyglobal off.
|
|
|
|
|
2021-08-19 02:32:07 +00:00
|
|
|
RunOncePath("/lib/ui").
|
|
|
|
RunOncePath("/lib/navigation").
|
|
|
|
RunOncePath("/lib/throttle").
|
|
|
|
RunOncePath("/lib/stabilize_rocket").
|
|
|
|
RunOncePath("/lib/launch_rocket").
|
|
|
|
RunOncePath("/lib/sensors").
|
2021-08-25 05:11:29 +00:00
|
|
|
RunOncePath("/lib/systems").
|
2021-08-19 02:32:07 +00:00
|
|
|
RunOncePath("/lib/reentry").
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-01 21:46:28 +00:00
|
|
|
clearguis().
|
|
|
|
|
2021-08-01 05:23:39 +00:00
|
|
|
global done is false.
|
|
|
|
on AG9 {
|
|
|
|
set done to true.
|
|
|
|
return true.
|
|
|
|
}
|
2021-07-21 09:24:46 +00:00
|
|
|
|
2021-08-08 04:15:28 +00:00
|
|
|
// Top-level menu structure.
|
2021-08-02 01:32:00 +00:00
|
|
|
local iface is gui(250, 300).
|
|
|
|
set iface:X to 200.
|
2021-09-14 03:51:18 +00:00
|
|
|
set iface:Y to 750.
|
2021-08-02 01:32:00 +00:00
|
|
|
local top is iface:AddVLayout().
|
2021-09-14 03:51:18 +00:00
|
|
|
local rows is list(MakeRow(top), MakeRow(top), MakeRow(top), MakeRow(top)).
|
2021-08-08 04:15:28 +00:00
|
|
|
local stk is iface:AddStack().
|
2021-07-19 04:54:32 +00:00
|
|
|
|
2021-08-08 04:15:28 +00:00
|
|
|
// Buttons and menus.
|
2021-08-24 10:10:21 +00:00
|
|
|
AddStockButtons(rows[0], "rocket").
|
2021-07-19 04:54:32 +00:00
|
|
|
|
2021-08-09 17:51:24 +00:00
|
|
|
MakeMenu(
|
|
|
|
stk,
|
2021-08-25 05:11:29 +00:00
|
|
|
MakeButton(rows[0], "Config"),
|
|
|
|
List(
|
|
|
|
List("Torque Epsilon Max", "SCALAR", "0.001"),
|
|
|
|
List("Max Stopping Time", "SCALAR", "2.0")
|
|
|
|
),
|
|
|
|
"Apply",
|
|
|
|
{
|
|
|
|
parameter options.
|
|
|
|
set STEERINGMANAGER:TORQUEEPSILONMAX to options["Torque Epsilon Max"]:TEXT:ToNumber().
|
|
|
|
set STEERINGMANAGER:MAXSTOPPINGTIME to options["Max Stopping Time"]:TEXT:ToNumber().
|
|
|
|
}
|
|
|
|
).
|
|
|
|
|
|
|
|
MakeToggle(rows[0], "Solar", {
|
|
|
|
parameter d.
|
|
|
|
SolarPanels(d).
|
|
|
|
}).
|
|
|
|
|
|
|
|
MakeButton(rows[0], "Ant", {
|
|
|
|
Antennas().
|
|
|
|
}).
|
|
|
|
|
|
|
|
MakeMenu(
|
|
|
|
stk,
|
|
|
|
MakeButton(rows[1], "Sensors"),
|
2021-08-10 22:08:00 +00:00
|
|
|
List(
|
2021-08-09 17:51:24 +00:00
|
|
|
List("Pressure", "RO", "-1"),
|
|
|
|
List("Temperature", "RO", "-1"),
|
|
|
|
List("Acceleration", "RO", "-1"),
|
|
|
|
List("Gravity", "RO", "-1"),
|
|
|
|
List("Light", "RO", "-1")
|
|
|
|
),
|
|
|
|
"Refresh",
|
|
|
|
refreshSensors@,
|
|
|
|
refreshSensors@
|
|
|
|
).
|
|
|
|
|
2021-08-08 04:15:28 +00:00
|
|
|
MakeMenu(
|
|
|
|
stk,
|
2021-08-25 05:11:29 +00:00
|
|
|
MakeButton(rows[1], "Ground"),
|
2021-08-08 04:15:28 +00:00
|
|
|
List(
|
2021-08-10 22:08:00 +00:00
|
|
|
List("Burn Distance", "RO", "-1"),
|
|
|
|
List("Stopping Time", "RO", "-1"),
|
|
|
|
List("Stopping Distance", "RO", "-1"),
|
|
|
|
List("Stopping dV", "RO", "-1")
|
2021-08-08 04:15:28 +00:00
|
|
|
),
|
2021-08-10 22:08:00 +00:00
|
|
|
"",
|
|
|
|
{ parameter options. },
|
2021-08-08 04:15:28 +00:00
|
|
|
{
|
|
|
|
parameter options.
|
2021-08-10 22:08:00 +00:00
|
|
|
set options["Burn Distance"]:TEXT to TargetBurnDistance():TOSTRING.
|
|
|
|
set options["Stopping dV"]:TEXT to SHIP:VELOCITY:SURFACE:MAG:TOSTRING.
|
|
|
|
set options["Stopping Time"]:TEXT to BurnTime(SHIP:VELOCITY:SURFACE:MAG):TOSTRING.
|
|
|
|
set options["Stopping Distance"]:TEXT to StoppingDistance():TOSTRING.
|
2021-08-02 01:37:42 +00:00
|
|
|
}
|
2021-08-08 04:15:28 +00:00
|
|
|
).
|
2021-08-17 02:52:16 +00:00
|
|
|
|
2021-08-25 05:11:29 +00:00
|
|
|
MakeButton(rows[1], "Hover", { Hover(). }).
|
|
|
|
MakeButton(rows[1], "Land", { Land(). }).
|
2021-08-08 04:15:28 +00:00
|
|
|
|
|
|
|
MakeMenu(
|
|
|
|
stk,
|
2021-08-25 05:11:29 +00:00
|
|
|
MakeButton(rows[2], "Launch"),
|
2021-08-08 04:15:28 +00:00
|
|
|
List(
|
|
|
|
List("Target Apoapsis", "SCALAR", "80000"),
|
2021-09-14 03:51:18 +00:00
|
|
|
List("Kick Angle", "SCALAR", "30"),
|
|
|
|
List("Kick Time", "SCALAR", "45"),
|
|
|
|
List("Kick Start", "SCALAR", "100"),
|
2021-08-21 01:20:15 +00:00
|
|
|
List("Atmo TWR", "SCALAR", "2.0"),
|
2021-08-12 23:14:20 +00:00
|
|
|
List("Minimum Pitch", "SCALAR", "5"),
|
|
|
|
List("Autostage", "BOOL", true)
|
2021-08-08 04:15:28 +00:00
|
|
|
),
|
|
|
|
"Execute",
|
|
|
|
{
|
|
|
|
parameter options.
|
|
|
|
Launch(
|
|
|
|
options["Target Apoapsis"]:TEXT:ToNumber(),
|
|
|
|
options["Atmo TWR"]:TEXT:ToNumber(),
|
2021-08-12 23:14:20 +00:00
|
|
|
options["Minimum Pitch"]:TEXT:ToNumber(),
|
2021-09-14 03:51:18 +00:00
|
|
|
options["Kick Angle"]:TEXT:ToNumber(),
|
|
|
|
options["Kick Time"]:TEXT:ToNumber(),
|
|
|
|
options["Kick Start"]:TEXT:ToNumber(),
|
2021-08-12 23:14:20 +00:00
|
|
|
options["Autostage"]:PRESSED
|
2021-08-08 04:15:28 +00:00
|
|
|
).
|
2021-07-26 19:13:03 +00:00
|
|
|
}
|
2021-08-08 04:15:28 +00:00
|
|
|
).
|
|
|
|
|
|
|
|
MakeMenu(
|
|
|
|
stk,
|
2021-08-25 05:11:29 +00:00
|
|
|
MakeButton(rows[2], "Node"),
|
2021-08-08 04:15:28 +00:00
|
|
|
List(
|
|
|
|
List("Node dV", "RO", "0"),
|
|
|
|
List("Node Burn Time", "RO", "0")
|
|
|
|
),
|
|
|
|
"Execute",
|
|
|
|
{
|
|
|
|
parameter options.
|
|
|
|
ExecNode().
|
|
|
|
},
|
|
|
|
{
|
|
|
|
parameter options.
|
|
|
|
if HASNODE {
|
|
|
|
set options["Node dV"]:TEXT to NEXTNODE:DELTAV:MAG:ToString.
|
|
|
|
set options["Node Burn Time"]:TEXT to BurnTime(NEXTNODE:DELTAV:MAG):ToString.
|
|
|
|
} else {
|
|
|
|
set options["Node dV"]:TEXT to "No Node".
|
|
|
|
set options["Node Burn Time"]:TEXT to "No Node".
|
|
|
|
}
|
|
|
|
}
|
|
|
|
).
|
|
|
|
|
|
|
|
MakeMenu(
|
|
|
|
stk,
|
|
|
|
MakeButton(rows[2], "TWR"),
|
|
|
|
List(
|
|
|
|
List("Target TWR", "SCALAR", "1.6")
|
|
|
|
),
|
|
|
|
"Lock TWR",
|
|
|
|
{
|
|
|
|
parameter options.
|
|
|
|
local done is false.
|
|
|
|
print "Locking throttle to target TWR.".
|
|
|
|
local tgt is options["Target TWR"]:TEXT:ToNumber().
|
|
|
|
lock THROTTLE to ThrottleToTWR(tgt).
|
|
|
|
wait until done.
|
|
|
|
print "Throttle unlocked.".
|
|
|
|
set done to false.
|
|
|
|
}
|
|
|
|
).
|
2021-08-01 05:23:39 +00:00
|
|
|
|
2021-08-10 22:08:00 +00:00
|
|
|
MakeMenu(
|
|
|
|
stk,
|
2021-08-25 05:11:29 +00:00
|
|
|
MakeButton(rows[2], "Reentry"),
|
2021-08-10 22:08:00 +00:00
|
|
|
List(
|
2021-08-25 05:11:29 +00:00
|
|
|
List("Retract Antennae", "BOOL", true)
|
2021-08-10 22:08:00 +00:00
|
|
|
),
|
2021-08-25 05:11:29 +00:00
|
|
|
"Execute",
|
2021-08-10 22:08:00 +00:00
|
|
|
{
|
|
|
|
parameter options.
|
2021-08-25 05:11:29 +00:00
|
|
|
PerformReentry(options["Retract Antennae"]:PRESSED).
|
2021-08-10 22:08:00 +00:00
|
|
|
}
|
|
|
|
).
|
|
|
|
|
2021-09-14 03:51:18 +00:00
|
|
|
MakeButton(
|
|
|
|
rows[3],
|
|
|
|
"Pro",
|
|
|
|
{
|
|
|
|
set done to false.
|
|
|
|
lock STEERING to SHIP:PROGRADE.
|
|
|
|
wait until done.
|
|
|
|
set done to false.
|
|
|
|
}
|
|
|
|
).
|
|
|
|
|
|
|
|
MakeButton(
|
|
|
|
rows[3],
|
|
|
|
"Ret",
|
|
|
|
{
|
|
|
|
set done to false.
|
|
|
|
lock STEERING to SHIP:RETROGRADE.
|
|
|
|
wait until done.
|
|
|
|
set done to false.
|
|
|
|
}
|
|
|
|
).
|
|
|
|
|
|
|
|
MakeButton(
|
|
|
|
rows[3],
|
|
|
|
"Srf Pro",
|
|
|
|
{
|
|
|
|
set done to false.
|
|
|
|
lock STEERING to SHIP:SRFPROGRADE.
|
|
|
|
wait until done.
|
|
|
|
set done to false.
|
|
|
|
}
|
|
|
|
).
|
|
|
|
|
|
|
|
MakeButton(
|
|
|
|
rows[3],
|
|
|
|
"Srf Ret",
|
|
|
|
{
|
|
|
|
set done to false.
|
|
|
|
lock STEERING to SHIP:SRFRETROGRADE.
|
|
|
|
wait until done.
|
|
|
|
set done to false.
|
|
|
|
}
|
|
|
|
).
|
|
|
|
|
2021-08-02 01:32:00 +00:00
|
|
|
iface:show().
|
2021-08-29 08:05:56 +00:00
|
|
|
|
|
|
|
until SHIP:STATUS <> "PRELAUNCH" {
|
|
|
|
if not CORE:MESSAGES:EMPTY {
|
|
|
|
local msg is CORE:MESSAGES:Pop().
|
|
|
|
local data is msg:CONTENT.
|
|
|
|
if data["command"] = "launch" {
|
|
|
|
Launch(
|
|
|
|
80000,
|
|
|
|
2.0,
|
|
|
|
5.0,
|
|
|
|
data["angle"],
|
|
|
|
data["time"],
|
2021-09-14 03:51:18 +00:00
|
|
|
data["start"],
|
2021-08-29 08:05:56 +00:00
|
|
|
true
|
|
|
|
).
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wait 0.001.
|
|
|
|
}
|
|
|
|
|
2021-07-18 23:32:45 +00:00
|
|
|
wait until false.
|
2021-08-09 17:51:24 +00:00
|
|
|
|
|
|
|
function refreshSensors {
|
|
|
|
parameter options.
|
|
|
|
set options["Pressure"]:TEXT to ReadSensor("PRES"):TOSTRING.
|
|
|
|
set options["Temperature"]:TEXT to ReadSensor("TEMP"):TOSTRING.
|
|
|
|
set options["Acceleration"]:TEXT to ReadSensor("ACC"):TOSTRING.
|
|
|
|
set options["Gravity"]:TEXT to ReadSensor("GRAV"):TOSTRING.
|
|
|
|
set options["Light"]:TEXT to ReadSensor("LIGHT"):TOSTRING.
|
|
|
|
}
|