Add program to zero velocity before hover/land operations.
This commit is contained in:
parent
966729911b
commit
bf6bbdc099
|
@ -6,6 +6,7 @@
|
||||||
// Do not include both this and stabilize_helicopter.ks in one program.
|
// Do not include both this and stabilize_helicopter.ks in one program.
|
||||||
|
|
||||||
runoncepath("/lib/sensors").
|
runoncepath("/lib/sensors").
|
||||||
|
runoncepath("/lib/node"). // TODO: move BurnTime to a more sensible library than 'node'
|
||||||
|
|
||||||
// Convenience function for landing operations. Hover over a point with a negative velocity, shutting down on landing.
|
// Convenience function for landing operations. Hover over a point with a negative velocity, shutting down on landing.
|
||||||
function Land {
|
function Land {
|
||||||
|
@ -13,6 +14,7 @@ function Land {
|
||||||
|
|
||||||
assumeControl().
|
assumeControl().
|
||||||
alignForHover().
|
alignForHover().
|
||||||
|
|
||||||
local pid is PIDLoop(0.1, 0.01, 0.01, 0, 1).
|
local pid is PIDLoop(0.1, 0.01, 0.01, 0, 1).
|
||||||
|
|
||||||
lock THROTTLE to pid:Update(TIME:SECONDS, SHIP:VERTICALSPEED).
|
lock THROTTLE to pid:Update(TIME:SECONDS, SHIP:VERTICALSPEED).
|
||||||
|
@ -27,6 +29,24 @@ function Land {
|
||||||
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.0.
|
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.0.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ZeroVelocity {
|
||||||
|
assumeControl().
|
||||||
|
alignForHover().
|
||||||
|
local processVar is 0.0.
|
||||||
|
print "Aligning.".
|
||||||
|
if ReadSensor("PRES") = 0 {
|
||||||
|
lock processVar to SHIP:VELOCITY:SURFACE:MAG.
|
||||||
|
} else {
|
||||||
|
lock processVar to SHIP:VERTICALSPEED.
|
||||||
|
}
|
||||||
|
local bt is BurnTime(processVar).
|
||||||
|
print "Burning.".
|
||||||
|
lock THROTTLE to 1.0.
|
||||||
|
wait bt.
|
||||||
|
lock THROTTLE to 0.0.
|
||||||
|
restoreControl().
|
||||||
|
}
|
||||||
|
|
||||||
// Stabilizes a rocket relative to the surface, with optional vertical
|
// Stabilizes a rocket relative to the surface, with optional vertical
|
||||||
// velocity.
|
// velocity.
|
||||||
function Hover {
|
function Hover {
|
||||||
|
|
|
@ -51,6 +51,7 @@ MakeMenu(
|
||||||
}
|
}
|
||||||
).
|
).
|
||||||
|
|
||||||
|
MakeButton(rows[1], "ZERO", { ZeroVelocity(). }).
|
||||||
MakeButton(rows[1], "HOVER", { Hover(). }).
|
MakeButton(rows[1], "HOVER", { Hover(). }).
|
||||||
MakeButton(rows[1], "LAND", { Land(). }).
|
MakeButton(rows[1], "LAND", { Land(). }).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user