Improve NEU properties#1327
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1327 +/- ##
==========================================
+ Coverage 24.89% 24.91% +0.02%
==========================================
Files 169 169
Lines 19669 19675 +6
==========================================
+ Hits 4896 4902 +6
Misses 14773 14773 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR improves the North East Up (NEU) properties implementation in JSBSim by fixing unit conversion issues and adopting better initialization practices. The changes restore proper feet-to-meters conversion for distance properties and rename NEU properties for better clarity.
Key changes:
- Restored missing feet-to-meters conversion for position/distance properties
- Renamed NEU properties to use more descriptive
from-start-neu-*naming pattern - Replaced runtime initialization check with proper JSBSim initialization pattern
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/models/FGAuxiliary.h | Added forward declaration and SetInitialState method, removed initialization flag |
| src/models/FGAuxiliary.cpp | Implemented proper initialization, restored unit conversions, updated property names |
| src/FGFDMExec.cpp | Added Auxiliary initialization call to main initialization sequence |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Yep, I actually thought of it at the time I first implemented them. Especially given it's not something that other systems like the EOM etc. need on each time step, plus they're not going to be popular properties in general. So, adding some additional conditional logic will more than likely be better performance wise as opposed to calculating it on every time step. However, I've run into an issue with our recent friend, So these are the changes I made, note the change in - double GetNEUPositionFromStart(int idx) const { return vNEUFromStart(idx); }
- const FGColumnVector3& GetNEUPositionFromStart() const { return vNEUFromStart; }
+ double GetNEUPositionFromStart(int idx) { return (GetNEUPositionFromStart())(idx); }
+ const FGColumnVector3& GetNEUPositionFromStart();
const FGColumnVector3& FGAuxiliary::GetNEUPositionFromStart()
{
if (!NEUValid) {
// Position tracking in local frame with local frame origin at lat, lon of initial condition
// and at 0 altitude relative to the reference ellipsoid. Position is NEU (North, East, UP) in feet.
vNEUFromStart = NEUStartLocation.LocationToLocal(in.vLocation);
vNEUFromStart(3) *= -1.0; // Flip sign for Up, so + for altitude above reference ellipsoid
NEUValid = true;
}
return vNEUFromStart;
}
bool FGAuxiliary::Run(bool Holding)
{
............
// New timestep so vNEUFromStart is no longer valid since we only calculate it on demand
NEUValid = false;
...........
}Which results in this, doesn't appear we can currently have getters that aren't const for binding via 1>FGAuxiliary.cpp
1>C:\source\jsbsim\src\models\FGAuxiliary.cpp(469,20): error C2672: 'JSBSim::FGPropertyManager::Tie': no matching overloaded function found
1> C:\source\jsbsim\src\input_output\FGPropertyManager.h(437,7): |
|
One workaround for the const issue, make the methods const again and declare + double GetNEUPositionFromStart(int idx) const { return (GetNEUPositionFromStart())(idx); }
+ const FGColumnVector3& GetNEUPositionFromStart() const;
FGLocation NEUStartLocation;
mutable FGColumnVector3 vNEUFromStart;
mutable bool NEUValid; |
Yep ! Seems reasonable to me. Especially since the mutable members are "byproducts" of the class. The method |
|
Yep, I came across the following when I was looking into the options available. https://isocpp.org/wiki/faq/const-correctness
|
|
Looks good to me 👍 |
Co-authored-by: Sean McLeod <sean@seanmcleod.com>
position/distance-from-start-lat/lon-mtproperties in the original PR for NEU properties.position/from-start-neu-n-ft