Jump to content

[1.3.1] Ferram Aerospace Research: v0.15.9.1 "Liepmann" 4/2/18


ferram4

Recommended Posts

Hey ferram no idea if this is helpful or not, but thought I'd post the source code for navlights. Thought maybe that might help you figure out a way to easy avoid voxelization everytime the lights flash. Hope that helps


using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using UnityEngine;
using System.Reflection;
namespace AviationLights


//Originally made by RPGprayer, edited by BigNose, Why485, GROOV3ST3R, JDP and J.Random
//License: This file contains code from RPGprayers "Position/Navigation Lights". Used with permission.
{
public static class navLightStates
{
public enum navLightState
{
Off = 0,
Flash = 1,
DoubleFlash = 2,
Interval = 3,
On = 4
}
}


public class ModuleNavLight : PartModule
{
protected Color _navLightColor;


[KSPField (isPersistant = true)]
public int navLightSwitch = 0;


private double _lastTimeFired;
private GameObject LightOffsetParent;

private const float INTENSITY_GLOW = 0.33f;
private const float INTENSITY_OFFSET = 0.67f;
bool b = false, flightStarted = false;


[KSPField]
public string Resource = "ElectricCharge";


[KSPField]
public float EnergyReq = 0;


[KSPField]
public float
IntervalFlashMode = 0,
Interval = 0,
FlashOn = 0,
FlashOff = 0;


[KSPField]
public Vector3 Color = Vector3.zero;


public override void OnStart(PartModule.StartState state)
{
if (state == StartState.Editor) return;
flightStarted = true;


_navLightColor = new Color(Color.x, Color.y, Color.z);
_lastTimeFired = Planetarium.GetUniversalTime();


// Parent for main illumination light, used to move it slightly above the light.
LightOffsetParent = new GameObject();
LightOffsetParent.transform.position = base.gameObject.transform.position;
LightOffsetParent.transform.rotation = base.gameObject.transform.rotation;
LightOffsetParent.transform.parent = base.gameObject.transform;
LightOffsetParent.transform.Translate(0.33f, 0.0f, 0.0f);


// Main Illumination light
LightOffsetParent.gameObject.AddComponent<Light>();
LightOffsetParent.gameObject.light.color = _navLightColor;
LightOffsetParent.gameObject.light.intensity = 0;


// Glow Illumination light
base.gameObject.AddComponent<Light>();
base.gameObject.light.color = _navLightColor;
base.gameObject.light.intensity = 0;


LightOffsetParent.gameObject.AddComponent<MeshRenderer>();
}


public override void OnUpdate()
{
if (!flightStarted) return;
switch (navLightSwitch)
{
case (int)navLightStates.navLightState.Off:
//Lights go to 'Off' mode
LightOffsetParent.gameObject.light.intensity = 0;
base.gameObject.light.intensity = 0;
break;
case (int)navLightStates.navLightState.Flash:
//Lights go to 'Flash' mode
FlashBasedSwitcher(IntervalFlashMode);
break;
case (int)navLightStates.navLightState.DoubleFlash:
//Lights go to 'Double Flash' mode
DoubleFlashBasedSwitcher(IntervalFlashMode);
break;
case (int)navLightStates.navLightState.Interval:
//Lights go to 'Interval' mode
IntervalBasedSwitcher(Interval);
break;
case (int)navLightStates.navLightState.On:
//Lights go to 'On' mode
LightOffsetParent.gameObject.light.intensity = INTENSITY_OFFSET;
base.gameObject.light.intensity = INTENSITY_GLOW;
break;
}


//Energy requirements check: if the light is not off and requires resources; request resource. If returned resource is less than requested; turn off
if (navLightSwitch > 0 && EnergyReq > 0 && TimeWarp.deltaTime > 0 && part.RequestResource (Resource, EnergyReq * TimeWarp.deltaTime) == 0)
navLightSwitch = (int)navLightStates.navLightState.Off;
}

public override string GetInfo()
{
if (EnergyReq > 0)
return Resource + " : " + (EnergyReq * 60).ToString("0.0") + "/min.";
else return "";
}

private void FlashBasedSwitcher(float FlashOn)
{
if (_lastTimeFired < Planetarium.GetUniversalTime() - FlashOn)
{
b = !b;
IntervalFlashMode = b ? this.FlashOn : FlashOff;
_lastTimeFired = Planetarium.GetUniversalTime();
LightOffsetParent.gameObject.light.intensity = (LightOffsetParent.gameObject.light.intensity == INTENSITY_OFFSET) ? 0f : INTENSITY_OFFSET;
base.gameObject.light.intensity = (base.gameObject.light.intensity == INTENSITY_GLOW) ? 0f : INTENSITY_GLOW;
}
}


private void DoubleFlashBasedSwitcher(float FlashOn)
{
LightOffsetParent.gameObject.light.intensity = 0;
base.gameObject.light.intensity = 0;


if (_lastTimeFired < Planetarium.GetUniversalTime() - FlashOn)
{
b = !b;
IntervalFlashMode = b ? this.FlashOn : FlashOff;
_lastTimeFired = Planetarium.GetUniversalTime();
LightOffsetParent.gameObject.light.intensity = (LightOffsetParent.gameObject.light.intensity == INTENSITY_OFFSET) ? 0f : INTENSITY_OFFSET;
base.gameObject.light.intensity = (base.gameObject.light.intensity == INTENSITY_GLOW) ? 0f : INTENSITY_GLOW;
}
}


private void IntervalBasedSwitcher(float Interval)
{
if (_lastTimeFired < Planetarium.GetUniversalTime() - Interval)
{
_lastTimeFired = Planetarium.GetUniversalTime();
LightOffsetParent.gameObject.light.intensity = (LightOffsetParent.gameObject.light.intensity == INTENSITY_OFFSET) ? 0f : INTENSITY_OFFSET;
base.gameObject.light.intensity = (base.gameObject.light.intensity == INTENSITY_GLOW) ? 0f : INTENSITY_GLOW;
}
}

[KSPAction("LightToggle", KSPActionGroup.None, guiName = "Light toggle")]
public void LightToggle(KSPActionParam param)
{
OnEvent();
}


[KSPAction("FlashToggle", KSPActionGroup.None, guiName = "Flash toggle")]
public void FlashToggle(KSPActionParam param)
{
FlashEvent();
}


[KSPAction("DoubleFlashToggle", KSPActionGroup.None, guiName = "Double Flash toggle")]
public void DoubleFlashToggle(KSPActionParam param)
{
DoubleFlashEvent();
}


[KSPAction("IntervalToggle", KSPActionGroup.None, guiName = "Interval toggle")]
public void IntervalToggle(KSPActionParam param)
{
IntervalEvent();
}


[KSPAction("Cycle", KSPActionGroup.None, guiName = "Cycle modes")]
public void Cycle(KSPActionParam param)
{
_lastTimeFired = 0;


if (navLightSwitch == 4)
navLightSwitch = 0;
else
navLightSwitch++;
}


[KSPEvent(name = "FlashEvent", active = true, guiActive = true, guiName = "Flash")]
public void FlashEvent()
{
_lastTimeFired = 0;


if (navLightSwitch == 1)
navLightSwitch = 0;
else
navLightSwitch = 1;
}


[KSPEvent(name = "DoubleFlashEvent", active = true, guiActive = true, guiName = "Double Flash")]
public void DoubleFlashEvent()
{
_lastTimeFired = 0;


if (navLightSwitch == 2)
navLightSwitch = 0;
else
navLightSwitch = 2;
}

[KSPEvent(name = "IntervalEvent", active = true, guiActive = true, guiName = "Interval")]
public void IntervalEvent()
{
_lastTimeFired = 0;


if (navLightSwitch == 3)
navLightSwitch = 0;
else
navLightSwitch = 3;
}


[KSPEvent(name = "OnEvent", active = true, guiActive = true, guiName = "Light")]
public void OnEvent()
{
_lastTimeFired = 0;


if (navLightSwitch == 4)
navLightSwitch = 0;
else
navLightSwitch = 4;
}
}
}

Link to comment
Share on other sites

@The Optimist: Unfortunate reaction with stock code that I simply can't fix. The stock heating system added in 1.0.3 created situations where skin temperatures of parts can fluctuate wildly, and since FAR sets different skin areas, that issue can occur when it previously didn't. Still, not something I can fix at all; your only hope is to avoid designs that attach multiple parts to a single tiny, lightweight (relatively) part to avoid things exploding.

As I've said before, many, many, many times, yell at Squad to hurry up with 1.0.5 and to never rush feature overhauls into a bugfix again, and then wait to actually fix that damn issues they add. I can't fix their bugs, only they can.

@Svm420: There is nothing in there that would ever cause FAR to update the aerodynamics. There are no animations being triggered. FAR will not have any idea that there are things that it should bother to look for, so it will never update.

I thought that you were asking for help because you had observed the problem. If this is all the code for navlights, then your problem is with some other mod, or something else actually does require FAR to updaate the aerodynamics.

Link to comment
Share on other sites

Hello I'm considering using FAR to have more fun in KSP. And to apply my knowledge as aerospace engineering student. (Looking at you flight dynamics, last subject before BSc degree but only given in the spring!)

Anyways, I have a few questions:

First of all: how does FAR play with other mods? Especially mods that add parts (such as USI colonization systems, and a few moar rocket parts, and I'm currently modifying jool's atmosphere by hand...).

Secondly: What about heating in the atmosphere? How does FAR interact with that? (And does it change the type of returning rockets I can have?)

Further: To what point do we have control in far? Can I add my own NACA profile to a wing?

Finally: How realistic is it? Does FAR simulate using computational fluid dynamics to solve the dynamic equations around the aircraft? Or is it just following the lifting line theory? How do the CL-alpha curve look?

Will I be able to see a separation bubble (and the linear cl_a change there?). Is stall hysteresis visible? Does the model take into account deep stall, and actual air-flow direction changes at the tail wing due to the main wing? (Giving rise to T-tails). Just because I did the test not too long ago, here is a CL-alpha curve I might want to see, you can see the seperation bubble at alpha = 4.5 degrees, hysteresis, deep stall plateau clearly:

bu49ab5.png

Link to comment
Share on other sites

There is nothing in there that would ever cause FAR to update the aerodynamics. There are no animations being triggered. FAR will not have any idea that there are things that it should bother to look for, so it will never update.

So quick question on those lines Ferram4. Does FAR now recalculate the airflow if you have moving wings, like the F-14 or the Mig-23?

Link to comment
Share on other sites

So quick question on those lines Ferram4. Does FAR now recalculate the airflow if you have moving wings, like the F-14 or the Mig-23?

I first tried that when Damned Robotics appeared, and it worked fine back then.

To answer a couple of paul23's questions:

FAR analyses shape. It does other things too if it's a wing or an intake or an engine ( maybe more things I don't know about ), but as far as I know it'll just work. It's always more or less just worked ( mostly by giving everything a default config ), just not as well as it does now. I'm pretty sure we're still using the single NACA supersonic profile it's always had but the wing code is getting rewritten at the moment. KSP heating is broken so I don't care what it does there, and the other stuff I'm not qualified to answer - there was some interaction between nearby wings in older versions at least, I've not had any answer about how much is in the current one.

Edited by Van Disaster
Link to comment
Share on other sites

Yes it always has accounted for wing sweep.

Previously it didnt seem to update in flight. If I moved the wings without staging something it didnt update the CoL movement. Not that I could monitor it while in flight.

Link to comment
Share on other sites

I first tried that when Damned Robotics appeared, and it worked fine back then.

To answer a couple of paul23's questions:

FAR analyses shape. It does other things too if it's a wing or an intake or an engine ( maybe more things I don't know about ), but as far as I know it'll just work. It's always more or less just worked ( mostly by giving everything a default config ), just not as well as it does now. I'm pretty sure we're still using the single NACA supersonic profile it's always had but the wing code is getting rewritten at the moment. KSP heating is broken so I don't care what it does there, and the other stuff I'm not qualified to answer - there was some interaction between nearby wings in older versions at least, I've not had any answer about how much is in the current one.

Well the heating system is something I do actually like sure it's not realistic and might be "broken" but it gives a reason not to just suicide-dive into an atmosphere to break. Whether I will use FAR depends actually entirely on this (I don't really wish to also install DRE though).

Link to comment
Share on other sites

FAR makes a voxel model of the whole craft which it uses to work out drag. That means that the vast majority of parts that aren't wings will work fine. There are sometimes problems with unusual parts. Wings and control surfaces are handled differently, and they do need FAR configs to work properly.

FAR is not aimed at changing the heating, though blatant bugs exist; Ferram discussed them above.

FAR offers a lot more control than stock, but you can't pick an airfoil, it just uses a single generic one all the time.

I'm not sure exactly how FAR works under the hood, but I'm pretty sure it's not CFD, that would be way too processor-intensive. The lift curve you show, with a hysteresis effect, is something I've seen in FAR. Many of your other questions I've never actually tested.

Link to comment
Share on other sites

First of all: how does FAR play with other mods? Especially mods that add parts (such as USI colonization systems, and a few moar rocket parts, and I'm currently modifying jool's atmosphere by hand...).

FAR currently only uses given parameters for wing parts, every other part is handled through its collision box.

The shapes are voxelized, wrapping the craft, this way the aerodynamics are applied based on the external surface and actual shape of the craft.

What could cause problems would be open/concave colliders or other collider messups, only saw this kind of problem reported twice and both times it got fixed.

Secondly: What about heating in the atmosphere? How does FAR interact with that? (And does it change the type of returning rockets I can have?)

Yes and no, it does not directly interfere with the atmospheric heating but the different aerodynamics will indirectly affect it.

It does change the type of returning rockets you can have, and how much speed you will lose during reentry.

Further: To what point do we have control in far? Can I add my own NACA profile to a wing?

You cannot add your own wing profile, IIRC FAR assumes a supersonic airfoil, but I don't remember exactly (I know that it does not fake a profile that does not exist in the actual model).

There are options that give you a lot of control regarding the control surfaces of the craft, allowing combined deflection, multi purpose control surfaces with different deflection settings and some other fancy stuff.

Finally: How realistic is it? Does FAR simulate using computational fluid dynamics to solve the dynamic equations around the aircraft? Or is it just following the lifting line theory? How do the CL-alpha curve look?

Will I be able to see a separation bubble (and the linear cl_a change there?). Is stall hysteresis visible? Does the model take into account deep stall, and actual air-flow direction changes at the tail wing due to the main wing? (Giving rise to T-tails). Just because I did the test not too long ago, here is a CL-alpha curve I might want to see, you can see the seperation bubble at alpha = 4.5 degrees, hysteresis, deep stall plateau clearly:

FAR uses some assumptions and simplifications to handle aerodynamics in real time on a game that was not really meant for it, but it's surprisingly accurate.

The CL curve accounts for stall and hysteresis, as a plus you also get Cm, L/D and Cd curves.

The wing interactions are not fully modeled yet, if you place many wings close to each other they will behave as a single wing, but wing interactions are not fully implemented yet.

FAR also gives you full dynamic stability derivatives, simulation graphs and transonic wave drag area readings, as well as overlays to assist you on improving transonic performance.

How realistic it is? Can't say for sure but it's pretty good.

FAR is an amazing mod, you should try it and see all of that by yourself :)

Edited by tetryds
Link to comment
Share on other sites

Well the heating (and maybe parachute aerodynamics) is making me reluctant to add it to my current carreer game.. (Started a very long game since I only take 20% science, 30% money).

But it's such a shame you can't choose an wingfoil: it's the alpha and omega in aircraft studies/design. (You start with it in the very first course describing the effect of airfoil selection on cl-alpha & stability - and after 5+ years you are still busy with it trying to figure out the best airfoil for a task). Something like xfoil can simulate any 3d wing shape (or take javafoil for 2d which is so much easier).

In my final BSc design synthesis exercise we had to change the Boeing 707 to fly slightly faster (M0.83), at higher altitude and especially much longer range (Heathrow -> Singapore without refuelling). First thing we did was take another airfoil (oh and we made the utterly stupid mistake of going to an aspect ratio of 12.5, when designing the structural integrity taking 18mm thick sheets at the wingroot is a bit of an alarm). In the end the TA came to us and asked us: "why did you choose that standard NACA, you should've looked into these supercritical airfoils instead. With these you wouldn't have any trouble due to local mach number increase".

Point being: an airfoil is so important, something I might even do in KSP if possible is take multiple wings, and decoupling a wing once I go past mach 1. Completely unrealistic in real flight, but would be really fun to see in ksp.

Link to comment
Share on other sites

Make a clone of your install and try it on that. KSP isn't tied to steam as far as I know ( I still get mine from the shop ), you should be able to make as many copies as you like.

It'd be nice to have a subsonic profile as well ( and a supercritical one ), but given you can still build extremely slow craft ( agile too ) with the one we have I'm not really that bothered. There are bigger problems building craft in KSP, like not being able to tune the shape properly or superdense parts if you're not running something that changes part density, or being able to pull 52g without everything folding flat. If you really want to fiddle with aircraft design in a bit more detail, you might want to try X-plane.

Edited by Van Disaster
Link to comment
Share on other sites

Well the heating (and maybe parachute aerodynamics) is making me reluctant to add it to my current carreer game.. (Started a very long game since I only take 20% science, 30% money).

But it's such a shame you can't choose an wingfoil: it's the alpha and omega in aircraft studies/design. (You start with it in the very first course describing the effect of airfoil selection on cl-alpha & stability - and after 5+ years you are still busy with it trying to figure out the best airfoil for a task). Something like xfoil can simulate any 3d wing shape (or take javafoil for 2d which is so much easier).

In my final BSc design synthesis exercise we had to change the Boeing 707 to fly slightly faster (M0.83), at higher altitude and especially much longer range (Heathrow -> Singapore without refuelling). First thing we did was take another airfoil (oh and we made the utterly stupid mistake of going to an aspect ratio of 12.5, when designing the structural integrity taking 18mm thick sheets at the wingroot is a bit of an alarm). In the end the TA came to us and asked us: "why did you choose that standard NACA, you should've looked into these supercritical airfoils instead. With these you wouldn't have any trouble due to local mach number increase".

Point being: an airfoil is so important, something I might even do in KSP if possible is take multiple wings, and decoupling a wing once I go past mach 1. Completely unrealistic in real flight, but would be really fun to see in ksp.

You know how fuel switcher works? Maybe you could help create a similar wing menu option where switching the foil creates different flight characteristics. I think this is easier to do in stock than in FAR.

Link to comment
Share on other sites

In practice, the current airfoil is very much like a NACA 6A series, but with somewhat higher zero-lift drag, no drag bucket and slightly higher stall angle. The main reason that there isn't airfoil selection currently is that the current legacy wing model isn't very conducive to adding in selectable profiles or making sure that they're oriented the correct way; future plans are to make them customizable, though the first pass is probably going to have a very limited implementation at least. One of the more difficult questions is how to combine selection of an airfoil section with player-created camber lines through putting multiple wing parts together. Also how to properly blend between airfoil properties if very different sections are chosen for different parts of the wing, which is something I admit I haven't looked too closely at implementing.

Link to comment
Share on other sites

I never seem to get much out of flaps, at best I can drop my landing speed by maybe 5-10 m/s. Is that normal or am I missing something.

And relatedly, any tips for making a spaceplane with a low landing speed, other than using vertical thrust? I'm trying to make one to do Kerbin>Serran in the New Horizons mod and I found the landing speeds there are somewhat higher than on Kerbin. The Ghost 3 is what I just tried and it touched down at 90-100 m/s, too fast for safety.

Link to comment
Share on other sites

Lower wing loading. I'd probably fill the back end of your wing in to turn it into a delta, but you can go the other way & reduce mass. I've managed with the help of some fiddling with AoA linked surfaces to hit 37 degrees AoA without anything showing it's stalling which would definitely slow you down, so maybe a little messing with high turn rate designs would help. I say high turn rate because that doesn't necessarily imply low speed, and obviously low speed designs aren't great for spaceplanes...

Link to comment
Share on other sites

I never seem to get much out of flaps, at best I can drop my landing speed by maybe 5-10 m/s. Is that normal or am I missing something.

And relatedly, any tips for making a spaceplane with a low landing speed, other than using vertical thrust? I'm trying to make one to do Kerbin>Serran in the New Horizons mod and I found the landing speeds there are somewhat higher than on Kerbin. The Ghost 3 is what I just tried and it touched down at 90-100 m/s, too fast for safety.

As above, but also: in rough-terrain landing, braking ability is as important as landing speed. Retrothrusters are a very good idea when taking aircraft interplanetary; the monoprop engines work well for this.

Link to comment
Share on other sites

As above, but also: in rough-terrain landing, braking ability is as important as landing speed. Retrothrusters are a very good idea when taking aircraft interplanetary; the monoprop engines work well for this.

Huge brake chutes too, if it's crewed or you're only making one landing.

Link to comment
Share on other sites

The way landing gear works in KSP, with a well designed craft, you should be able to make ~150 m/s landings on mostly flat terrain without damaging anything.

If you are landing at half the speed of sound there is a problem.

I doubt any of the aircraft I design have a landing speed of higher than 90m/s at their fastest.

Link to comment
Share on other sites

The way landing gear works in KSP, with a well designed craft, you should be able to make ~150 m/s landings on mostly flat terrain without damaging anything.
A fast landing is possible but I don't have the skill to make it reliable. My current main save is no-reverts (bugs excepted) so I need something that I can get down safely most of the time.
Link to comment
Share on other sites

On an unrelated note, is the issue with inconsistent behaviour from the analysis tools likely to be resolved. Simple things like reloading the craft, or making a change and then undoing it, have a habit of changing the reported aerodynamic behaviour. It makes plane design rather frustrating.

Link to comment
Share on other sites

On an unrelated note, is the issue with inconsistent behaviour from the analysis tools likely to be resolved. Simple things like reloading the craft, or making a change and then undoing it, have a habit of changing the reported aerodynamic behaviour. It makes plane design rather frustrating.

I think that bug has been known for a while. The cause less so.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...