Jump to content

Hyperlynx

Members
  • Posts

    55
  • Joined

  • Last visited

Reputation

3 Neutral

Profile Information

  • About me
    Rocketeer
  1. I've thought of maybe doing that. The tricky part would be how often to sample. Maybe I could do a bunch of flights to gather data on what a good trajectory looks like and then hope it fits into a mathematical curve that I can easily work out?... I'll give that pdf a read. Thanks! My TWR ranges between 1.3 and 1.5, grav turn speed between 80 and 100, turn angle 1 to 10, time before ap burn 30 to 15. Getting the right number within those ranges is what's annoying, particularly because I'm trying to get as close to optimal (circular) as I can/have the patience for, to save on the cost of the rocket. But I should try the lock to 45 degrees thing, it's probably going to be more consistent. That's a good point! I could use that to work out the proper burn duration!
  2. I've been playing KSP for a while now, on and off (Steam says >350 hours). But yet, getting into orbit is still trial-and-error for me. I use Kerbal OS. For each spacecraft I design, I write a script to launch it. The script is roughly the same each time: Lock throttle to <target TWR> When at <gravity turn speed>, pitch to <angle> degrees from vertical. Wait 10 seconds. Unlock steering. Wait until apoapsis has reached <target apoapsis>. Cut throttle. Wait until <seconds before apoapsis> Throttle to 100% Wait until periapsis has reached <target periapsis> What changes is the values of those variables (in <angle brackets>). The thing is, changing those variables is completely trial-and-error. I can tell from experience how each one is going to affect my orbit. If I'm at a higher speed before I start my gravity turn then the pitch-over is going to be slower and higher, and I'll have to burn longer to circularise, but if it's too low then I'll pitch over too fast and won't reach space. Similar story with TWR - too low and I don't go to space, too high and I waste fuel due to air pressure. But finding the *right* numbers to use seems to be just keep trying and trying and trying until eventually I get into a nice, relatively circular orbit. Surely there must be a better way to do this than trial-and-error hardcoded values. How can I work this stuff out beforehand? Or is there another algorithm I should use instead?
  3. I have a launch script that works. I'm trying to convert it to put the launching part in a function, called by a button click. However, when I click the button my ship stages but doesn't throttle up. What's going on? @LAZYGLOBAL OFF. //flight parameters //Note: these must be global, or the locks won't work global targetApoapsis to 71000. global targetPeriapsis to 70000. global targetTWR to 1.5. global gravTurnSpeed to 90. global gravTurnAngle to 4. global timeBeforeApoapsis to 30. ///////////////////////////// SAS OFF. LOCAL preflightGUI IS GUI(200). LOCAL launchButton TO preflightGUI:ADDBUTTON("Launch"). set launchButton:ONCLICK to launch@. LOCAL closeButton TO preflightGUI:ADDBUTTON("Close"). preflightGUI:SHOW(). until closeButton:TAKEPRESS { // button still isn't pressed yet, let's keep waiting. wait 0. } function launch { preflightGUI:HIDE(). print targetApoapsis. print targetTWR. stage. //lock throttle to the target thrust-to-weight ratio: global lock distance to SHIP:ALTITUDE + BODY("Kerbin"):RADIUS. global lock weight to CONSTANT():G * ((SHIP:MASS* BODY("Kerbin"):MASS) / ( distance * distance )). lock THROTTLE to (targetTWR * weight) / (SHIP:MAXTHRUST + 0.001). lock steering to up + R(0, 0, 270). print "Ascending". wait until SHIP:VERTICALSPEED > gravTurnSpeed. lock steering to up + R(0, -gravTurnAngle, 270). print "Gravity turn". wait 10. // surface prograde lock steering to R(0,0,0) + velocity:surface. // when high enough, go hell-for-leather for orbital prograde. when ship:altitude > 27000 then { lock steering to ship:prograde. set targetTWR to 100. } when ship:maxthrust < 0.01 then { stage. when ship:maxthrust < 0.01 then { //don't thrust into the next stage, or it will explode and knock the craft off course lock throttle to 0. //wait for engine to stop declare global waitTime is TIME:SECONDS + 0.25. when TIME:SECONDS >= waitTime then { stage. set waitTime to TIME:SECONDS + 1. when TIME:SECONDS >= waitTime then { lock throttle to (targetTWR * weight) / (SHIP:MAXTHRUST + 0.001). } } } } print "Waiting until target apoapsis". wait until SHIP:APOAPSIS >= targetApoapsis. lock throttle to 0. print "Done". }
  4. Hm. Is there any way to set up different script directories for different saved games? I have my scripts under Git source control, and would rather like to do that with my ship designs as well, in the one repo. I usually have a craft and a script to launch and operate that craft, but the crafts are stored per save and the scripts are stored globally, at least by default. I guess as a workaround I can have the repo be in ksp/saves/savename/Ships and softlink a scripts directory to the ksp/Ships/Script directory. I just tried putting a subdirectory in boot, with the idea of having each save use a different subdir, but the contents was not recognised. I guess I'll need to append a namespace to my scripts' filenames, if I want to keep them from conflicting across saves. Not the end of the world, though, seeing as I'm probably not going to end up running two saves at the same time.
  5. Aha! So my problem was just that I didn't know how to read the info in CKAN properly, and I actually didn't have v1.1.5.2 when I thought I did. It's all good now
  6. Oh whoops, I didn't realise you were the OP. Of course, it must be something at my end. I'll track down the logs...
  7. You misunderstand - I have the 1.4.1 version, but it's not working. I can put the kOS part on my craft, and old designs using it still work, but right-clicking on it doesn't give me the button to open the console. I also don't have a kOS icon on my toolbar, like I used to.
  8. Hey, I've just started playing KSP again after a long hiatus. kOS doesn't seem to be working for me any more. Are you all playing on KSP v1.4.1? I'm on 1.4.2 due to Steam patching my game whether I like it or not. Am I missing something about how to get it working, or do I just need to wait for an update?
  9. Thanks guys! It works perfectly. The finished code: set stageTwoTWR to 1.3. //... set targetTWR to stageTwoTWR. lock distance to SHIP:ALTITUDE + BODY("Kerbin"):RADIUS. lock weight to CONSTANT():G * ((SHIP:MASS* BODY("Kerbin"):MASS) / ( distance * distance )). lock THROTTLE to (targetTWR * weight) / (SHIP:MAXTHRUST + 0.001).
  10. FancyMouse: I was under the impression that the formula for gravity was the acceleration under gravity, not the weight due to gravity. Not so? Reddeyfish: the force of gravity is based on the mass of both bodies, though. Granted my ship's mass is infintesimal compared to Kerbin, but it still contributes. Have I got my formula for gravity wrong?
  11. I'm trying to calculate my spacecraft's weight, so I can keep my TWR constant. I've managed to get my thrust-to-MASS constant, but I'm having a lot of trouble trying to calculate my weight. From what I understand, weight = gravity * mass, and gravity = G * (mass[craft] * mass[kerbin])/distance^2. However, I can't get correct results out of kOS. Here's what I'm trying so far: lock distance to SHIP:ALTITUDE + BODY("Kerbin"):RADIUS. lock gravity to CONSTANT():G * ((SHIP:MASS* BODY("Kerbin"):MASS * 1000) / ( distance * distance )). lock weight to (SHIP:MASS) * gravity. print "distance:" + distance. print "grav:" + gravity. print "weight:" + weight. kOS returns SHIP:MASS in metric tons, not kilograms, so I have multiplied by 1000 to get kg. The craft has a mass of 2,779kg, however this gives the weight as 75,723kg! That's likely because it has gravity as 27,251 when, as far as I understand, it should be just 9.8. What am I doing wrong? I figure I have units crossed somewhere. Or does Kerbin have fixed gravity that differs from what it should have for its mass and size?
  12. The problem was definitely, totally that the solid boosters were slewing. Struts solved it.
  13. Aha! I spent the $75,000 for the astronaut complex upgrade, did some EVAs and spent the science on struts. Now that I've strutted up my boosters, things are MUCH better. Yes, I took that screenshot to show that I had found that problem. Unfortunately, it was not the only problem with my design. The main problem was that the radial decouplers were not keeping the boosters straight. Struts has fixed that problem.
  14. I don't yet have struts or multi-kerbal cockpits. Making do with pretty crap technology.
×
×
  • Create New...