Add sensor button, fix sensor code.
This commit is contained in:
parent
8e012799eb
commit
224a076b8b
|
@ -45,3 +45,22 @@ function CreateCircularizationNode {
|
||||||
|
|
||||||
return n.
|
return n.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function PredictGeo {
|
||||||
|
// parameter t.
|
||||||
|
|
||||||
|
// local pos is PositionAt(SHIP,t).
|
||||||
|
// local rDir is VDOT(SHIP:BODY:NORTH:FOREVECTOR,SHIP:BODY:ANGULARVEL). //the number of radians the body will rotate in one second (negative if rotating counter clockwise when viewed looking down on north
|
||||||
|
// local dT is t - TIME:SECONDS.
|
||||||
|
// local geoPos is SHIP:BODY:GeoPositionOf(pos).
|
||||||
|
// local drift is rDir * dT * CONSTANT:RADTODEG.
|
||||||
|
// local long is Mod(geoPos:LNG + drift, 360).
|
||||||
|
// if long < -180 {
|
||||||
|
// set long to long + 360.
|
||||||
|
// }
|
||||||
|
// if long > 180 {
|
||||||
|
// set long TO long - 360.
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return LatLng(geoPos:LAT, long).
|
||||||
|
// }
|
||||||
|
|
|
@ -24,5 +24,31 @@ function ReadSensor {
|
||||||
if not sList:HasKey(s) {
|
if not sList:HasKey(s) {
|
||||||
return -1. // TODO: is -1 an impossible result for all sensors? I suspect not...
|
return -1. // TODO: is -1 an impossible result for all sensors? I suspect not...
|
||||||
}
|
}
|
||||||
return s:DISPLAY:TOSCALAR.
|
|
||||||
|
if not sList[s]:ACTIVE {
|
||||||
|
sList[s]:Toggle().
|
||||||
|
}
|
||||||
|
|
||||||
|
// UGH, this appears to be the only way to do this.
|
||||||
|
local ret is -1.
|
||||||
|
if s = "PRES" {
|
||||||
|
set ret to SHIP:SENSORS:PRES.
|
||||||
|
}
|
||||||
|
if s = "TEMP" {
|
||||||
|
set ret to SHIP:SENSORS:TEMP.
|
||||||
|
}
|
||||||
|
if s = "ACC" {
|
||||||
|
set ret to SHIP:SENSORS:ACC:MAG.
|
||||||
|
}
|
||||||
|
if s = "GRAV" {
|
||||||
|
set ret to SHIP:SENSORS:GRAV.
|
||||||
|
}
|
||||||
|
if s = "LIGHT" {
|
||||||
|
set ret to SHIP:SENSORS:LIGHT.
|
||||||
|
}
|
||||||
|
|
||||||
|
// turn off the sensor when we're done with it
|
||||||
|
sList[s]:Toggle().
|
||||||
|
|
||||||
|
return ret.
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ function Hover {
|
||||||
function alignForHover {
|
function alignForHover {
|
||||||
if ReadSensor("PRES") = 0 {
|
if ReadSensor("PRES") = 0 {
|
||||||
// if we're in a vacuum, align with retrograde for smoother horizontal control.
|
// if we're in a vacuum, align with retrograde for smoother horizontal control.
|
||||||
lock STEERING to SHIP:SRFRETROGRADE.
|
lock STEERING to LookDirUp(SHIP:SRFRETROGRADE:FOREVECTOR, SHIP:FACING:TOPVECTOR)..
|
||||||
print "Aligning with retrograde.".
|
print "Aligning with retrograde.".
|
||||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:SRFRETROGRADE:FOREVECTOR) < 0.1.
|
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:SRFRETROGRADE:FOREVECTOR) < 0.1.
|
||||||
if done {
|
if done {
|
||||||
|
@ -55,7 +55,7 @@ function alignForHover {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ... otherwise just align vertically.
|
// ... otherwise just align vertically.
|
||||||
lock STEERING to SHIP:UP.
|
lock STEERING to LookDirUp(SHIP:UP:FOREVECTOR, SHIP:FACING:TOPVECTOR)..
|
||||||
print "Aligning vertical.".
|
print "Aligning vertical.".
|
||||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:UP:FOREVECTOR) < 1.
|
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:UP:FOREVECTOR) < 1.
|
||||||
if done {
|
if done {
|
||||||
|
|
|
@ -6,6 +6,7 @@ runoncepath("/lib/throttle").
|
||||||
runoncepath("/lib/node").
|
runoncepath("/lib/node").
|
||||||
runoncepath("/lib/stabilize_rocket").
|
runoncepath("/lib/stabilize_rocket").
|
||||||
runoncepath("/lib/launch_rocket").
|
runoncepath("/lib/launch_rocket").
|
||||||
|
runoncepath("/lib/sensors").
|
||||||
|
|
||||||
clearguis().
|
clearguis().
|
||||||
|
|
||||||
|
@ -36,6 +37,21 @@ set btn:ONTOGGLE to {
|
||||||
}
|
}
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
MakeMenu(
|
||||||
|
stk,
|
||||||
|
MakeButton(rows[0], "SENSOR"),
|
||||||
|
List(
|
||||||
|
List("Pressure", "RO", "-1"),
|
||||||
|
List("Temperature", "RO", "-1"),
|
||||||
|
List("Acceleration", "RO", "-1"),
|
||||||
|
List("Gravity", "RO", "-1"),
|
||||||
|
List("Light", "RO", "-1")
|
||||||
|
),
|
||||||
|
"Refresh",
|
||||||
|
refreshSensors@,
|
||||||
|
refreshSensors@
|
||||||
|
).
|
||||||
|
|
||||||
MakeMenu(
|
MakeMenu(
|
||||||
stk,
|
stk,
|
||||||
MakeButton(rows[0], "CONF"),
|
MakeButton(rows[0], "CONF"),
|
||||||
|
@ -124,3 +140,12 @@ MakeMenu(
|
||||||
|
|
||||||
iface:show().
|
iface:show().
|
||||||
wait until false.
|
wait until false.
|
||||||
|
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user