Roy Ovesen:
Please find attatched a new version of xmlauto.cxx. Remove the call to build() in reinit(). This prevents build() from being called twice when Reload Autopilot is selected from the Debug menu. I've also added the ability to define an enabled property for the filters. It's used like the PID controllers. If there is no enabled tag then the filter defaults to enabled so that nothing should get broken by this change. This ability can be used to create a filter between the output of a PID controller and the property that it controls (a control surface). By putting a noise spike filter between the output of a controller and the control surface that it controls, we can simulate the limited movement rate that is inherent in autopilot servos.
This commit is contained in:
parent
e00b796b3c
commit
15cd4284fb
1 changed files with 28 additions and 3 deletions
|
@ -640,6 +640,19 @@ FGDigitalFilter::FGDigitalFilter(SGPropertyNode *node)
|
|||
name = cval;
|
||||
} else if ( cname == "debug" ) {
|
||||
debug = child->getBoolValue();
|
||||
} else if ( cname == "enable" ) {
|
||||
SGPropertyNode *prop = child->getChild( "prop" );
|
||||
if ( prop != NULL ) {
|
||||
enable_prop = fgGetNode( prop->getStringValue(), true );
|
||||
}
|
||||
SGPropertyNode *val = child->getChild( "value" );
|
||||
if ( val != NULL ) {
|
||||
enable_value = val->getStringValue();
|
||||
}
|
||||
SGPropertyNode *pass = child->getChild( "honor-passive" );
|
||||
if ( pass != NULL ) {
|
||||
honor_passive = pass->getBoolValue();
|
||||
}
|
||||
} else if ( cname == "type" ) {
|
||||
if ( cval == "exponential" ) {
|
||||
filterType = exponential;
|
||||
|
@ -670,10 +683,23 @@ FGDigitalFilter::FGDigitalFilter(SGPropertyNode *node)
|
|||
|
||||
void FGDigitalFilter::update(double dt)
|
||||
{
|
||||
if ( input_prop != NULL ) {
|
||||
if ( input_prop != NULL &&
|
||||
enable_prop != NULL &&
|
||||
enable_prop->getStringValue() == enable_value) {
|
||||
input.push_front(input_prop->getDoubleValue());
|
||||
input.resize(samples + 1, 0.0);
|
||||
if ( !enabled ) {
|
||||
// first time being enabled, initialize output to the
|
||||
// value of the output property to avoid bumping.
|
||||
output.push_front(output_list[0]->getDoubleValue());
|
||||
output.resize(1);
|
||||
}
|
||||
|
||||
enabled = true;
|
||||
} else if (enable_prop == NULL &&
|
||||
input_prop != NULL) {
|
||||
input.push_front(input_prop->getDoubleValue());
|
||||
input.resize(samples + 1, 0.0);
|
||||
// no sense if there isn't an input :-)
|
||||
enabled = true;
|
||||
} else {
|
||||
enabled = false;
|
||||
|
@ -798,7 +824,6 @@ void FGXMLAutopilot::init() {
|
|||
void FGXMLAutopilot::reinit() {
|
||||
components.clear();
|
||||
init();
|
||||
build();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue