Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1254 +/- ##
==========================================
- Coverage 24.94% 24.78% -0.17%
==========================================
Files 169 169
Lines 19524 19656 +132
==========================================
+ Hits 4871 4872 +1
- Misses 14653 14784 +131 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
For the record, this PR is motivated by #1250 (comment). @seanmcleod70, I guess we also need a property |
|
The random seed for a particular sensor, i.e. a sensor that you want to control the reproducibility of it's noise is set via a sensor attribute, specific to a specific sensor. <sensor name="name">
<input> property </input>
<lag> number </lag>
<noise [variation="PERCENT|ABSOLUTE"] [distribution="UNIFORM|GAUSSIAN"] [randomseed="number"] > number </noise>So unlike the wind turbulence case there isn't a single random seed property. Not quite following you in terms of "reset the simulation to it's initial state". In terms of reset are you talking about the case where an FDM is created, it's run for a while, then reset and further time steps, i.e. without creating a new FDM instance? fdm = create_fdm()
fdm.run() # N times
fdm.reset()
fdm.run() # N times |
Yep, got that. But my question was rather if a property would not be needed for each sensor that uses this attribute in its XML definition ?
Correct, that was my thought. I was trying to anticipate some cases where having a property would be useful but maybe it's irrelevant ? |
|
I did sort of consider the option of generating a property for the sensor if it had a jsbsim/src/models/flight_control/FGSensor.cpp Lines 268 to 279 in 13008f3 But ended up going with the option of the user supplying the random seed value as an attribute of the But thinking about it a bit more, I'm inclined to switch to a scheme matching the |
|
I've pushed some commits to switch to generating a sensor specific randomseed property. One of the builds failed due to a disk space issue, but all the other builds built successfully and the tests succeeded. |
|
Looks like, without a subsequent commit the build task that failed due to lack of disk space was re-run and now show all builds/tests are successful/green tick. |
bcoconni
left a comment
There was a problem hiding this comment.
It seems to me that the way the property name for randomseed is determined is too complicated. I understand that you have duplicated the code from quant_property but I think there is a much simpler way to proceed (see my comments in the code).
| if (!noise_property.empty()) { | ||
| if (noise_property.find("/") == string::npos) { // not found | ||
| string nprop = "fcs/" + PropertyManager->mkPropertyName(noise_property, true) + "/randomseed"; | ||
| FGPropertyNode* node = PropertyManager->GetNode(nprop, true); | ||
| if (node->isTied()) { | ||
| XMLLogException err(fcs->GetExec()->GetLogger(), el); | ||
| err << "Property " << tmp << " has already been successfully bound (late).\n"; | ||
| throw err; | ||
| } | ||
| else | ||
| PropertyManager->Tie(nprop, this, &FGSensor::GetNoiseRandomSeed, &FGSensor::SetNoiseRandomSeed); | ||
| } | ||
| } |
There was a problem hiding this comment.
It seems too complicated to me, I'd rather duplicate the code of the malfunction/ properties:
const string tmp_randomseed = tmp + "/randomseed";
PropertyManager->Tie(tmp_randomseed, this, &FGSensor::GetNoiseRandomSeed, &FGSensor::SetNoiseRandomSeed);
src/models/flight_control/FGSensor.h
Outdated
| <input> property </input> | ||
| <lag> number </lag> | ||
| <noise [variation="PERCENT|ABSOLUTE"] [distribution="UNIFORM|GAUSSIAN"]> number </noise> | ||
| <noise [variation="PERCENT|ABSOLUTE"] [distribution="UNIFORM|GAUSSIAN"] [name="name"] > number </noise> |
There was a problem hiding this comment.
No need to add a name attribute to <noise>, we already know the name of the property: randomseed so we don't need to ask the user to provide one.
src/models/flight_control/FGSensor.h
Outdated
| <input> aero/qbar </input> | ||
| <lag> 0.5 </lag> | ||
| <noise variation="PERCENT"> 2 </noise> | ||
| <noise variation="PERCENT" name="qbarsensor"> 2 </noise> |
There was a problem hiding this comment.
Same as previously, you can remove it from the example.
Yep, that was me ! I pushed the button "Re-run failed jobs" on GitHub and it managed to find a runner with sufficient disk space 😉 |
Removed the `name` attribute from the `<noise>` element in XML, simplifying noise configuration. Introduced a new `randomseed` property, automatically named based on the sensor's name. Updated `FGSensor::bind` to handle the new property and removed the obsolete `noise_property` member. Adjusted documentation, examples, and test cases to reflect these changes. This reduces complexity while preserving functionality for noise random seed configuration.
|
Pushed a commit based on your suggestions. Copilot suggested commit message was pretty accurate so used it as is.
I actually looked for that option, but couldn't find it. Could be because I'm not an 'Owner' of the repo, only a 'Member'. |
|
PR merged 👍
I have promoted your account to "Owner" (and demoted your old account to "Member" because there is only one Sean 😉) |
Co-authored-by: Sean McLeod <sean@seanmcleod.com>
No description provided.