1
0
Fork 0

Merge branch 'next' of gitorious.org:fg/flightgear into next

This commit is contained in:
Torsten Dreyer 2010-06-01 22:10:00 +02:00
commit 8c15899837
16 changed files with 40 additions and 511 deletions

View file

@ -685,14 +685,6 @@
<Filter
Name="Lib_Autopilot"
>
<File
RelativePath="..\..\..\src\Autopilot\autobrake.cxx"
>
</File>
<File
RelativePath="..\..\..\src\Autopilot\autobrake.hxx"
>
</File>
<File
RelativePath="..\..\..\src\Autopilot\route_mgr.cxx"
>

View file

@ -57,6 +57,7 @@ void FGAICarrier::readFromScenario(SGPropertyNode* scFileNode) {
setMaxLong(scFileNode->getDoubleValue("max-long", 0));
setMinLong(scFileNode->getDoubleValue("min-long", 0));
setMPControl(scFileNode->getBoolValue("mp-control", false));
setAIControl(scFileNode->getBoolValue("ai-control", false));
SGPropertyNode* flols = scFileNode->getChild("flols-pos");
if (flols) {
@ -121,6 +122,10 @@ void FGAICarrier::setMPControl(bool c) {
MPControl = c;
}
void FGAICarrier::setAIControl(bool c) {
AIControl = c;
}
void FGAICarrier::update(double dt) {
// Now update the position and heading. This will compute new hdg and
// roll values required for the rotation speed computation.

View file

@ -58,6 +58,7 @@ public:
void setMaxLong( double deg );
void setMinLong( double deg );
void setMPControl( bool c );
void setAIControl( bool c );
void TurnToLaunch();
void TurnToRecover();
void TurnToBase();

View file

@ -52,6 +52,7 @@ _next_run(0),
_lead_angle(0),
_xtrack_error(0),
_tunnel(false),
_initial_tunnel(false),
_curr_alt(0),
_prev_alt(0),
_until_time(""),

View file

@ -65,6 +65,8 @@ enum plane_type {
// PlaneRec - a structure holding ATC-centric details of planes under control
// This might move or change eventually
struct PlaneRec {
PlaneRec() : type(UNKNOWN), squawkcode(0) {}
PlaneRec(const std::string& s) : type(UNKNOWN), callsign(s), squawkcode(0) {}
plane_type type;
std::string callsign;
int squawkcode;
@ -87,6 +89,7 @@ const int ATC_NUM_TYPES = 1 + INVALID;
// DCL - new experimental ATC data store
struct ATCData {
ATCData() : type(INVALID), cart(0, 0, 0), freq(0), range(0) {}
atc_type type;
SGGeod geod;
SGVec3d cart;
@ -99,6 +102,7 @@ struct ATCData {
// perhaps we could use an FGRunway instead of this.
// That wouldn't cache the orthopos though.
struct RunwayDetails {
RunwayDetails() : end1ortho(0, 0, 0), end2ortho(0, 0, 0), hdg(0), length(-1), width(-1) {}
SGGeod threshold_pos;
SGVec3d end1ortho; // ortho projection end1 (the threshold ATM)
SGVec3d end2ortho; // ortho projection end2 (the take off end in the current hardwired scheme)

View file

@ -63,10 +63,9 @@ using boost::ref;
using boost::tie;
FGATIS::FGATIS() :
transmission(""),
trans_ident(""),
old_volume(0),
atis_failed(false),
msg_OK(0),
attention(0),
_prev_display(0),
refname("atis")

View file

@ -2,7 +2,6 @@ noinst_LIBRARIES = libAutopilot.a
libAutopilot_a_SOURCES = \
route_mgr.cxx route_mgr.hxx \
xmlauto.cxx xmlauto.hxx \
autobrake.cxx autobrake.hxx
xmlauto.cxx xmlauto.hxx
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src

View file

@ -1,349 +0,0 @@
// autobrake.cxx - generic, configurable autobrake system
//
// Written by James Turner, started September 2009.
//
// Copyright (C) 2009 Curtis L. Olson
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include "autobrake.hxx"
#include <Main/fg_props.hxx>
FGAutoBrake::FGAutoBrake() :
_lastGroundspeedKts(0.0),
_step(0),
_rto(false),
_armed(false),
_rtoArmed(false),
_engaged(false),
_targetDecel(0.0),
_fcsBrakeControl(0.0),
_leftBrakeOutput(0.0),
_rightBrakeOutput(0.0)
{
// default config, close to Boeing 747-400 / 777 values
_configNumSteps = 4;
_configRTOStep = -1;
_configDisengageStep = 0;
_configMaxDecel = 11; // ft-sec-sec
_configRTODecel = 11; // ft-sec-sec
_configRTOSpeed = 85; // kts
}
FGAutoBrake::~FGAutoBrake()
{
}
void FGAutoBrake::init()
{
_root = fgGetNode("/autopilot/autobrake", true);
_root->tie("armed", SGRawValueMethods<FGAutoBrake, bool>
(*this, &FGAutoBrake::getArmed, &FGAutoBrake::setArmed));
_root->tie("step", SGRawValueMethods<FGAutoBrake, int>
(*this, &FGAutoBrake::getStep, &FGAutoBrake::setStep));
_root->tie("rto", SGRawValueMethods<FGAutoBrake, bool>
(*this, &FGAutoBrake::getRTO, &FGAutoBrake::setRTO));
_engineControlsNode = fgGetNode("/controls/engines");
// brake position nodes
_brakeInputs[0] = fgGetNode("/controls/gear/brake-left");
_brakeInputs[1] = fgGetNode("/controls/gear/brake-right");
_brakeInputs[2] = fgGetNode("/controls/gear/copilot-brake-left");
_brakeInputs[3] = fgGetNode("/controls/gear/copilot-brake-right");
// config
SGPropertyNode_ptr config = _root->getChild("config", 0, true);
config->tie("num-steps", SGRawValuePointer<int>(&_configNumSteps));
config->tie("rto-step", SGRawValuePointer<int>(&_configRTOStep));
config->tie("disengage-step", SGRawValuePointer<int>(&_configDisengageStep));
config->tie("rto-decel-fts-sec", SGRawValuePointer<double>(&_configRTODecel));
config->tie("max-decel-fts-sec", SGRawValuePointer<double>(&_configMaxDecel));
config->tie("rto-engage-kts", SGRawValuePointer<double>(&_configRTOSpeed));
// outputs
_root->tie("target-decel-fts-sec",
SGRawValueMethods<FGAutoBrake,double>(*this, &FGAutoBrake::getTargetDecel));
_root->tie("actual-decel-fts-sec",
SGRawValueMethods<FGAutoBrake,double>(*this, &FGAutoBrake::getActualDecel));
_root->tie("fcs-brake", SGRawValuePointer<double>(&_fcsBrakeControl));
_root->tie("brake-left-output", SGRawValuePointer<double>(&_leftBrakeOutput));
_root->tie("brake-right-output", SGRawValuePointer<double>(&_rightBrakeOutput));
_root->tie("engaged", SGRawValueMethods<FGAutoBrake, bool>(*this, &FGAutoBrake::getEngaged));
}
void FGAutoBrake::postinit()
{
_weightOnWheelsNode = fgGetNode("/gear/gear/wow");
_groundspeedNode = fgGetNode("/velocities/groundspeed-kt");
if (!_weightOnWheelsNode) {
return; // don't crash if we're using an acft (UFO, ATC, with no WoW flag)
}
_lastWoW = _weightOnWheelsNode->getBoolValue();
}
void FGAutoBrake::bind()
{
}
void FGAutoBrake::unbind()
{
}
void FGAutoBrake::update(double dt)
{
_leftBrakeInput = SGMiscd::max(_brakeInputs[0]->getDoubleValue(),
_brakeInputs[2]->getDoubleValue());
_rightBrakeInput = SGMiscd::max(_brakeInputs[1]->getDoubleValue(),
_brakeInputs[3]->getDoubleValue());
// various FDMs don't supply sufficent information for us to work,
// so just be passive in those cases.
if (!_weightOnWheelsNode || !_groundspeedNode || !_engineControlsNode) {
// pass the values straight through
_leftBrakeOutput = _leftBrakeInput;
_rightBrakeOutput = _rightBrakeInput;
return;
}
if (dt <= 0.0) {
return; // paused
}
double gs = _groundspeedNode->getDoubleValue();
_actualDecel = (_lastGroundspeedKts - gs) / dt;
_lastGroundspeedKts = gs;
if (!_armed || (_step == 0)) {
// even if we're off or disarmed, the physical valve system must pass
// pilot control values through.
_leftBrakeOutput = _leftBrakeInput;
_rightBrakeOutput = _rightBrakeInput;
return;
}
if (_engaged) {
updateEngaged(dt);
} else {
bool e = shouldEngage();
if (e) {
engage();
updateEngaged(dt);
}
}
// sum pilot inpiuts with auto-brake FCS input
_leftBrakeOutput = SGMiscd::max(_leftBrakeInput, _fcsBrakeControl);
_rightBrakeOutput = SGMiscd::max(_rightBrakeInput, _fcsBrakeControl);
_lastWoW = _weightOnWheelsNode->getBoolValue();
}
void FGAutoBrake::engage()
{
SG_LOG(SG_AUTOPILOT, SG_INFO, "FGAutoBrake: engaging");
_engaged = true;
}
void FGAutoBrake::updateEngaged(double dt)
{
// check for pilot braking input cancelling engage
const double BRAKE_INPUT_THRESHOLD = 0.02; // 2% application triggers
if ((_leftBrakeInput > BRAKE_INPUT_THRESHOLD) || (_rightBrakeInput > BRAKE_INPUT_THRESHOLD)) {
SG_LOG(SG_AUTOPILOT, SG_INFO, "auto-brake, detected pilot brake input, disengaing");
disengage();
return;
}
if (!throttlesAtIdle()) {
SG_LOG(SG_AUTOPILOT, SG_INFO, "auto-brake, throttles not at idle, disengaing");
disengage();
return;
}
// update the target deceleration; note step can be changed while engaged
if (_rto) {
_targetDecel = _configRTODecel;
} else {
double f = (double) _step / _configNumSteps;
_targetDecel = _configMaxDecel * f;
}
}
bool FGAutoBrake::shouldEngage()
{
if (_rto) {
return shouldEngageRTO();
}
if (_lastWoW || !_weightOnWheelsNode->getBoolValue()) {
return false;
}
if (!throttlesAtIdle()) {
return false;
}
SG_LOG(SG_AUTOPILOT, SG_INFO, "Autobrake, should enage");
return true;
}
bool FGAutoBrake::shouldEngageRTO()
{
double speed = _groundspeedNode->getDoubleValue();
if (_rtoArmed) {
if (speed < _configRTOSpeed) {
SG_LOG(SG_AUTOPILOT, SG_INFO, "FGAutoBrake: RTO armed, but speed is now below arming speed");
_rtoArmed = false;
return false;
}
if (!_weightOnWheelsNode->getBoolValue()) {
if (airborne()) {
SG_LOG(SG_AUTOPILOT, SG_INFO, "FGAutoBrake: RTO, airbone, disengaging");
_rtoArmed = false;
_armed = false;
_step = _configDisengageStep;
}
return false;
}
if (throttlesAtIdle()) {
SG_LOG(SG_AUTOPILOT, SG_INFO, "FGAutoBrake: RTO, throttles at idle, will engage");
return true;
} else {
return false;
}
} else {
// RTO arming case
if (speed > _configRTOSpeed) {
SG_LOG(SG_AUTOPILOT, SG_INFO, "Autobrake RTO: passed " << _configRTOSpeed << " knots, arming RTO mode");
_rtoArmed = true;
}
}
return false;
}
void FGAutoBrake::disengage()
{
if (!_engaged) {
return;
}
SG_LOG(SG_AUTOPILOT, SG_INFO, "FGAutoBrake: disengage");
_engaged = false;
_fcsBrakeControl = 0.0;
_armed = false;
_rtoArmed = false;
_targetDecel = 0.0;
_step = _configDisengageStep;
}
bool FGAutoBrake::airborne() const
{
return !_weightOnWheelsNode->getBoolValue();
}
bool FGAutoBrake::throttlesAtIdle() const
{
SGPropertyNode_ptr e;
const double IDLE_THROTTLE = 0.05; // 5% margin for idle setting
for (int index=0; (e = _engineControlsNode->getChild("engine", index)) != NULL; ++index) {
if ((e->getDoubleValue("throttle") > IDLE_THROTTLE) && !e->getBoolValue("reverser")) {
return false;
}
} // of engines iteration
return true;
}
void FGAutoBrake::setArmed(bool aArmed)
{
if (aArmed == _armed) {
return;
}
disengage();
_armed = aArmed;
}
void FGAutoBrake::setRTO(bool aRTO)
{
if (aRTO) {
// ensure we meet RTO selection criteria:
if (!_weightOnWheelsNode->getBoolValue()) {
// some systems combine RTO with a standard step, selecting RTO if on
// the ground. Handle that case by setting _rto = false, and letting
// setStep() do the rest of the work as normal.
if ((_configRTOStep > 0) && (_configRTOStep <= _configNumSteps)) {
// RTO is combined with a normal step, select that
} else {
SG_LOG(SG_AUTOPILOT, SG_WARN, "auto-brake: cannot select RTO mode, no weight on wheels");
}
_rto = false;
return;
}
_rtoArmed = false;
_rto = true;
_step = _configRTOStep;
setArmed(true);
SG_LOG(SG_AUTOPILOT, SG_INFO, "RTO mode set");
} else {
_rto = false;
_rtoArmed = false;
// and if we're enaged?
disengage();
}
}
void FGAutoBrake::setStep(int aStep)
{
if (aStep == _step) {
return;
}
SG_LOG(SG_AUTOPILOT, SG_INFO, "Autobrake step now=" << aStep);
_step = aStep;
bool validStep = false;
if (aStep == _configRTOStep) {
setRTO(true);
validStep = true;
} else {
_rto = false;
validStep = (_step > 0) && (_step <= _configNumSteps);
}
setArmed(validStep); // selecting a valid step arms the system
}

View file

@ -1,108 +0,0 @@
// autobrake.hxx - generic, configurable autobrake system
//
// Written by James Turner, started September 2009.
//
// Copyright (C) 2009 Curtis L. Olson
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#ifndef FG_INSTR_AUTOBRAKE_HXX
#define FG_INSTR_AUTOBRAKE_HXX
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
// forward decls
class FGAutoBrake : public SGSubsystem
{
public:
FGAutoBrake();
virtual ~FGAutoBrake();
virtual void init ();
virtual void postinit ();
virtual void bind ();
virtual void unbind ();
virtual void update (double dt);
private:
void engage();
void disengage();
void updateEngaged(double dt);
bool shouldEngage();
bool shouldEngageRTO();
/**
* Helper to determine if all throttles are at idle
* (or have reverse thrust engaged)
*/
bool throttlesAtIdle() const;
/**
* Helper to determine if we're airbone, i.e weight off all wheels
*/
bool airborne() const;
// accessors, mostly for SGRawValueMethods use
void setArmed(bool aArmed);
bool getArmed() const { return _armed; }
void setRTO(bool aRTO);
bool getRTO() const { return _rto; }
void setStep(int aStep);
int getStep() const { return _step; }
bool getEngaged() const { return _engaged;}
double getTargetDecel() const { return _targetDecel; }
double getActualDecel() const { return _actualDecel; }
// members
double _lastGroundspeedKts;
int _step;
bool _rto; // true if in Rejected TakeOff mode
bool _armed;
bool _rtoArmed; ///< true if we have met arming criteria for RTO mode
bool _engaged; ///< true if auto-braking is currently active
double _targetDecel; // target deceleration ft-sec^2
double _actualDecel; // measured current deceleration in ft-sec^2
double _fcsBrakeControl;
bool _lastWoW;
double _leftBrakeInput; // summed pilot and co-pilot left brake input
double _rightBrakeInput; // summed pilot and co-pilot right brake input
double _leftBrakeOutput;
double _rightBrakeOutput;
SGPropertyNode_ptr _root;
SGPropertyNode_ptr _brakeInputs[4];
SGPropertyNode_ptr _weightOnWheelsNode;
SGPropertyNode_ptr _engineControlsNode;
SGPropertyNode_ptr _groundspeedNode;
int _configNumSteps;
int _configRTOStep;
int _configDisengageStep;
double _configMaxDecel; ///< deceleration (in ft-sec^2) corresponding to step=numSteps
double _configRTODecel; ///< deceleration (in ft-sec^2) to use in RTO mode
double _configRTOSpeed; ///< speed (in kts) for RTO mode to arm
};
#endif // of FG_INSTR_AUTOBRAKE_HXX

View file

@ -258,10 +258,6 @@ FGJSBsim::FGJSBsim( double dt )
speedbrake_pos_pct->setDoubleValue(0);
spoilers_pos_pct->setDoubleValue(0);
ab_brake_engaged = fgGetNode("/autopilot/autobrake/engaged", true);
ab_brake_left_pct = fgGetNode("/autopilot/autobrake/brake-left-output", true);
ab_brake_right_pct = fgGetNode("/autopilot/autobrake/brake-right-output", true);
temperature = fgGetNode("/environment/temperature-degc",true);
pressure = fgGetNode("/environment/pressure-inhg",true);
density = fgGetNode("/environment/density-slugft3",true);
@ -548,12 +544,6 @@ bool FGJSBsim::copy_to_JSBsim()
double parking_brake = globals->get_controls()->get_brake_parking();
double left_brake = globals->get_controls()->get_brake_left();
double right_brake = globals->get_controls()->get_brake_right();
if (ab_brake_engaged->getBoolValue()) {
left_brake = ab_brake_left_pct->getDoubleValue();
right_brake = ab_brake_right_pct->getDoubleValue();
}
FCS->SetLBrake(FMAX(left_brake, parking_brake));
FCS->SetRBrake(FMAX(right_brake, parking_brake));

View file

@ -254,10 +254,6 @@ private:
SGPropertyNode_ptr speedbrake_pos_pct;
SGPropertyNode_ptr spoilers_pos_pct;
SGPropertyNode_ptr ab_brake_engaged;
SGPropertyNode_ptr ab_brake_left_pct;
SGPropertyNode_ptr ab_brake_right_pct;
SGPropertyNode_ptr gear_pos_pct;
SGPropertyNode_ptr wing_fold_pos_pct;
SGPropertyNode_ptr tailhook_pos_pct;

View file

@ -202,6 +202,7 @@ FGMouseInput::mouse::mouse ()
save_y(-1),
nModes(1),
current_mode(0),
timeout(0),
modes(NULL)
{
}

View file

@ -219,6 +219,7 @@ GPS::GPS ( SGPropertyNode *node) :
_mode("init"),
_name(node->getStringValue("name", "gps")),
_num(node->getIntValue("number", 0)),
_searchResultsCached(false),
_computeTurnData(false),
_anticipateTurn(false),
_inTurn(false)

View file

@ -84,7 +84,6 @@
#include <Autopilot/route_mgr.hxx>
#include <Autopilot/xmlauto.hxx>
#include <Autopilot/autobrake.hxx>
#include <Cockpit/cockpit.hxx>
#include <Cockpit/panel.hxx>
@ -1549,7 +1548,6 @@ bool fgInitSubsystems() {
globals->add_subsystem( "xml-autopilot", new FGXMLAutopilotGroup );
globals->add_subsystem( "route-manager", new FGRouteMgr );
globals->add_subsystem( "autobrake", new FGAutoBrake );
////////////////////////////////////////////////////////////////////
// Initialize the view manager subsystem.

View file

@ -149,15 +149,14 @@ fgviewerMain(int argc, char** argv)
osgGA::KeySwitchMatrixManipulator* keyswitchManipulator;
keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
osgGA::MatrixManipulator* mm = new osgGA::TrackballManipulator;
keyswitchManipulator->addMatrixManipulator('1', "Trackball", mm);
mm = new osgGA::FlightManipulator;
keyswitchManipulator->addMatrixManipulator('2', "Flight", mm);
mm = new osgGA::DriveManipulator;
keyswitchManipulator->addMatrixManipulator('3', "Drive", mm);
mm = new osgGA::TerrainManipulator;
keyswitchManipulator->addMatrixManipulator('4', "Terrain", mm);
keyswitchManipulator->addMatrixManipulator('1', "Trackball",
new osgGA::TrackballManipulator);
keyswitchManipulator->addMatrixManipulator('2', "Flight",
new osgGA::FlightManipulator);
keyswitchManipulator->addMatrixManipulator('3', "Drive",
new osgGA::DriveManipulator);
keyswitchManipulator->addMatrixManipulator('4', "Terrain",
new osgGA::TerrainManipulator);
viewer.setCameraManipulator(keyswitchManipulator);
// Usefull stats

View file

@ -58,14 +58,14 @@ main(int argc, char** argv)
osgGA::KeySwitchMatrixManipulator* keyswitchManipulator;
keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
osgGA::MatrixManipulator* mm = new osgGA::TrackballManipulator;
keyswitchManipulator->addMatrixManipulator('1', "Trackball", mm);
mm = new osgGA::FlightManipulator;
keyswitchManipulator->addMatrixManipulator('2', "Flight", mm);
mm = new osgGA::DriveManipulator;
keyswitchManipulator->addMatrixManipulator('3', "Drive", mm);
mm = new osgGA::TerrainManipulator;
keyswitchManipulator->addMatrixManipulator('4', "Terrain", mm);
keyswitchManipulator->addMatrixManipulator('1', "Trackball",
new osgGA::TrackballManipulator);
keyswitchManipulator->addMatrixManipulator('2', "Flight",
new osgGA::FlightManipulator);
keyswitchManipulator->addMatrixManipulator('3', "Drive",
new osgGA::DriveManipulator);
keyswitchManipulator->addMatrixManipulator('4', "Terrain",
new osgGA::TerrainManipulator);
viewer.setCameraManipulator(keyswitchManipulator);