Jump to content

bazilshep_

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by bazilshep_

  1. Has anyone figured out how velocity:surface reports while on the mun? The method I'm using for kerbin gives nonsensical results, even though it appears to work perfectly on kerbin. It fits best on the mun if you assume that 144 should be added to the longitude, but that doesn't work quite correctly. The surface velocity code is shown below, can anyone spot any errors? set lat to latitude. set lon to longitude. set vs to velocity:surface . //calculate surface velocity in terms of unit vectors east, north, and up set ve to vs:z * sin(lon) + vs:x * cos( lon ) . set vu to vs:z * cos(lon)*cos(lat) - ( vs:x * sin(lon)*cos(lat) + vs:y*sin(lat) ) . set vn to vs:z * cos(lon)*sin(lat) + vs:y*cos(lat) - vs:x * sin(lon)*sin(lat) .
  2. Surfacevelocity appears to be measuring the horizontal components of the surface velocity.
  3. This is a pretty good mod OP, its quite fun coming up with this stuff. Using check's lat/lon surface velocity trick I've come up with a fully automated suicide burn landing program using some kinematics math. To test it launch a craft with a reasonably centered COT and reasonable TWR. Run the program, then get some altitude on the craft. The program will kick in once its starts descending. It will try to zero your horizontal and vertical velocity at altitude = TargetH . Once it zeros your vertical velocity it switches to hover mode, which zeros horizontal velocity and descends at targetv . clearscreen. print "Started...". set gl to 9.81. set TargetH to 5 . set targetv to -.9 . set thr to 0 . set thrmargin to 0.7 . set tlmargin to 0.8 . set theta to 0 . set tl to 0 . set E to ( TargetH - ALT:RADAR ) . set D to 0 . print "waiting...". until verticalspeed < -2 { }. print "Suicide Burn..." . SAS off. until ( abs(E) < 10 ) AND ( ( abs(verticalspeed) < 2 ) OR ( tl < 0 ) ) { set TMR to ( maxthrust / mass ) + 0.01 . set E to ( TargetH - ALT:RADAR ) . set tl to 2 * tlmargin * E / verticalspeed - .5 . set thr to ( ( (verticalspeed / tl - gl) ^ 2 + surfacespeed ^ 2 / tl ^ 2 ) ^ .5) / TMR . set q to (surfacespeed * verticalspeed)/( verticalspeed^2 - 2*E). set aq to abs(q). set theta to (-90)*( q^5 + 83.29*q^3 + 518.1*q )/( aq^5 + 96.08*aq^3 + 535.5*aq + 597.9 ). set lat1 to latitude . set lon1 to longitude . set lat2 to latitude . set lon2 to longitude . set bearingw to ( lon2 - lon1 ) / cos( lat2 ) . set bearingn to ( lat2 - lat1 ) . set bearingm to ( bearingw^2 + bearingn^2 )^.5 + 0.000001 . lock steering to up + R( theta * bearingn / bearingm , theta * bearingw / bearingm , 180) . if thr < 0 { lock throttle to 0 . }. if thr > 1 { lock throttle to 1 . }. if ( thr < 1 ) AND ( thr > thrmargin ) { lock throttle to thr. }. print "tl: " + tl + " " at (20,0). print "bw: " + bearingw/bearingm + " " at (20,1). print "the: " + theta + " " at (20,2). }. print "Hovering..." . until abs(verticalspeed) < .05 { set theta to surfacespeed * 5. set WTR to (mass*gl/maxthrust). set D to (-.2) * ( verticalspeed - targetv ) * WTR. set thr to D + WTR* cos( theta ). set lat1 to latitude. set lon1 to longitude. set lat2 to latitude. set lon2 to longitude. set bearingw to ( lon2 - lon1 ) / cos( lat2 ) . set bearingn to ( lat2 - lat1 ) . set bearingm to ( bearingw^2 + bearingn^2 )^.5 + 0.000001 . lock steering to up + R( theta*bearingn/bearingm, theta*bearingw/bearingm , 180) . if thr < 0 { lock throttle to 0. } . if thr > 1 { lock throttle to 1 . } . if (thr < 1) AND (thr > 0) { lock throttle to thr. } . } . print "Landed.". set throttle to 0. unlock steering. print "Exiting..". I also came up with an approximation to the atan function. It has a maximum error of about 2 degrees, but its close enough for this. The code calculates theta = atand( q ). set q to something. set aq to abs(q). set theta to (-90)*( q^5 + 83.29*q^3 + 518.1*q )/( aq^5 + 96.08*aq^3 + 535.5*aq + 597.9 ).
  4. Using check's lat/lon trick to figure out surface velocity bearing I've made a suicide burn landing program. Great mod OP, its pretty fun figuring this stuff out. To test it launch a craft that can land with a reasonably centered COT and reasonable TWR, run the program, and then get some altitude. The program engages after you start descending. It figures out the required constant throttle power and heading to zero out your velocity at altitude = TargetH, and executes it when the required throttle to do the maneuver gets over thrmargin (.7) . clearscreen. print "Started...". set gl to 9.81. set TargetH to 10 . set targetv to -.9 . set thr to 0 . set thrmargin to 0.7 . set tlmargin to 0.8 . set theta to 0 . set tl to 0 . set E to ( TargetH - ALT:RADAR ) . set D to 0 . print "waiting...". until verticalspeed < -1 { }. print "Suicide Burn..." . SAS off. until ( abs(E) < 10 ) AND ( ( abs(verticalspeed) < 2 ) OR ( tl < 0 ) ) { set TMR to ( maxthrust / mass ) + 0.01 . set E to ( TargetH - ALT:RADAR ) . set tl to 2 * tlmargin * E / verticalspeed - .5 . set thr to ( ( (verticalspeed / tl - gl) ^ 2 + surfacespeed ^ 2 / tl ^ 2 ) ^ .5) / TMR . set q to (surfacespeed * verticalspeed)/( verticalspeed^2 - 2*E). set aq to abs(q). set theta to (-90)*( q^5 + 83.29*q^3 + 518.1*q )/( aq^5 + 96.08*aq^3 + 535.5*aq + 597.9 ). set lat1 to latitude . set lon1 to longitude . set lat2 to latitude . set lon2 to longitude . set bearingw to ( lon2 - lon1 ) / cos( lat2 ) . set bearingn to ( lat2 - lat1 ) . set bearingm to ( bearingw^2 + bearingn^2 )^.5 + 0.000001 . lock steering to up + R( theta * bearingn / bearingm , theta * bearingw / bearingm , 180) . if thr < 0 { lock throttle to 0 . }. if thr > 1 { lock throttle to 1 . }. if ( thr < 1 ) AND ( thr > thrmargin ) { lock throttle to thr. }. print "tl: " + tl + " " at (20,0). print "bw: " + bearingw/bearingm + " " at (20,1). print "the: " + theta + " " at (20,2). }. print "Hovering..." . until abs(verticalspeed) < .05 { set theta to surfacespeed. set WTR to (mass*gl/maxthrust). set D to (-.2) * ( verticalspeed - targetv ) * WTR. set thr to D + WTR* cos( theta ). set lat1 to latitude. set lon1 to longitude. set lat2 to latitude. set lon2 to longitude. set bearingw to ( lon2 - lon1 ) / cos( lat2 ) . set bearingn to ( lat2 - lat1 ) . set bearingm to ( bearingw^2 + bearingn^2 )^.5 + 0.000001 . lock steering to up + R( theta*bearingn/bearingm, theta*bearingw/bearingm , 180) . if thr < 0 { lock throttle to 0. } . if thr > 1 { lock throttle to 1 . } . if (thr < 1) AND (thr > 0) { lock throttle to thr. } . } . print "Landed.". set throttle to 0. unlock steering. print "Exiting..". I also figured out an approximation to the atan function that might be useful to people. It has a max error about 2 degrees, but its precise enough for this. The code below executes theta = atand( q ) . set q to something. set aq to abs(q). set theta to (-90)*( q^5 + 83.29*q^3 + 518.1*q )/( aq^5 + 96.08*aq^3 + 535.5*aq + 597.9 ).
×
×
  • Create New...