Skip to content

Edit J246 aircraft guidance properties#1377

Merged
bcoconni merged 3 commits intoJSBSim-Team:masterfrom
heshpdx:patch-1
Feb 5, 2026
Merged

Edit J246 aircraft guidance properties#1377
bcoconni merged 3 commits intoJSBSim-Team:masterfrom
heshpdx:patch-1

Conversation

@heshpdx
Copy link
Contributor

@heshpdx heshpdx commented Jan 21, 2026

Use different property domain for eccentricity so that apogee and perigee are calculated correctly.

Use different property domain for eccentricity so that apogee and perigee are calculated correctly.
@heshpdx heshpdx mentioned this pull request Jan 21, 2026
@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 25.28%. Comparing base (5988bb4) to head (52ae398).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1377      +/-   ##
==========================================
+ Coverage   25.24%   25.28%   +0.04%     
==========================================
  Files         169      169              
  Lines       18549    18569      +20     
==========================================
+ Hits         4682     4696      +14     
- Misses      13867    13873       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bcoconni
Copy link
Member

Not sure to understand why this opportunity is not taken to replace the eccentricity from the system code by the eccentricity from the C++ code ?

        <property caption="Orbital perigee (miles): "> guidance/executive/periapsis </property>
-        <property caption="Orbital eccentricity:    "> guidance/executive/eccentricity </property>
+        <property caption="Orbital eccentricity:    "> orbital/eccentricity </property>
        <property caption="Altitude AGL (ft):       "> position/h-agl-ft </property>

Also we could go one step further and replace the perigee and apogee computations in the system code by the C++ implementation ?

    <fcs_function name="guidance/executive/apoapsis">
      <function>
        <quotient>
          <difference>
-            <product>
-              <property>guidance/executive/semimajor-axis-length-ft</property>
-              <sum>
-                <value>1</value>
-                <property>guidance/executive/eccentricity</property>
-              </sum>
-            </product>
+            <property>orbital/apoapsis-radius-ft</property>
            <property>inertial/sea-level-radius_ft</property>
          </difference>
          <value>5280</value>
        </quotient>
      </function>
    </fcs_function>

    <fcs_function name="guidance/executive/periapsis">
      <function>
        <quotient>
          <difference>
-            <product>
-              <property>guidance/executive/semimajor-axis-length-ft</property>
-              <difference>
-                <value>1</value>
-                <property>guidance/executive/eccentricity</property>
-              </difference>
-            </product>
+            <property>orbital/periapsis-radius-ft</property>
            <property>inertial/sea-level-radius_ft</property>
          </difference>
          <value>5280</value>
        </quotient>
      </function>
    </fcs_function>

@bcoconni
Copy link
Member

bcoconni commented Feb 1, 2026

Ping ! Any comments about my suggestion ?

@heshpdx
Copy link
Contributor Author

heshpdx commented Feb 2, 2026

I just tried your suggestion 1 and then added suggestion 2. These all work also. The outputs are just slightly different from the original (due to rounding error) although it grows over time. In both cases O3 does equal Ofast, so that problem is not there. If we change scripts/J2461.xml then we should also change scripts/J2460.xml which has the same property.

Here are the outputs from J2461.xml.

O3-J2461-bc.xml.txt
O3-J2461-bc2.xml.txt
Ofast-J2461-bc.xml.txt
Ofast-J2461-bc2.xml.txt

This is the difference in O3 when replacing the apogee/perigee computations (within FP rounding errors).

image

Eccentricity calculations switch from using the legacy system
code to using the modern C++ code for orbital parameters.
@bcoconni
Copy link
Member

bcoconni commented Feb 3, 2026

I just tried your suggestion 1 and then added suggestion 2. These all work also.

Great!

The outputs are just slightly different from the original (due to rounding error) although it grows over time.

This is not surprising since, as I have explained in #834 (comment), I think there is an error in the computation of guidance/executive/eccentricity.

Now I think we can safely remove the computations of guidance/executive/eccentricity and guidance/executive/semimajor-axis-length-ft (i.e. the 2 <fcs_function> elements listed below) since they are no longer needed.

<fcs_function name="guidance/executive/semimajor-axis-length-ft">
<description>
This equation calculates the semimajor-axis length in feet. a = mu/(2*mu/r - v^2)
</description>
<function>
<quotient>
<p> guidance/executive/gm </p>
<difference>
<quotient>
<product>
<v> 2.0 </v>
<p> guidance/executive/gm </p>
</product>
<p> position/radius-to-vehicle-ft </p>
</quotient>
<pow>
<p> velocities/eci-velocity-mag-fps </p>
<v> 2.0 </v>
</pow>
</difference>
</quotient>
</function>
</fcs_function>
<fcs_function name="guidance/executive/eccentricity">
<description>
This equation calculates eccentricity. e = sqrt (1 - [ r v cos(gamma) ]^2 / {a * mu})
</description>
<function>
<pow>
<difference>
<v> 1.0 </v>
<quotient>
<pow>
<product>
<property> position/radius-to-vehicle-ft </property>
<property> velocities/eci-velocity-mag-fps </property>
<cos>
<property> flight-path/gamma-rad </property>
</cos>
</product>
<v> 2.0 </v>
</pow>
<product>
<p> guidance/executive/semimajor-axis-length-ft </p>
<p> guidance/executive/gm </p>
</product>
</quotient>
</difference>
<v> 0.5 </v>
</pow>
</function>
</fcs_function>

And after that, this PR will be ready for merging, unless someone has some other comments.

@bcoconni
Copy link
Member

bcoconni commented Feb 4, 2026

Is everyone happy with the changes ? @seanmcleod70 @agodemar ?
Because I am 😃

@agodemar
Copy link
Contributor

agodemar commented Feb 4, 2026

@bcoconni it's OK for me

@seanmcleod70
Copy link
Contributor

Looks good to me.

@bcoconni bcoconni merged commit 5f5f467 into JSBSim-Team:master Feb 5, 2026
28 checks passed
bcoconni pushed a commit to bcoconni/jsbsim that referenced this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants