Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Addons > Addon Development
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Addon Development Developers post news, updates, & discussions here about your projects in development.

Reply
 
Thread Tools
Old 04-12-2018, 01:17 PM   #31
Ripley
Tutorial translator
 
Ripley's Avatar
Default

I guess he'll PM his email address to you.
Ripley is offline   Reply With Quote
Old 04-12-2018, 01:51 PM   #32
Marijn
Orbinaut
 
Marijn's Avatar
Default

Quote:
Originally Posted by Ripley View Post
 I guess he'll PM his email address to you.
That's the easiest way. @zachary77, if you PM me your email, I'll reply with the model attached.
Marijn is offline   Reply With Quote
Old 04-12-2018, 03:43 PM   #33
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Quote:
Originally Posted by Thorsten View Post
 Umm, what is a state machine?

I guess calling it a kind of coding philosophy describes it best...

Something that has internal states, can receive inputs to change the states and does outputs dependent on input and internal state.
Well yes. I prefer calling it a tool, because using a finite state machine in a design is not the same as the implementation - you can have many different ways to implement the same state machine, still all behave similar.

You might even want to make a state machine around a state machine (which could then be designed equally as a single state machine - but gets more complicated to understand then).

Like: You have three flap positions: Retracted (R), take-off (T) and landing (L).

These would also be states in your state machine.

For getting from one to the other, you would need a transition. Now, if you don't want to instantly switch from retracted to take-off, you would also need states between, which describe when your flap in in motion.

So, you would have the following states:

R, T, L, RT, TL, LT, TR.

Maybe you also want to skip over T and instantly go from retracted to landing or landing to retracted. Then you could have also the states RL and LR.

Now, you also need rules that describe how you get from one state to the other.

For example:

If you press F on the keyboard (the event 'OAPI_KEY_F'), the following transitions could happen depending on the current state:

R -> RT
T -> TL
L -> LT
T' -> TR

T' is here a special clone of state T, which represents "T while retracting flaps". Its exactly the same as T, it just reacts differently to the event.

For implementing such a state machine, it could be as simple as just have a numeric constant representing each state, storing the current state as int or better as enum.

It just helps knowing the states you need in advance then, because extending such a state machine can become increasingly difficult.

Or you have a State Pattern in OOP, which also works in C++:

https://en.wikipedia.org/wiki/State_pattern
Urwumpe is online now   Reply With Quote
Old 04-12-2018, 05:40 PM   #34
Marijn
Orbinaut
 
Marijn's Avatar
Default

Quote:
Originally Posted by zachary77 View Post
 Current features:
  • Glide ratio 20:1
  • Ballast to fine-tune glide speed
So, what do you guys think? Feature requests? Fire away!
zachary77
The glide ratio, when given as a single number like 20:1 or just 20, always means the BEST glide ratio. Any best glide ratio is only true at a certain speed (and pressure). Any other speed, either faster or slower, means a less favorable glide ratio is realized. If you plot the horizontal speed of a glider on the x-axis against the vertical speed on the y, you will get a curved line called a polar. This is the single most important characteristic of any glider. I think your add-on should reflect this. And it's rather easy to implemend I would say. Example: http://sarmed.netfirms.com/pakglidin...ders/asw28.htm

A polar can be described with just three pairs of speeds and two weights like in the example below:

*ASW-20 WinPilot POLAR file: MassDryGross[kg], MaxWaterBallast[liters], Speed1[km/h], Sink1[m/s], Speed2, Sink2, Speed3, Sink3
377, 159, 116.2, -0.77, 174.3, -1.89, 213.04, -3.3

Current onboard flight-computers use this format. With these numbers, you can express the polar as a simple quadratic equation which can give you the sink speed for any airspeed with high accuracy. Also, you can adjust for headwind, tailwind, sink and lift by shifting the polar to the left, right, down and up. Corrections for changes in ballast can also be implemented.

The math is quite elegant and not very difficult I would say: Ws = aV≤ + bV + c.

I can help with giving you the formulas to get a, b and c.

If you do it correctly, you will find that carrying any ballast without encountering natural sources of lift and or headwinds will always compromise the performance. The same is true for using negative flaps.
Marijn is offline   Reply With Quote
Old 04-12-2018, 06:00 PM   #35
Urwumpe
Certain Super User
 
Urwumpe's Avatar

Default

Well lets describe it like that: A nominal flight condition polar. Since all gliders are only reaching very small Mach numbers and use rather conventional wing profiles, its easy to use such an approximation without big differences to the real flight behavior.

But if you are approaching stall, are spinning or tumbling, the lift function enters the place where the simple approximation won't work anymore.
Urwumpe is online now   Reply With Quote
Old 04-12-2018, 11:13 PM   #36
zachary77
Orbinaut
Default

Quote:
Originally Posted by Marijn View Post
 The glide ratio, when given as a single number like 20:1 or just 20, always means the BEST glide ratio. Any best glide ratio is only true at a certain speed (and pressure). Any other speed, either faster or slower, means a less favorable glide ratio is realized. If you plot the horizontal speed of a glider on the x-axis against the vertical speed on the y, you will get a curved line called a polar. This is the single most important characteristic of any glider. I think your add-on should reflect this. And it's rather easy to implemend I would say. Example: http://sarmed.netfirms.com/pakglidin...ders/asw28.htm

A polar can be described with just three pairs of speeds and two weights like in the example below:

*ASW-20 WinPilot POLAR file: MassDryGross[kg], MaxWaterBallast[liters], Speed1[km/h], Sink1[m/s], Speed2, Sink2, Speed3, Sink3
377, 159, 116.2, -0.77, 174.3, -1.89, 213.04, -3.3

Current onboard flight-computers use this format. With these numbers, you can express the polar as a simple quadratic equation which can give you the sink speed for any airspeed with high accuracy. Also, you can adjust for headwind, tailwind, sink and lift by shifting the polar to the left, right, down and up. Corrections for changes in ballast can also be implemented.

The math is quite elegant and not very difficult I would say: Ws = aV≤ + bV + c.

I can help with giving you the formulas to get a, b and c.

If you do it correctly, you will find that carrying any ballast without encountering natural sources of lift and or headwinds will always compromise the performance. The same is true for using negative flaps.
Well, thatís a bit outdated now. I managed to nudge it to 40:1. But, yes, I get your point. Could you give me the formulas? Thanks
zachary77 is offline   Reply With Quote
Old 04-13-2018, 12:21 AM   #37
Marijn
Orbinaut
 
Marijn's Avatar
Default

The model is in your inbox. It's an ASW28.
Marijn is offline   Reply With Quote
Thanked by:
Old 04-13-2018, 06:31 AM   #38
zachary77
Orbinaut
Default

Quote:
Originally Posted by Marijn View Post
 The model is in your inbox. It's an ASW28.
I got it, thanks. I'll see what I can do.
zachary77 is offline   Reply With Quote
Old 04-13-2018, 07:41 AM   #39
Marijn
Orbinaut
 
Marijn's Avatar
Default

Quote:
Originally Posted by zachary77 View Post
 Could you give me the formulas? Thanks
I found a complete copy of Helmut Reichmann's Cross-Country Soaring. This famous book explains all the theory. Have a look at page 105:

https://www.j2mcl-planeurs.net/dbj2m...mann_1978).pdf
Marijn is offline   Reply With Quote
Thanked by:
Old 04-15-2018, 05:18 AM   #40
zachary77
Orbinaut
Default

I'm having issues with XRSound. I'm initialising it in clbkPostCreation like so:
Code:
void Glider::clbkPostCreation()
{
	XRSound *CreateInstance(VESSEL *pVessel);

}
But when I ask it to play a sound, like this:
Code:
XRSound::PlayWav(10037, true, 1.0);
I get "a nonstatic member reference must be relative to a specific object".
How do I fix this?
zachary77 is offline   Reply With Quote
Old 04-15-2018, 07:49 AM   #41
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by zachary77 View Post
 I'm having issues with XRSound. I'm initialising it in clbkPostCreation like so:
Code:
void Glider::clbkPostCreation()
{
	XRSound *CreateInstance(VESSEL *pVessel);

}
But when I ask it to play a sound, like this:
Code:
XRSound::PlayWav(10037, true, 1.0);
I get "a nonstatic member reference must be relative to a specific object".
How do I fix this?
You should learn more about pointers and classes in C++.

You need a private field in your class that holds the XRSound instance pointer. Let's say it is called "sound". You'd declare it in your class header:
Code:
#include "XRSound.h"
class Glider: public VESSEL4 {
...
private:
     XRSound *sound;
}
Then you assign the new instance pointer to this field like so:
Code:
void Glider::clbkPostCreation()
{
	sound = XRSound::CreateInstance(this);
}
To play sound, you have to dereference the pointer in the sound field like so:
Code:
sound->PlayWav(10037, true, 1.0);
In the destructor, you do this to clean up memory:
Code:
delete sound;
Face is offline   Reply With Quote
Thanked by:
Old 04-15-2018, 12:32 PM   #42
zachary77
Orbinaut
Default

Alright, that works. But now I get this:
Code:
1>------ Build started: Project: Glider, Configuration: Release Win32 ------
1>LINK : fatal error C1047: The object or library file '..\..\..\..\Desktop\Orbiter\Orbitersdk\XRSound\XRSound.lib' was created with an older compiler than other objects; rebuild old objects and libraries
1>LINK : fatal error LNK1257: code generation failed
1>Done building project "Glider.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
zachary77 is offline   Reply With Quote
Old 04-15-2018, 01:55 PM   #43
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by zachary77 View Post
 
Code:
1>LINK : fatal error C1047: The object or library file '..\..\..\..\Desktop\Orbiter\Orbitersdk\XRSound\XRSound.lib' was created with an older compiler than other objects; rebuild old objects and libraries
Rebuilding of the library is only possible with the source code at hand. I think you have to talk to dbeachy1 for this. With my VS 2015, the lib is linking fine. What VS version do you use?
Face is offline   Reply With Quote
Old 04-15-2018, 05:27 PM   #44
dbeachy1
O-F Administrator
 
dbeachy1's Avatar


Default

Quote:
Originally Posted by zachary77 View Post
 Alright, that works. But now I get this:
Code:
1>------ Build started: Project: Glider, Configuration: Release Win32 ------
1>LINK : fatal error C1047: The object or library file '..\..\..\..\Desktop\Orbiter\Orbitersdk\XRSound\XRSound.lib' was created with an older compiler than other objects; rebuild old objects and libraries
1>LINK : fatal error LNK1257: code generation failed
1>Done building project "Glider.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
From Googling for C1047, it looks like this is happening because your VS 2017 project has Link Time Code Generation enabled in your project settings, which an optional feature of Visual Studio to (apparently?) speed up compilation times. XRSound is built with Visual Studio 2015.

If you disable Link Time Code Generation in your project settings (Project properties -> Linker -> Optimization ->Link Time Code Generation -> Set to "default" to disable it), then it will hopefully build successfully.
dbeachy1 is offline   Reply With Quote
Thanked by:
Old 04-16-2018, 10:13 AM   #45
zachary77
Orbinaut
Default

Quote:
Originally Posted by dbeachy1 View Post
 From Googling for C1047, it looks like this is happening because your VS 2017 project has Link Time Code Generation enabled in your project settings, which an optional feature of Visual Studio to (apparently?) speed up compilation times. XRSound is built with Visual Studio 2015.

If you disable Link Time Code Generation in your project settings (Project properties -> Linker -> Optimization ->Link Time Code Generation -> Set to "default" to disable it), then it will hopefully build successfully.
Just tried it, no luck...
Code:
1>------ Build started: Project: Glider, Configuration: Release Win32 ------
1>Glider.obj : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>LINK : fatal error C1047: The object or library file '..\..\..\..\Desktop\Orbiter\Orbitersdk\XRSound\XRSound.lib' was created with an older compiler than other objects; rebuild old objects and libraries
1>LINK : fatal error LNK1257: code generation failed
1>Done building project "Glider.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
zachary77 is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Addons > Addon Development

Tags
glider, o2016


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 08:47 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright ©2007 - 2017, Orbiter-Forum.com. All rights reserved.