Jump to content

Cannon

Members
  • Posts

    203
  • Joined

  • Last visited

Reputation

30 Excellent

Profile Information

  • About me
    Spacecraft Engineer

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Sorry for a late reply, I've been away for a few months due to college and stuff. I tested it with your latest release and now it reduces ship's monopropellant properly when transfering it to jetpack. Good work
  2. So, as the tittle says, I made an autopilot in krpc(java) that gets to desired orbit and lands boosters by itself.
  3. I finally figured it out. The problem was, I was taking my ship's current orientation as a prograde value, but it's never perfectly facing prograde in-game, there are always some micro movements and variations, that's why I couldn't get exact vectors. Now I took the actual prograde vectors and converted them to heading and pitch like this: progradePitch = asin(-(progradeY)) progradeHeading = atan2(progradeX, progradeZ) And then just used the formulas I mentioned in my last comment and got velocity vectors with 100% accuracy
  4. Well, here's what I'm actually doing, I make the rocket that's about to go through reentry and eventually land, with its apoapsis at 85k and periapsis at 20k. So I orient it towards prograde and then I extract heading and pitch once it's facing prograde, because I assume that is also the direction of velocity vectors. But then the tricky part seems to be in choosing the right reference frame just as you suggested. Before I explain any further, here's the explanation of what each reference frame means: So, my velocity in the program matches the in-game velocity if I use celestial body orbital reference frame, but my pitch and heading will only match the in-game pitch and heading if I use vessel surface reference frame. I have tried to play around with those reference frames now, to see if I can get different results for my vectors. If I extract pitch value using celestial body orbital reference frame and heading value using vessel surface reference frame I get 2 of the vectors very close to the correct values. Here's what I get: pitch=-10.908204 //It doesn't match the in-game pitch which is about -1 or 0 at most. heading=89.91391 //Matches the in-game heading value vMag=2219.828828308464 //Matches the in-game orbital velocity xx=3.2752230972366845 yy=2179.717671720176 zz=-420.07162662308826 vectors=[-416.6260029541221, -2180.3798267286315, 2.5713511279416803] Notice how "zz" and "yy" values are very close to the first and second value of vectors, even though "yy" is lacking the negative sign. But the "xx" is still not that close to the third number. These are the formulas I used to get those results: xx=|vMagnitude| * (cos(heading) * cos(pitch)) yy=|vMagnitude| * (sin(heading) * cos(pitch)) zz=|vMagnitude| * (sin(pitch)) Objectively, they're still not 100% accurate results, but are very close now. I'm running out of ideas what to try next though
  5. Yup, converted all to radians, but it still gives wrong numbers. For example x=sin(heading) would be x=sin(90.389) or for radians x=sin(1.57), and the result of that is 0.99, doesn't match any of the extracted velocity vectors in [-72.25886975259107, -2209.998264874299, 1.6282022342777325] Here's part of my code too, it might help if you notice any errors: Triplet<Double,Double,Double> velocity = vessel.flight(refDelta).getVelocity(); System.out.println("vectors="+velocity); //Prints out [-72.25886975259107, -2209.998264874299, 1.6282022342777325] double vMag = Math.sqrt(velocity.getValue0() * velocity.getValue0() + velocity.getValue1() * velocity.getValue1() + velocity.getValue2() * velocity.getValue2()); //Calculate magnitude of velocity float pitchA = vessel.flight(vessel.getSurfaceReferenceFrame()).getPitch(); float headingA = vessel.flight(vessel.getOrbit().getBody().getReferenceFrame()).getHeading(); System.out.println("pitch="+pitchA); System.out.println("heading="+headingA); pitchA *= (Math.PI/180); //Conversion to radians headingA *= (Math.PI/180); //Conversion to radians double radiusAlt = vessel.getOrbit().getBody().getEquatorialRadius() + vessel.flight(vessel.getOrbit().getBody().getReferenceFrame()).getMeanAltitude(); //Radius + Current Altitude double vLat = vessel.getOrbit().getBody().latitudeAtPosition(vessel.position(vessel.getOrbit().getBody().getReferenceFrame()), vessel.getOrbit().getBody().getReferenceFrame()); //Get Latitude double vLon = vessel.getOrbit().getBody().longitudeAtPosition(vessel.position(vessel.getOrbit().getBody().getReferenceFrame()), vessel.getOrbit().getBody().getReferenceFrame()); //Get Longitude vLat *= (Math.PI/180); //Conversion to radians vLon *= (Math.PI/180); //Conversion to radians //Formulas for x,y,z vector calculation (I've tried with previously mentioned formulas too, didn't work) double xxx = Math.abs(vMag)*((Math.cos(headingA)*Math.cos(pitchA))*vLat); double yyy = Math.abs(vMag)*((Math.sin(headingA)*Math.cos(pitchA))*vLon); double zzz = Math.abs(vMag)*((Math.sin(pitchA))*radiusAlt); double xyz = Math.abs(vMag)*((Math.cos(headingA)*Math.cos(pitchA))*vLat+(Math.sin(headingA)*Math.cos(pitchA))*vLon+(Math.sin(pitchA))*radiusAlt); System.out.println("pitch="+pitchA); System.out.println("heading="+headingA); System.out.println("xx="+xxx); System.out.println("yy="+yyy); System.out.println("zz="+zzz); System.out.println("xyz="+xyz); System.out.println("vLat="+vLat); System.out.println("vLon="+vLon);
  6. I tried using those 2 formulas but it's not giving me the correct results X=(magnitude)*(cos(heading)) OR X=(magnitude)*(cos(pitch)) OR x=(magnitude)*sin(heading)*cos(heading) OR x=(magnitude)*sin(heading)*cos(pitch) OR x=(magnitude)*sin(pitch)*cos(heading) OR x=(magnitude)*sin(pitch)*cos(pitch) I've tried all of the above combinations and none of them produced any of the correct numbers [-72.25886975259107, -2209.998264874299, 1.6282022342777325]
  7. Don't know if this is the right place to ask this, but I couldn't find any better. A spacecraft is travelling at given velocity. Velocity vectors are = [-72.25886975259107, -2209.998264874299, 1.6282022342777325]. When I calculate the magnitude of it, I get 2211.18m/s. That's easy to do. But what if I have to calculate all 3 vector components when I only have magnitude? Spacecraft bearing/heading is 90.389° so it's heading south-east, and its pitch is -1.725° which means it's going slightly "below the horizon"/towards the ground. I tried this formula: X=(magnitude)*(cos(heading)) to get one of the vectors but I know solution is incorrect because it's not equal to any of the vectors I wrote at the start. X=(2211.18)*(cos(90.389)=-15.01 . I also tried a formula from here which goes x=ρsinφcosθ. I used magnitude (2211.18m/s) as "ρ" value, and 90° for both θ and φ, since direction is 90° south of north pole, and 90° towards east too. So, x=2211.18*sin(90)*cos(90)*=-15, the result was -15, which still doesn't match any of the vector components [-72.25886975259107, -2209.998264874299, 1.6282022342777325] So how do I calculate it then? I'm trying to create something with krpc mod, and a certain function requires velocity vectors as input, instead of velocity's magnitude (2211.18m/s).
  8. Alright, I changed all of reinitResourcesOnStoreInVessel to False and I fixed the typo in oretanks.cfg, and also replaced the OreToParts.dll. However, ship's monopropellant still doesn't get reduced after refuelling Here's the oretanks.cfg file and a console screenshot:
  9. For anyone trying to use LaunchOrbit java code from tutorials, there is a problem in every while loop. Basically lots of variables aren't declared as "volatile" which causes different threads to not be synchronized, and then your while loop keeps going on forever without doing anything. The reason for that is the JVM is allowed to assume that other threads do not change some of the variables during the loop. The proper fix would be to make them all "volatile", but you can also fix it more easily by adding the following at the start of every loop: System.out.print("."); System.out.print("\b"); This will add a dot and then delete it every time, but what it does is force syncrhronization which makes the loop work properly.
  10. For anyone trying to use LaunchOrbit java code from tutorials, there is a problem in every while loop. Basically lots of variables aren't declared as "volatile" which causes different threads to not be synchronized, and then your while loop keeps going on forever without doing anything. The reason for that is the JVM is allowed to assume that other threads do not change some of the variables during the loop. The proper fix would be to make them all "volatile", but you can also fix it more easily by adding the following at the start of every loop: System.out.print("."); System.out.print("\b"); This will add a dot and then delete it every time, but what it does is force syncrhronization which makes the loop work properly.
  11. Alright, I'll try that. The list of mods is: -ClickThroughBlocker -ToolbarControl -Astronomers Visual Pack -Chatterer -Distant Object Enhancement -Engine Light Relit -Environmental Visual Enhancements -KAS -KIS -Kopernicus -Loading Screen Manager -Modular Flight Integrator -NASA Countdown Clock -Docking Port Alignment Indicator -Parallax -Planetary Base Systems -Planet Shine -Scatterer -SunflaresOfMaar -TAC Life Support -TUFX -Vapor Vent I could also refuel the jetpacks in the new save BUT it still wasn't reducing the monopropellant of the ship, so I could refuel as many times as I want. I assume it should reduce the ship's monopropellant by an equal amount that the jetpack refueled with. And if ship has no monopropellant left, you should be unable to refuel. EDIT: Even after removing all mods (except this one) on the new save, the refueling still doesn't reduce ship's monopropellant. EDIT2: I managed to stop automatic refuel (upon entering the ship) in the old save without removing any mods, if I put a new jetpack in VAB. It still doesn't reduce ship's monopropellant when I click refuel though.
  12. -I put the evafix.cfg inside the CustomPatches which is in GameData folder -I'm playing the career mode -Version is 1.12.2.3167 and I do have breaking ground dlc (1.7.1) -Sure thing, here's ksp.log and quicksave . However, I've also tested with new save, I mean I started new career mode from scratch, just to try it out. In new save, the jetpack actually wasn't refilling automatically by itself (while it does in old save), so that part was working properly now. However, when I clicked on "refuel EVA fuel" it still wasn't taking/reducing the ship's monopropellant, but it did refuel the jetpack. So basically this still gives me infinite fuel because I can refuel in the ship infinite amount of times. I decided to include the quicksave of the new game too, here it is . I don't want to abandon my old save though, this was just to test it. EDIT: fixed the link for new save
  13. I did everything as you said, but jetpacks are still getting refueled upon entering the ship, without reducing the ship's monopropellant. I made a "CustomPatches" folder and then a file inside it called "evafix.cfg" and I put this in it: //Disable EVA jetpack infinite fuel @PART[evaJetpack] { @MODULE[ModuleCargoPart] { %reinitResourcesOnStoreInVessel = false } } @PART[evaCylinder] { @MODULE[ModuleCargoPart] { %reinitResourcesOnStoreInVessel = false } } and then I downloaded your mod and put the folder "OreToParts" into GameData. I also enabled "Persist kerbal inventory loadout" in difficulty settings. Why is it not working properly?
×
×
  • Create New...