From: Bertrand <bco...@us...> - 2016-05-16 18:20:01
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv18420/src/models Modified Files: FGFCS.cpp FGFCS.h FGGroundReactions.cpp FGGroundReactions.h FGLGear.cpp FGLGear.h Log Message: The steering angle of each landing gear is now managed by FGGroundReactions and FGLGear. FGFCS no longer needs to know how many gears there are, which ones are steerable, which are not, etc. The steering angle was also stored in 3 different locations FGFCS::SteerPosDeg, FGLGear::in::SteerPosDeg and FGLGear::SteerAngle. Now the data is stored in FGLGear::SteerAngle only. This results in a better encapsulation of the landing gears code. The code is also simpler since information no longer need to be exchanged back and forth between FGLGear and FGFCS. Index: FGFCS.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCS.cpp,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -r1.94 -r1.95 *** FGFCS.cpp 3 Apr 2016 11:13:19 -0000 1.94 --- FGFCS.cpp 16 May 2016 18:19:57 -0000 1.95 *************** *** 84,88 **** systype = stFCS; ! DaCmd = DeCmd = DrCmd = DsCmd = DfCmd = DsbCmd = DspCmd = 0; PTrimCmd = YTrimCmd = RTrimCmd = 0.0; GearCmd = GearPos = 1; // default to gear down --- 84,88 ---- systype = stFCS; ! DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0; PTrimCmd = YTrimCmd = RTrimCmd = 0.0; GearCmd = GearPos = 1; // default to gear down *************** *** 109,113 **** PropAdvanceCmd.clear(); PropAdvance.clear(); - SteerPosDeg.clear(); PropFeatherCmd.clear(); PropFeather.clear(); --- 109,112 ---- *************** *** 136,140 **** for (i=0; i<PropFeather.size(); i++) PropFeather[i] = 0.0; ! DaCmd = DeCmd = DrCmd = DsCmd = DfCmd = DsbCmd = DspCmd = 0; PTrimCmd = YTrimCmd = RTrimCmd = 0.0; TailhookPos = WingFoldPos = 0.0; --- 135,139 ---- for (i=0; i<PropFeather.size(); i++) PropFeather[i] = 0.0; ! DaCmd = DeCmd = DrCmd = DfCmd = DsbCmd = DspCmd = 0; PTrimCmd = YTrimCmd = RTrimCmd = 0.0; TailhookPos = WingFoldPos = 0.0; *************** *** 173,182 **** for (i=0; i<PropFeather.size(); i++) PropFeather[i] = PropFeatherCmd[i]; - // Set the default steering angle - for (i=0; i<SteerPosDeg.size(); i++) { - FGLGear* gear = FDMExec->GetGroundReactions()->GetGearUnit(i); - SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() ); - } - // Execute system channels in order for (i=0; i<SystemChannels.size(); i++) { --- 172,175 ---- *************** *** 504,509 **** Debug(2); - if (systype == stFCS) bindModel(); - Element* channel_element = document->FindElement("channel"); --- 497,500 ---- *************** *** 689,700 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - void FGFCS::AddGear(unsigned int NumGear) - { - SteerPosDeg.clear(); - for (unsigned int i=0; i<NumGear; i++) SteerPosDeg.push_back(0.0); - } - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - double FGFCS::GetDt(void) const { --- 680,683 ---- *************** *** 755,759 **** PropertyManager->Tie("fcs/right-brake-cmd-norm", this, &FGFCS::GetRBrake, &FGFCS::SetRBrake); PropertyManager->Tie("fcs/center-brake-cmd-norm", this, &FGFCS::GetCBrake, &FGFCS::SetCBrake); - PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd); PropertyManager->Tie("gear/tailhook-pos-norm", this, &FGFCS::GetTailhookPos, &FGFCS::SetTailhookPos); --- 738,741 ---- *************** *** 797,815 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - void FGFCS::bindModel(void) - { - unsigned int i; - string tmp; - - for (i=0; i<SteerPosDeg.size(); i++) { - if (FDMExec->GetGroundReactions()->GetGearUnit(i)->GetSteerable()) { - tmp = CreateIndexedPropertyName("fcs/steer-pos-deg", i); - PropertyManager->Tie( tmp.c_str(), this, i, &FGFCS::GetSteerPosDeg, &FGFCS::SetSteerPosDeg); - } - } - } - - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // The bitmasked value choices are as follows: // unset: In this case (the default) JSBSim would only print --- 779,782 ---- Index: FGFCS.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCS.h,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -r1.50 -r1.51 *** FGFCS.h 27 Feb 2016 16:54:15 -0000 1.50 --- FGFCS.h 16 May 2016 18:19:57 -0000 1.51 *************** *** 225,232 **** double GetDrCmd(void) const { return DrCmd; } - /** Gets the steering command. - @return steering command in range from -1.0 - 1.0 */ - double GetDsCmd(void) const { return DsCmd; } - /** Gets the flaps command. @return flaps command in range from 0 to 1.0 */ --- 225,228 ---- *************** *** 334,343 **** const std::vector<double>& GetMixturePos() const {return MixturePos;} - /** Gets the steering position. - @return steering position in degrees */ - double GetSteerPosDeg(int gear) const { return SteerPosDeg[gear]; } - - const std::vector<double>& GetSteerPosDeg() const {return SteerPosDeg;} - /** Gets the gear position (0 up, 1 down), defaults to down @return gear position (0 up, 1 down) */ --- 330,333 ---- *************** *** 392,399 **** void SetDrCmd(double cmd) { DrCmd = cmd; } - /** Sets the steering command - @param cmd steering command in percent*/ - void SetDsCmd(double cmd) { DsCmd = cmd; } - /** Sets the flaps command @param cmd flaps command in percent*/ --- 382,385 ---- *************** *** 485,492 **** void SetMixturePos(int engine, double cmd); - /** Sets the steering position - @param cmd steering position in degrees*/ - void SetSteerPosDeg(int gear, double pos) { SteerPosDeg[gear] = pos; } - /** Set the gear extend/retract position, defaults to down @param gear position 0 up, 1 down */ --- 471,474 ---- *************** *** 557,561 **** void AddThrottle(void); - void AddGear(unsigned int NumGear); double GetDt(void) const; --- 539,542 ---- *************** *** 566,570 **** private: ! double DaCmd, DeCmd, DrCmd, DsCmd, DfCmd, DsbCmd, DspCmd; double DePos[NForms], DaLPos[NForms], DaRPos[NForms], DrPos[NForms]; double DfPos[NForms], DsbPos[NForms], DspPos[NForms]; --- 547,551 ---- private: ! double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd; double DePos[NForms], DaLPos[NForms], DaRPos[NForms], DrPos[NForms]; double DfPos[NForms], DsbPos[NForms], DspPos[NForms]; *************** *** 578,582 **** std::vector <bool> PropFeatherCmd; std::vector <bool> PropFeather; - std::vector <double> SteerPosDeg; //double LeftBrake, RightBrake, CenterBrake; // Brake settings std::vector <double> BrakePos; // left, center, right - defined by FGLGear:: enum --- 559,562 ---- *************** *** 589,593 **** Channels SystemChannels; void bind(void); - void bindModel(void); void bindThrottle(unsigned int); void Debug(int from); --- 569,572 ---- Index: FGGroundReactions.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGGroundReactions.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -r1.51 -r1.52 *** FGGroundReactions.cpp 9 Jun 2014 11:52:07 -0000 1.51 --- FGGroundReactions.cpp 16 May 2016 18:19:57 -0000 1.52 *************** *** 58,62 **** FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex), ! FGSurface(fgex) { Name = "FGGroundReactions"; --- 58,63 ---- FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex), ! FGSurface(fgex), ! DsCmd(0.0) { Name = "FGGroundReactions"; *************** *** 85,88 **** --- 86,90 ---- vForces.InitMatrix(); vMoments.InitMatrix(); + DsCmd = 0.0; multipliers.clear(); *************** *** 139,142 **** --- 141,153 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + void FGGroundReactions::SetDsCmd(double cmd) + { + DsCmd = cmd; + for (unsigned int i=0; i<lGear.size(); ++i) + lGear[i]->SetSteerCmd(cmd); + } + + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + bool FGGroundReactions::Load(Element* document) { *************** *** 259,262 **** --- 270,275 ---- PropertyManager->Tie("gear/num-units", this, &FGGroundReactions::GetNumGearUnits); PropertyManager->Tie("gear/wow", this, &FGGroundReactions::GetWOW); + PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGGroundReactions::GetDsCmd, + &FGGroundReactions::SetDsCmd); } Index: FGGroundReactions.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGGroundReactions.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** FGGroundReactions.h 16 Jan 2014 12:31:49 -0000 1.29 --- FGGroundReactions.h 16 May 2016 18:19:57 -0000 1.30 *************** *** 110,113 **** --- 110,121 ---- FGLGear* GetGearUnit(int gear) const { return lGear[gear]; } + /** Gets the steering command. + @return steering command in range from -1.0 - 1.0 */ + double GetDsCmd(void) const { return DsCmd; } + + /** Sets the steering command + @param cmd steering command in percent*/ + void SetDsCmd(double cmd); + void RegisterLagrangeMultiplier(LagrangeMultiplier* lmult) { multipliers.push_back(lmult); } std::vector <LagrangeMultiplier*>* GetMultipliersList(void) { return &multipliers; } *************** *** 120,123 **** --- 128,132 ---- FGColumnVector3 vMoments; std::vector <LagrangeMultiplier*> multipliers; + double DsCmd; void bind(void); Index: FGLGear.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGLGear.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -r1.122 -r1.123 *** FGLGear.cpp 16 May 2016 17:47:14 -0000 1.122 --- FGLGear.cpp 16 May 2016 18:19:57 -0000 1.123 *************** *** 81,85 **** SteerAngle(0.0), Castered(false), ! StaticFriction(false) { kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0; --- 81,86 ---- SteerAngle(0.0), Castered(false), ! StaticFriction(false), ! eSteerType(stSteer) { kSpring = bDamp = bDampRebound = dynamicFCoeff = staticFCoeff = rollingFCoeff = maxSteerAngle = 0; *************** *** 254,257 **** --- 255,259 ---- MaximumStrutForce = MaximumStrutTravel = 0.0; SinkRate = GroundSpeed = 0.0; + SteerAngle = 0.0; vWhlVelVec.InitMatrix(); *************** *** 447,451 **** void FGLGear::ComputeSlipAngle(void) { ! // Check that the speed is non-null otherwise use the current angle if (vGroundWhlVel.Magnitude(eX,eY) > 1E-3) WheelSlip = -atan2(vGroundWhlVel(eY), fabs(vGroundWhlVel(eX)))*radtodeg; --- 449,453 ---- void FGLGear::ComputeSlipAngle(void) { ! // Check that the speed is non-null otherwise keep the current angle if (vGroundWhlVel.Magnitude(eX,eY) > 1E-3) WheelSlip = -atan2(vGroundWhlVel(eY), fabs(vGroundWhlVel(eX)))*radtodeg; *************** *** 458,480 **** void FGLGear::ComputeSteeringAngle(void) { ! switch (eSteerType) { ! case stSteer: ! SteerAngle = degtorad * in.SteerPosDeg[GearNumber]; ! break; ! case stFixed: ! SteerAngle = 0.0; ! break; ! case stCaster: ! if (!Castered) ! SteerAngle = degtorad * in.SteerPosDeg[GearNumber]; ! else { ! // Check that the speed is non-null otherwise use the current angle if (vWhlVelVec.Magnitude(eX,eY) > 0.1) SteerAngle = atan2(vWhlVelVec(eY), fabs(vWhlVelVec(eX))); - } - break; - default: - cerr << "Improper steering type membership detected for this gear." << endl; - break; } } --- 460,467 ---- void FGLGear::ComputeSteeringAngle(void) { ! if (Castered) { ! // Check that the speed is non-null otherwise keep the current angle if (vWhlVelVec.Magnitude(eX,eY) > 0.1) SteerAngle = atan2(vWhlVelVec(eY), fabs(vWhlVelVec(eX))); } } *************** *** 832,835 **** --- 819,830 ---- PropertyManager->Tie( property_name.c_str(), &GearPos ); } + + if (eSteerType != stFixed) { + // This property allows the FCS to override the steering position angle that + // is set by the property fcs/steer-cmd-norm. The prefix fcs/ has been kept + // for backward compatibility. + string tmp = CreateIndexedPropertyName("fcs/steer-pos-deg", GearNumber); + PropertyManager->Tie(tmp.c_str(), this, &FGLGear::GetSteerAngleDeg, &FGLGear::SetSteerAngleDeg); + } } Index: FGLGear.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGLGear.h,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -r1.64 -r1.65 *** FGLGear.h 28 Jan 2014 09:42:21 -0000 1.64 --- FGLGear.h 16 May 2016 18:19:57 -0000 1.65 *************** *** 211,215 **** FGColumnVector3 vXYZcg; // CG coordinates expressed in the structural frame FGLocation Location; - std::vector <double> SteerPosDeg; std::vector <double> BrakePos; double FCSGearPos; --- 211,214 ---- *************** *** 276,280 **** bool GetReport(void) const { return ReportEnable; } double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; } ! double GetDefaultSteerAngle(double cmd) const { return cmd*maxSteerAngle; } double GetstaticFCoeff(void) const { return staticFCoeff; } --- 275,279 ---- bool GetReport(void) const { return ReportEnable; } double GetSteerNorm(void) const { return radtodeg/maxSteerAngle*SteerAngle; } ! void SetSteerCmd(double cmd) { SetSteerAngleDeg(cmd * maxSteerAngle); } double GetstaticFCoeff(void) const { return staticFCoeff; } *************** *** 316,319 **** --- 315,322 ---- double GetGearUnitPos(void) const; double GetSteerAngleDeg(void) const { return radtodeg*SteerAngle; } + void SetSteerAngleDeg(double angle) { + if (eSteerType != stFixed && !Castered) + SteerAngle = degtorad * angle; + } const struct Inputs& in; |