Board index FlightGear Development New features

Dynamic pitch and yaw offsets for submodels

Discussion and requests for new features. Please note that FlightGear developers are volunteers and may or may not be able to consider these requests.

Dynamic pitch and yaw offsets for submodels

Postby onox » Mon May 18, 2015 5:11 pm

My patches have been committed to flightgear, so it's now possible to change the pitch and yaw offsets of a <submodel>. This is very useful for guns, etc. The patches are backwards compatible with old aircraft code that uses static numbers.

For example:

Code: Select all
<yaw-offset>
    <property>/carrier/phalanx/output/forward-left/yaw-deg</property>
    <offset>-90.0</offset>
</yaw-offset>
<pitch-offset>
    <property>/carrier/phalanx/output/forward-left/pitch-deg</property>
</pitch-offset>


It works just like how it works in an <autopilot> file. So you can use <property>, <expression>, <value>, <scale>, <offset>, <min>, <max>, <abs>, <period>.
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 2:45 pm

Re: Dynamic pitch and yaw offsets for submodels

Postby Thorsten » Mon May 18, 2015 5:13 pm

Nice :-) That should be very useful.
Thorsten
 
Posts: 11463
Joined: Mon Nov 02, 2009 8:33 am

Re: Dynamic pitch and yaw offsets for submodels

Postby Tomaskom » Mon May 18, 2015 8:22 pm

That is something I was hoping for! :D
Now let's go make some AA guns for Bombable :twisted:
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Re: Dynamic pitch and yaw offsets for submodels

Postby Tomaskom » Tue May 19, 2015 11:01 am

First of all, once again thanks a lot for committing the submodel orientation patch! I already compiled latest git next branch and will go test it.

While at it, I had an idea: would it be possible to implement direction dispersion? This would be quite useful especially for guns. Particles can be set in a quite detailed way, but submodels currently offer only the <random> option, which varies azimuth (only, not elevation) by a fixed value (-+5deg) and also introduces changes to drag (10%) and life (customizable). No need to go as detailed as particles do, a simple dispersion parameter in deg would be perfect.
My guess is separating those and enabling user-set values instead of fixed ones won't be much more difficult than the orientation functionality, since the code handling it is already there, just using fixed values. The related Azimuth and Elevation assignment seem to happen at AIModel/AIBallistic.cxx:272, where the fixed 10deg dispersion for azimuth can be seen. Unfortunately I have no experience with the fgfs C++ codebase (but I intend to change that in the future).
I can't see why whoever designed this didn't allow more flexibility right away... Maybe not at the time, but now it seems obvious how useful it could be.
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Re: Dynamic pitch and yaw offsets for submodels

Postby Necolatis » Tue May 19, 2015 3:35 pm

I agree with Tomaskom, more control over the randomize property would be awesome.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2076
Joined: Mon Oct 29, 2012 12:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2019.1.2
OS: Windows 10

Re: Dynamic pitch and yaw offsets for submodels

Postby Tomaskom » Tue May 19, 2015 4:20 pm

Some feedback from my tests: Works really well under normal circumstances when the yaw is changing smoothly. However there seems to be some normalization issue: if I jump the yaw control property to some rather high value out of the 0-360 range, like 5000 or -5000, there is a noticeable error in the pitch orientation. In extreme cases the pitch can be straight up when it should be ~15deg. Other models and a particle system I have in place controlled by the same properties work OK.
That's weird, because extreme values in yaw are influencing pitch (yaw seems fine in those cases). I saw it happen even with relatively small yaw values, like -60 causing it to aim parallel to the ground instead of ~30deg pitch, but the only way I was able to reproduce it really reliably was to set a high yaw value.
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Re: Dynamic pitch and yaw offsets for submodels

Postby onox » Tue May 19, 2015 6:09 pm

I can fix azimuth, elevation, cd, and life. It seems that cd and life are wrong anyway. cd is between 90% and 100% (0 to -10%) instead of +-10%. Same thing for life.

About your pitch problem: have you tried to do geo.normdeg()? Can you send me a link to the code in a PM or here?
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 2:45 pm

Re: Dynamic pitch and yaw offsets for submodels

Postby Tomaskom » Wed May 20, 2015 8:26 am

onox wrote in Tue May 19, 2015 6:09 pm:About your pitch problem: have you tried to do geo.normdeg()? Can you send me a link to the code in a PM or here?

That won't help me much, I'm using almost continuous interpolation, so it would go in the wrong way when crossing the 0/360 deg boundary. And I saw it even for values within this range once, but setting high values was the easiest way to reproduce it.
I could interpolate the value to normalized one in zero time first (to stop ongoing interpolation, setprop doesn't stop them) and then start the interpolation I want, but that doesn't seem as a clean solution. Clean solution would be for it to work with any values, normalizing internally if necessary. But I think the problem is more tricky than that.

I will prepare some minimized code for reproducing the issue for you later today.
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Re: Dynamic pitch and yaw offsets for submodels

Postby Torsten » Wed May 20, 2015 9:21 am

Hi guys,

those dynamic properties use the InputValue functionality from the autopilot and you may use <periodic> and <max> and <min> to limit/transform the input:
http://wiki.flightgear.org/Autopilot_co ... Cperiod.3E

Torsten
flightgear.org - where development happens.
User avatar
Torsten
 
Posts: 638
Joined: Fri Feb 01, 2008 9:22 pm
Location: near Hamburg, Germany
Callsign: offline
Version: next
OS: Linux

Re: Dynamic pitch and yaw offsets for submodels

Postby Tomaskom » Wed May 20, 2015 9:54 pm

After I conducted extensive tests, I discovered it didn't depend on any extreme values.
Download this:
https://www.dropbox.com/s/krghpqppn2gub ... m.zip?dl=0
and use it as aircraft (called "SubmodelAim").

First you can try varying the values in property tree under aim/ and see how it aims flawlessly with any values.

But once you start changing the "aircraft" orientation too, things get tricky.

Set these values:
orientation/ heading-deg=80 pitch-deg=15, roll-deg=25
aim/ pitch=85, yaw=110

And the submodels will aim way off from the red aiming aid. Now you can see that slightly varying the values can have huge effect on the offset.

And note that all the values are in the expected ranges, whether it is 0,360 or -180,180 for yaw.

The reason why I had to use huge pitch and yaw values was that my aircraft pitch and roll were very small, less than 0.1deg.

Tom
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Re: Dynamic pitch and yaw offsets for submodels

Postby onox » Wed May 20, 2015 11:05 pm

Thanks Tomaskom, this will help me to debug it.
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 2:45 pm

Re: Dynamic pitch and yaw offsets for submodels

Postby onox » Fri May 22, 2015 9:08 am

I have fixed the offset bug. The initial azimuth and elevation computation was incorrect. Still need to test the randomness of azimuth and elevation. After that, I want to add <offsets> with <x-m>, <y-m>, and <z-m> like in regular model xml files.

Will send the patches to the mailing list in the weekend.
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 2:45 pm

Re: Dynamic pitch and yaw offsets for submodels

Postby onox » Sun May 24, 2015 7:44 am

I have sent all the patches to the mailing list, but I need to wait for a moderator to approve the posting because I went over the limit of 40 kb :(
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 2:45 pm

Re: Dynamic pitch and yaw offsets for submodels

Postby onox » Thu May 28, 2015 9:48 am

Patches have been committed to git. For randomness you use:

Code: Select all
<randomness>
    <azimuth>0.0</azimuth>
    <elevation>0.0</elevation>
    <cd>0.1</cd>
    <life>0.5</life>
</randomness>


These are the defaults, so you don't need to explicitly add them.

Another new thing is you can define the offsets in meters instead of feet. To do this you use:

Code: Select all
<offsets>
    <x-m>0.0</x-m>
    <y-m>0.0</y-m>
    <z-m>0.0</z-m>
    <yaw>0.0</yaw>
    <pitch>0.0</pitch>
</offsets>


Note 1: If you use <offsets>, you must write <yaw> and <pitch> instead of <yaw-offset> and <pitch-offset>

Note 2: The x axis of <x-m> is flipped/reversed. It's now in the same direction as the main model xml file.

Note 3: old aircraft can continue to use the <*-offset> elements as long as they do not add <offsets>.
onox
Retired
 
Posts: 431
Joined: Fri Jun 20, 2014 2:45 pm

Re: Dynamic pitch and yaw offsets for submodels

Postby Tomaskom » Thu May 28, 2015 3:49 pm

The aiming now works flawlessly, nice :)

However, I failed to get the randomness to work, I'm using this submodel code:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>

<PropertyList>


  <PhalanxCannon>
    <model>Aircraft/Type-45/PhalanxSandbox_Tom/Tracer.xml</model>
    <speed>3600</speed>
    <cd>0.295</cd>
    <weight>0.225</weight>
    <eda>0.00338</eda>
    <fuse-range>0</fuse-range>
    <life>30</life>
    <expiry>true</expiry>
    <repeat>true</repeat>
    <count>-1</count>
    <wind>false</wind>
    <collision>true</collision>
    <collision-report>sim/ai/aircraft/collision/gun</collision-report>
    <impact>true</impact>
    <impact-report>sim/ai/aircraft/impact/bullet</impact-report>
    <pitch-offset>0</pitch-offset>
  </PhalanxCannon>
 
 
  <submodel>
    <name>Phalanx left - cannon</name>
    <model alias="../../PhalanxCannon/model"/>
    <trigger>armament/phalanx/firing</trigger>
    <speed alias="../../PhalanxCannon/speed"/>
    <cd alias="../../PhalanxCannon/cd"/>
    <eda alias="../../PhalanxCannon/eda"/>
    <fuse-range alias="../../PhalanxCannon/fuse-range"/>
    <weight alias="../../PhalanxCannon/weight"/>
    <life alias="../../PhalanxCannon/life"/>
    <repeat alias="../../PhalanxCannon/repeat"/>
    <delay>0.0222</delay>
    <count alias="../../PhalanxCannon/count"/>
    <wind alias="../../PhalanxCannon/wind"/>
    <expiry alias="../../PhalanxCannon/expiry"/>
    <collision alias="../../PhalanxCannon/collision"/>
    <collision-report alias="../../PhalanxCannon/collision-report"/>
    <impact alias="../../PhalanxCannon/impact"/>
    <impact-report alias="../../PhalanxCannon/impact-report"/>
    <submodel-path alias="../../PhalanxCannon/submodel-path"/>
    <x-offset>-34.225 </x-offset> <!-- 10.4319 m to ft -->
    <y-offset>-29.040 </y-offset> <!-- -8.8514 m to ft -->
    <z-offset> 31.004 </z-offset> <!--  9.45   m to ft -->
    <yaw-offset>
      <property>/armament/phalanx/rotation-deg</property>
      <offset>0</offset>
    </yaw-offset>
    <pitch-offset>
      <property>/armament/phalanx/elevation-deg</property>
    </pitch-offset>
    <randomness>
      <azimuth>10.15</azimuth>
      <elevation>10.15</elevation>
      <cd>0.0</cd>
      <life>0.0</life>
    </randomness>
  </submodel>


</PropertyList>


The azimuth and elevation randomness values are pumped up to make it clearly visible, but no randomness occurs. What do I have wrong?
"There are no problems in the air. The only problem is hitting the ground"

Get my L-159 ALCA from the FGUK hangar. If you crash it, things gonna go boom!
User avatar
Tomaskom
 
Posts: 132
Joined: Sun Dec 02, 2012 8:03 pm
Location: Czech Republic
Callsign: OK-TomK
Version: git
OS: openSUSE (Linux)

Next

Return to New features

Who is online

Users browsing this forum: No registered users and 0 guests