Board index FlightGear Development Aircraft Cockpit development

speedo Drum settings

Discussion about creating 2d and 3d cockpits.

speedo Drum settings

Postby RobAndrew » Tue Nov 12, 2019 8:42 pm

Howdy to all...

I am currently trying to redesign a cockpit. There are several areas that need work doing to animations as i've done all the 3D needed so far. However there are a couple of, rather complicated examples. One being the speedometer.

There are 4 drums that represent the velocity at which you're traveling, and below these, a dial that can be turned to select the speed shown, between "Off", "TAS" and "GS". Now I can animate these fine, when the dial is clicked, the drums turn to represent the speed-in "TAS" that is. However when flipped from "TAS" to "GS" the value doubles for some reason. say from 0234, to 0468. Then when flipping back to "TAS" it doesn't half it's value again, just stays at that double value, and the drums move from that value.
Now i've tried a few different things to try and solve this, but to no avail. I've talked to a couple of people on Discord about it, but again to no avail. I do have the code and pictures of the device if needed, but, i've forgotten how to get them on here!

There a few instruments with the same form of makeup in the cockpit which I would like to get working as well. But i'd like to start as simple as possible with this one. When i've got this working correctly I can move on to the others!

Hopefully someone here knows what i'm talking about and can get me on the right track. Thank you
RobAndrew
 
Posts: 134
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: speedo Drum settings

Postby Maerchenprinz » Tue Nov 12, 2019 9:14 pm

Hi Rob!

Code: Select all
Simply paste  your code between "[code]" and "[/code]" (without quotation marks), or just click the 5th symbol of the edit bar.

It is very difficult to give a solution without looking at your code, though I have a slight suspicion of where the Problem might be.
Ciao,

Adrian
User avatar
Maerchenprinz
 
Posts: 245
Joined: Thu Mar 15, 2007 5:24 pm
Location: Bochum, it's better, much better than you think!
Callsign: Adrian

Re: speedo Drum settings

Postby RobAndrew » Tue Nov 12, 2019 10:11 pm

Rightho! Well let's see if this works then...

Code: Select all
<?xml version="1.0"?>
<PropertyList>
 <path>airspeed_indicator.ac</path>   

  <animation>
   <type>rotate</type>
   <object-name>Cylinder.012</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>1</value>
       </equals>
   </condition>
   <property>velocities/airspeed-kt</property>
   <factor>36</factor>
   <center>
    <x-m>-0.038</x-m>
    <y-m>0.008</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

  <animation>
   <type>rotate</type>
   <object-name>Cylinder.012</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>2</value>
       </equals>
   </condition>
   <property>velocities/groundspeed-kt</property>
   <factor>36</factor> 
   <center>
    <x-m>-0.038</x-m>
    <y-m>0.008</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

   <animation>
   <type>rotate</type>
   <object-name>Cylinder.013</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>1</value>
       </equals>
   </condition>
   <property>velocities/airspeed-kt</property>
   <factor>3.6</factor> 
   <center>
    <x-m>-0.038</x-m>
    <y-m>-0.005</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

  <animation>
   <type>rotate</type>
   <object-name>Cylinder.013</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>2</value>
       </equals>
   </condition>
   <property>velocities/groundspeed-kt</property>
   <factor>3.6</factor>
   <center>
    <x-m>-0.038</x-m>
    <y-m>-0.005</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

  <animation>
   <type>rotate</type>
   <object-name>Cylinder.014</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>1</value>
       </equals>
   </condition>
   <property>velocities/airspeed-kt</property>
   <factor>0.36</factor> 
   <center>
    <x-m>-0.038</x-m>
    <y-m>0.001</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

     <animation>
   <type>rotate</type>
   <object-name>Cylinder.014</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>2</value>
       </equals>
   </condition>
   <property>velocities/groundspeed-kt</property>
   <factor>0.36</factor>
   <center>
    <x-m>-0.038</x-m>
    <y-m>0.001</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

  <animation>
   <type>rotate</type>
   <object-name>Cylinder.015</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>1</value>
       </equals>
   </condition>
   <property>velocities/airspeed-kt</property>
   <factor>0.036</factor> 
   <center>
    <x-m>-0.038</x-m>
    <y-m>-0.012</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

   <animation>
   <type>rotate</type>
   <object-name>Cylinder.015</object-name>
   <condition>
       <equals>
            <property>B1b/airspeed-indicator</property>
            <value>2</value>
       </equals>
   </condition>
   <property>velocities/groundspeed-kt</property>
   <factor>0.036</factor>
   <center>
    <x-m>-0.038</x-m>
    <y-m>-0.012</y-m>
    <z-m>0.006</z-m>
   </center>
   <axis>
    <x>0</x>
    <y>-1</y>
    <z>0</z>
   </axis>
  </animation>

  <animation>
        <type>knob</type>
        <object-name>Airspeed-type-knob</object-name>
        <property>B1b/airspeed-indicator</property>
        <factor>45</factor>
        <center>
            <x-m>-0.013</x-m>
            <y-m>0.007</y-m>
            <z-m>-0.016</z-m>
        </center>
        <axis>
            <x>-1</x>
            <y>0</y>
            <z>0</z>
        </axis>       
        <action>
            <binding>
                <command>property-adjust</command>
                <property>B1b/airspeed-indicator</property>
                <min>0</min>
                <max>2</max>               
                <wrap>false</wrap>
           </binding>
        </action>
    </animation>
</PropertyList>


I know there's quite a lot there. It's just the different settings between the dial. The REAL interesting part is at the bottom of it all, in the last paragraph. I feel the issue is in there somewhere, but not to sure where...
RobAndrew
 
Posts: 134
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: speedo Drum settings

Postby WoodSTokk » Wed Nov 13, 2019 12:08 am

RobAndrew wrote in Tue Nov 12, 2019 10:11 pm:Rightho! Well let's see if this works then...

code snipped

I know there's quite a lot there. It's just the different settings between the dial. The REAL interesting part is at the bottom of it all, in the last paragraph. I feel the issue is in there somewhere, but not to sure where...


The problem is that you have conditioned animations.
In such cases i make an unconditioned animation on one property and feet this property with a prop-rule.
In your case set the rotate animation unconditioned to a fixed property like:
Code: Select all
  <animation>
    <type>rotate</type>
    <object-name>Cylinder.012</object-name>
    <property>B1b/displayed-speed</property>
    <factor>36</factor>
    <center>
      <x-m>-0.038</x-m>
      <y-m>0.008</y-m>
      <z-m>0.006</z-m>
    </center>
    <axis>
      <x>0</x>
      <y>-1</y>
      <z>0</z>
    </axis>
  </animation>

The same for the other animations.
And feet the property 'B1b/displayed-speed' with a prop-rule like:
Code: Select all
<filter>
    <name>displayed speed</name>
    <type>gain</type>
    <debug>false</debug>
    <input>
        <condition>
            <equals>
                <property>B1b/airspeed-indicator</property>
                <value>1</value>
            </equals>
        </condition>
        <property>velocities/airspeed-kt</property>
    </input>
    <input>
        <condition>
            <equals>
                <property>B1b/airspeed-indicator</property>
                <value>2</value>
            </equals>
        </condition>
        <property>velocities/groundspeed-kt</property>
    </input>
    <output>B1b/displayed-speed</output>
</filter>
WoodSTokk
 
Posts: 742
Joined: Tue Oct 17, 2017 2:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: OE-WST
IRC name: WoodSTokk
Version: 2020.3.0
OS: Debian Buster

Re: speedo Drum settings

Postby Maerchenprinz » Wed Nov 13, 2019 1:06 am

Hi Rob!

I was facing a similar problem (a drum fuel counter), and someone pointed me to the explanation for this phenomenon.

The good news: I could finally find the post with the explanation, otherwise I would have had to mumble-stutter something like "It has something to do with a rotation-matrix-thingy or something..." :?
https://forum.flightgear.org/viewtopic.php?f=47&t=28967
The bad news: Doesn't work the way you (and me) tried first - It is impossible to "drive" an animation by more than one property.
The good news: There's a simple solution; Just write a tiny nasal script to "feed" one property by two or more sources*
The bad news (now this becomes really mood-swaying): I haven't yet written the script for my similar case , so I can't post it as a template - I knew there was something on my ToDo-list... The counter "counts" fuel flow in the background even it is not on, so it doesn't start counting when turned on, instead jumps to the background value. :oops:

* Or maybe using <expression> in your .xml may fit your needs?
like:
Code: Select all
  <expression>
   <sum>
      <product>
       <property>B1b/airspeed-indicator</property>
       <property>B1b/speedo-switch-gs</property><!-- toggle 0 and 1 -->
      </product>
      <product>
       <property>velocities/airspeed-kt</property>
       <property>B1b/speedo-switch-tas</property><!-- toggle 1 and 0 -->
      </product>
      </sum>
  </expression>




Ciao,

Adrian

EDIT: Argh! WoodStokk posted while I was still writing... The prop-rule solution surely looks more elegant!
User avatar
Maerchenprinz
 
Posts: 245
Joined: Thu Mar 15, 2007 5:24 pm
Location: Bochum, it's better, much better than you think!
Callsign: Adrian

Re: speedo Drum settings

Postby RobAndrew » Wed Nov 13, 2019 7:33 pm

Okay, great reply guys, thanks very much. This will surely aid me finish what i've started! I think I'll go with that first suggestion...

So digging in a bit, that <filter> you mention, Is that a paragraph that would finish the file, and go beneath everything else, just like my knob animation in my example? Also, I'm guessing i'd need to keep that binding animation for the knob?

I probably should mention that I have little experience in this, so please do be patient with my lack of knowledge and bad terminology!

*I will also correct myself from what I said before and state that the Discord community have been a great help and have got me as far as I am now. Without them, I wouldn't have started this project!....Just for if any of them are reading this...*
RobAndrew
 
Posts: 134
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: speedo Drum settings

Postby WoodSTokk » Thu Nov 14, 2019 12:58 am

Filters (or exactly Property Rules) must by included in the set-file (like autopilot files).
Make a new file and name it 'B1b-filters.xml' with the following content:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
</PropertyList>

    <filter>
        <name>displayed speed</name>
        <type>gain</type>
        <debug>false</debug>
        <input>
            <condition>
                <equals>
                    <property>B1b/airspeed-indicator</property>
                    <value>1</value>
                </equals>
            </condition>
            <property>velocities/airspeed-kt</property>
        </input>
        <input>
            <condition>
                <equals>
                    <property>B1b/airspeed-indicator</property>
                    <value>2</value>
                </equals>
            </condition>
            <property>velocities/groundspeed-kt</property>
        </input>
        <output>B1b/displayed-speed</output>
    </filter>

</PropertyList>


open the set-file and include it as 'property-rule' under <sim>, <systems>:
Code: Select all
<PropertyList>

  <sim>

  <systems>
      <property-rule n="100">
        <path>Path/to/your/file/B1b-filters.xml</path>
      </property-rule>

  </systems>




It's important to set the number (n="xxx") to a number above 100 and it must by unique.
WoodSTokk
 
Posts: 742
Joined: Tue Oct 17, 2017 2:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: OE-WST
IRC name: WoodSTokk
Version: 2020.3.0
OS: Debian Buster

Re: speedo Drum settings

Postby Johan G » Thu Nov 14, 2019 1:16 pm

The FlightGear wiki article Autopilot configuration reference (permalink) might be of help. It is about setting up, configuring and using property rules (as that is what is used by the default autopilot system).
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Johan G
Moderator
 
Posts: 6202
Joined: Fri Aug 06, 2010 5:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: speedo Drum settings

Postby RobAndrew » Fri Nov 15, 2019 11:40 pm

Okay, so i'm getting somewhere!

Now the tricky part-I'm trying to get the drums to "Click" as such. So that as soon as 00001 has gone all the way round, just after (and not during) the next will go around to 1 as such. So when one does 360 degrees, the second will do 36 degrees after, and so on, if that makes any sense to anyone...

I was recently given a piece of code to help with that, but it's not working very well and I can't think why. I keep getting the error "Nasal runtime error: Nil used in numeric context" Now i've been told that it's the code wanting a number, and not getting one. But the property that the bellow code is asking for does work, and shows the correct values. This is what I have:

Code: Select all
var fuelDigits = func {
    var fuel = getprop("B1b/fuel-tank-selector/displayed-fuel");
    var a = int((fuel*1-int(fuel*1))*10);
    var b = int((fuel*0.1-int(fuel*0.1))*10);
    var c = int((fuel*0.01-int(fuel*0.01))*10);
    var d = int((fuel*0.001-int(fuel*0.001))*10);
    var e = int((fuel*0.0001-int(fuel*0.0001))*10);
    setprop("B1b/fuel—tank-selector/displayed-fuel-digit-1", a);
    setprop("B1b/fuel—tank-selector/displayed-fuel-digit-2", b);
    setprop("B1b/fuel—tank-selector/displayed-fuel-digit-3", c);
    setprop("B1b/fuel—tank-selector/displayed-fuel-digit-4", d);
    setprop("B1b/fuel—tank-selector/displayed-fuel-digit-5", e);
    settimer(fuelDigits,0.2);
  }
fuelDigits();


What's more is the new properties do show, but just don't show the values. This may be down to the same named properties being in the animation files though. This piece of nasal is in it's own file and has been added to the set.xml file which I believe recognizes it. I think.

Any way thanks for looking, please let me know if you have any advice on the matter!
RobAndrew
 
Posts: 134
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: speedo Drum settings

Postby WoodSTokk » Sat Nov 16, 2019 3:49 am

Rotating a full drum makes only sense if you see the full drum, but i think you want animate drums in a instrument where you see only the front section.
I strongly recommend to use a drum section with a texture animation (textranslate).
A textranslate have many useful properties to make a realy good animation and you dont need a nasal script.

As an example, look at the altimeter in the Citation II.
If you want, i send you the blender file.
WoodSTokk
 
Posts: 742
Joined: Tue Oct 17, 2017 2:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: OE-WST
IRC name: WoodSTokk
Version: 2020.3.0
OS: Debian Buster

Re: speedo Drum settings

Postby RobAndrew » Sat Nov 16, 2019 10:48 pm

okay, that's great. But doing this, you need to find the amount of pixels in the area of your texture file you're using. I can only find the amount of pixels of the entire page, something like 2, 067,600 or something like that. How would I go about finding the pixels in the one area that i'm using in the texture file?
RobAndrew
 
Posts: 134
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: speedo Drum settings

Postby WoodSTokk » Sun Nov 17, 2019 2:06 am

In the lower area of the screenshot, you see the texture of the altimeter.
As you can see, the digits are on the right side on the texture and goes from bottom to top.
The size of the image doesn't matter. The engine scales the image allways from 0 to 1.
Horizontal: 0 is left side - 1 is right side
Vertical: 0 is bottom - 1 is top
As we have ten digits from bottom to top, every step is a textranslate of 0.1 on the y-axis.
You map every drum section in Blender with the '0'. If you move the mapping with textranslate 0.1 units up, you will see the digit '1' on the drum.
Here is a screenshot of the middle drum in edit mode to see the UV mapping:
Image
WoodSTokk
 
Posts: 742
Joined: Tue Oct 17, 2017 2:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: OE-WST
IRC name: WoodSTokk
Version: 2020.3.0
OS: Debian Buster

Re: speedo Drum settings

Postby RobAndrew » Sun Nov 17, 2019 6:51 pm

Okay, I like the idea, but it won't work. Firstly, the texture of the backing is not it's own texture. It is part of a larger texture full of other things for different parts. So when it goes past "1", it scrolls through the rest of the stuff above it until it gets back to zero, on the other end of the page...
Secondly, this doesn't solve the issue of why my nasal isn't working. I've made a nasal script so that the numbers "Click" as such, so the numbers are clear and lined up, all the time. Instead of half scrolled when the value of the drum next to it is at 5. I see textranslating as an alternative to rotating, but it won't do anything else that rotating won't. It doesn't "Click" the numbers without needing a nasal script to make it so. Or it won't give you a filter when you need to switch the values of the drums to different properties (Like TAS and GS).
So my issue still stands: I've narrowed it down to (Surprise Surprise) my small nasal paragraph above. Which I've added to the end of another nasal file, but it doesn't seem to register it. Maybe i'm missing some characters somewhere? Don't know.

Either way, thanks for the suggestion. i'll keep trying
RobAndrew
 
Posts: 134
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: speedo Drum settings

Postby WoodSTokk » Sun Nov 17, 2019 7:17 pm

Here is the animation code for the digit in the previous example:
Code: Select all
  <animation>
    <type>textranslate</type>
    <object-name>alt.100</object-name>
    <property alias="../../altitude-ft"/>
    <factor>0.001</factor>
    <step>100</step>
    <scroll>10</scroll>
    <axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </axis>
  </animation>

<step> and <scroll> do the job for you do turn the drums smoothly.
Anyway, if you dont have your digits as full band (vertically or horizontally) on your texture,
you can rearrange your UV mapping to achieve it or you need another trick.

EDIT:
Your nasal code includes unicode characters.
Code: Select all
setprop("B1b/fuel—tank-selector/displayed-fuel-digit-1", a);
                 ^

This is not a normal dash.
Replace it on all 5 lines.
WoodSTokk
 
Posts: 742
Joined: Tue Oct 17, 2017 2:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: OE-WST
IRC name: WoodSTokk
Version: 2020.3.0
OS: Debian Buster

Re: speedo Drum settings

Postby RobAndrew » Wed Nov 20, 2019 1:42 am

Brilliant! That did the trick! Had to do lots of moving around on the textures, but it was all worth it. Now I m trying to use your examples of Factor, Step and scroll on a couple of other pieces. However I am still unsure as to how each of them works fully. I have looked on the Wiki, but I can't quite understand the wording. Do you think you could word how they work to me in a way I can understand?

Thanks very much again for the suggestions, They've really helped me a lot!
RobAndrew
 
Posts: 134
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Next

Return to Cockpit development

Who is online

Users browsing this forum: No registered users and 1 guest