Clean up hover code and add some vector rendering stuff.
This commit is contained in:
parent
0605cc4f2e
commit
659e41c80f
|
@ -1,4 +1,5 @@
|
||||||
// This script assumes you have bound collective (aka deploy angle) to main throttle.
|
// This script assumes you have bound collective (aka deploy angle) to main throttle.
|
||||||
|
runoncepath("/debug/vecrender"). // debug
|
||||||
|
|
||||||
// SAS off. // debug: re-enable when adjusting heading
|
// SAS off. // debug: re-enable when adjusting heading
|
||||||
local pitchPID is PIDLoop(0.01, 0.001, 0.001, -45, 45).
|
local pitchPID is PIDLoop(0.01, 0.001, 0.001, -45, 45).
|
||||||
|
@ -9,35 +10,28 @@ local collectivePID is PIDLoop(0.1, 0.1, 0.001, 0, 1).
|
||||||
set collectivePID:SETPOINT to 0.
|
set collectivePID:SETPOINT to 0.
|
||||||
|
|
||||||
|
|
||||||
local vel is 0. lock vel to SHIP:BODY:UP * SHIP:VELOCITY:SURFACE.
|
// local x is 0. lock x to SHIP:FACING:FOREVECTOR * SHIP:VELOCITY:SURFACE.
|
||||||
set vecDraw(V(0,0,0), vel):show to true. // debug
|
// local y is 0. lock y to (SHIP:UP:FOREVECTOR * SHIP:VELOCITY:SURFACE) / (SHIP:VELOCITY:SURFACE:MAG * cos(VectorAngle(SHIP:UP:FOREVECTOR, SHIP:VELOCITY:SURFACE))).
|
||||||
|
// local z is 0. lock z to SHIP:FACING:RIGHTVECTOR * SHIP:VELOCITY:SURFACE.
|
||||||
local x is 0. lock x to SHIP:FACING:FOREVECTOR * SHIP:VELOCITY:SURFACE.
|
// local spd is 0. lock spd to SHIP:VELOCITY:SURFACE:MAG.
|
||||||
local y is 0. lock y to (SHIP:UP:FOREVECTOR * SHIP:VELOCITY:SURFACE) / (SHIP:VELOCITY:SURFACE:MAG * cos(VectorAngle(SHIP:UP:FOREVECTOR, SHIP:VELOCITY:SURFACE))).
|
|
||||||
local z is 0. lock z to SHIP:FACING:RIGHTVECTOR * SHIP:VELOCITY:SURFACE.
|
|
||||||
local spd is 0. lock spd to SHIP:VELOCITY:SURFACE:MAG.
|
|
||||||
|
|
||||||
local done is false.
|
local done is false.
|
||||||
|
|
||||||
on AG9 {
|
on AG9 {
|
||||||
set done to true.
|
set done to true.
|
||||||
}
|
}
|
||||||
|
|
||||||
until done {
|
until done {
|
||||||
// debug
|
// local newPitch is pitchPID:Update(TIME:SECONDS, spd). // was x
|
||||||
// print x + " " + y + " " + z.
|
// local newRoll is rollPid:Update(TIME:SECONDS, spd). // was z
|
||||||
print "Vertical Speed = " + y.
|
local newThrot is collectivePID:Update(TIME:SECONDS, SHIP:VELOCITY:SURFACE:Y). // was y
|
||||||
|
|
||||||
local newPitch is pitchPID:Update(TIME:SECONDS, spd). // was x
|
|
||||||
local newRoll is rollPid:Update(TIME:SECONDS, spd). // was z
|
|
||||||
local newThrot is collectivePID:Update(TIME:SECONDS, y). // was y
|
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
print "Yaw = " + mod(360 - SHIP:BEARING, 360).
|
print "Yaw = " + mod(360 - SHIP:BEARING, 360).
|
||||||
print "Pitch = " + newPitch.
|
print "Pitch = " + newPitch.
|
||||||
print "Roll = " + newRoll.
|
print "Roll = " + newRoll.
|
||||||
print "Throt = " + newThrot.
|
print "Throt = " + newThrot.
|
||||||
print "Spd = " + spd.
|
print "Vertical Speed = " + SHIP:VELOCITY:SURFACE:Y.
|
||||||
|
DrawVectorWithComponents(SHIP:VELOCITY:SURFACE).
|
||||||
|
|
||||||
set SHIP:CONTROL:PILOTMAINTHROTTLE to newThrot.
|
set SHIP:CONTROL:PILOTMAINTHROTTLE to newThrot.
|
||||||
// lock STEERING to Heading(
|
// lock STEERING to Heading(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user