c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
82 stars 43 forks source link

Amphibious : gears no longer retract #1400

Closed dany93 closed 1 year ago

dany93 commented 2 years ago

With the amphibious set, the landing gears no longer retract. Pressing g, G, does nothing.

dany93 commented 2 years ago

Worse: neither it works with the install/flightgear/fgdata version.

dany93 commented 2 years ago

If I press the "G" key, controls/gear/gear-down (=true) briefly toggles, but it immediately comes back to true.

If I press Ctrl+Click on controls/gear/gear-down-command, everything works, the gears retract and extend. Is there an issue in electrical.nas (line 476) ?

I just realized (rather didn't remember) that Clicking on the (amphibious) gear lever makes everything work. It may be on purpose. Only controlled by the gear lever. In this case, sorry for the disturbance

wlbragg commented 2 years ago

I think I should take a looked an see why the g key doesn't work. As far as I am aware it should. Do you know if it works on the Cub amphibious?

dany93 commented 2 years ago

Hi, @wlbragg

On the J3Cub amphibious, the G key (g or G) does nothing either. The gear lever (mouse click) works.

wlbragg commented 2 years ago

I want to check the key mappings an make sure I didn't simply overlook making one. I can't think of any reason not to have the gear bound to g. Do you know, in standard aircraft with gear, is it a lower or upper or both toggle up/down, or g/G for up and down? Brake used b/B I think. I would hope it to be consistent.

dany93 commented 2 years ago

From Keyboard bindings,

G | Gear up (that is: g)

⇧ Shift+G | Gear down (that is: G)


B | Apply all brakes

⇧ Shift+B | Toggle parking brake(s)

wlbragg commented 2 years ago

Thanks @dany93 Hum, so it looks like it should be working. I'll take a look and see if I can figure out what's wrong.

dany93 commented 2 years ago

@dany93 wrote

If I press the "G" key, controls/gear/gear-down (=true) briefly toggles, but it immediately comes back to true.

It seems that the lever position overwrites the G / g key action at every frame.

Normally, per default in FG and without any gear lever code or animation, g / G on the keyboard should make the gears retract or extend.

What I think is that:

(fgdata/keyboard.xml)

 <key n="71">
  <name>G</name>
  <desc>Gear down</desc>
  <binding>
   <command>nasal</command>
   <script>controls.gearDown(1)</script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.gearDown(0)</script>
   </binding>
  </mod-up>
 </key>

 <key n="103">
  <name>g</name>
  <desc>Gear Up</desc>
  <binding>
   <command>nasal</command>
   <script>controls.gearDown(-1)</script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.gearDown(0)</script>
   </binding>
  </mod-up>
 </key>

The magnetos, parking brake, flap controls probably work like this (no overwriting at every frame).

Not sure I've seen everything well...

dany93 commented 2 years ago

@wlbragg Maybe you could use controls.gearToggle() ? (see fgdata/nasal/controls.nas, line 356). (not sure, I'm too close from my limits in nasal)

wlbragg commented 2 years ago

@dany93 I saw this was left unresolved and decided to finish our discussion. I don't know the ramifications of not using an FG default like controls.gearDown(0). The c172p code is using /controls/gear/gear-down-command which in effect appears to be overriding /controls/gear/gear-down, which is what controls.gearDown(0) is mapped to or controlling. We have logic that maps /controls/gear/gear-down-command to /controls/gear/gear-down for the damage system. I don't know if that may be why I did it this way. I am concerned that a user expecting a mapping to /controls/gear/gear-down, say for a joystick, isn't going to work correctly. But an easy fix to get the keyboard G/g working is to map those keys to what we use, which is /controls/gear/gear-down-command. I also notice throughout the files we do try to set /controls/gear/gear-down. We do it in the mooring code, the checklists and the tutorials. But I am not sure it is even working as we also have that property being overridden by the following. So you really can't set it.

    <logic>
        <name>Amphibious Gear Hydraulic Damage</name>
        <input>
            <and>
                <equals>
                    <property>fdm/jsbsim/pontoon-damage/left-pontoon</property>
                    <value>0</value>
                </equals>
                <equals>
                    <property>fdm/jsbsim/pontoon-damage/right-pontoon</property>
                    <value>0</value>
                </equals>
                <property>controls/gear/gear-down-command</property>
            </and>
        </input>
        <output>
            <property>controls/gear/gear-down</property>
        </output>
    </logic>

I am under the weather at the moment with Covid and my brain is just not processing thing as it should. So I really need to keep this open and see if we can't remap everything to /controls/gear/gear-down instead of /controls/gear/gear-down-command. There should be no reason not to use the FG default for gear control.

I'm posting this now so as to refresh my memory as to what is going on with this code until I can get back to it.

@legoboyvdlp maybe you have something to say about this?

wlbragg commented 1 year ago

@dany93 I took another look and added the key bindings for this. As far as I can tell this should be good to merge. If you have the time to test that would be great. I'll post the merge request here shortly.