From: <sv...@ww...> - 2005-04-02 20:54:12
|
Author: mkrose Date: 2005-04-02 12:54:03 -0800 (Sat, 02 Apr 2005) New Revision: 1505 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Include/FlightDynamics.h trunk/CSP/CSPSim/Include/FlightModel.h trunk/CSP/CSPSim/Source/FlightDynamics.cpp Log: Export qBar and G channels. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1505 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2005-04-02 19:49:46 UTC (rev 1504) +++ trunk/CSP/CSPSim/CHANGES.current 2005-04-02 20:54:03 UTC (rev 1505) @@ -13,6 +13,8 @@ * Convert channel strings to channel name constants and connect angular velocity (in body coordinates) channel. + * Export qBar and G channels. + 2005-03-12: delta * Reformated GearAnimation and related classes as Systems. Adjusted xml files consequently. Cleaned up GearDynamics. Modified: trunk/CSP/CSPSim/Include/FlightDynamics.h =================================================================== --- trunk/CSP/CSPSim/Include/FlightDynamics.h 2005-04-02 19:49:46 UTC (rev 1504) +++ trunk/CSP/CSPSim/Include/FlightDynamics.h 2005-04-02 20:54:03 UTC (rev 1505) @@ -1,17 +1,17 @@ -// Combat Simulator Project - FlightSim Demo -// Copyright (C) 2002 The Combat Simulator Project +// Combat Simulator Project +// Copyright (C) 2002-2005 The Combat Simulator Project // http://csp.sourceforge.net -// +// // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -78,15 +78,18 @@ DataChannel<simdata::Vector3>::CRef b_WindVelocity; // export channels - DataChannel<double>::Ref b_Alpha; // current angle of attack - DataChannel<double>::Ref b_Beta; // side slip angle + DataChannel<double>::Ref b_Alpha; // current angle of attack + DataChannel<double>::Ref b_Beta; // side slip angle DataChannel<double>::Ref b_Airspeed; + DataChannel<double>::Ref b_QBar; // dynamic pressure + DataChannel<double>::Ref b_G; // G force (includes gravity) double m_Beta; double m_Alpha; - double m_Alpha0; // discrete AOA + double m_Alpha0; // discrete AOA double m_AlphaDot; double m_Airspeed; + double m_QBar; simdata::Vector3 m_WindVelocityBody; Modified: trunk/CSP/CSPSim/Include/FlightModel.h =================================================================== --- trunk/CSP/CSPSim/Include/FlightModel.h 2005-04-02 19:49:46 UTC (rev 1504) +++ trunk/CSP/CSPSim/Include/FlightModel.h 2005-04-02 20:54:03 UTC (rev 1505) @@ -115,7 +115,7 @@ m_Beta = beta; m_Beta_float = static_cast<float>(m_Beta); m_AirSpeed = airspeed; - m_qBarS = m_HalfWingArea * qBar * airspeed * airspeed; + m_qBarS = m_HalfWingArea * 2.0 * qBar; m_Inv2V = 0.5 / std::max(0.5, airspeed); } Modified: trunk/CSP/CSPSim/Source/FlightDynamics.cpp =================================================================== --- trunk/CSP/CSPSim/Source/FlightDynamics.cpp 2005-04-02 19:49:46 UTC (rev 1504) +++ trunk/CSP/CSPSim/Source/FlightDynamics.cpp 2005-04-02 20:54:03 UTC (rev 1505) @@ -1,17 +1,17 @@ -// Combat Simulator Project - FlightSim Demo -// Copyright (C) 2002 The Combat Simulator Project +// Combat Simulator Project +// Copyright (C) 2002-2005 The Combat Simulator Project // http://csp.sourceforge.net -// +// // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -24,10 +24,14 @@ #include <FlightDynamics.h> #include <FlightModel.h> #include <CSPSim.h> +#include <ConditionsChannels.h> +#include <ControlSurfacesChannels.h> +#include <FlightDynamicsChannels.h> #include <KineticsChannels.h> -#include <SimCore/Util/Log.h> +#include <SimCore/Util/Log.h> #include <SimData/Math.h> +#include <SimData/Key.h> #include <sstream> #include <iomanip> @@ -37,9 +41,7 @@ using simdata::toDegrees; using simdata::toRadians; -using bus::Kinetics; - SIMDATA_REGISTER_INTERFACE(FlightDynamics) @@ -48,7 +50,8 @@ m_Alpha(0.0), m_Alpha0(0.0), m_AlphaDot(0.0), - m_Airspeed(1.0) + m_Airspeed(1.0), + m_QBar(0.0) { } @@ -57,21 +60,23 @@ void FlightDynamics::registerChannels(Bus *bus) { assert(bus!=0); - b_Alpha = bus->registerLocalDataChannel<double>("FlightDynamics.Alpha", 0.0); - b_Beta = bus->registerLocalDataChannel<double>("FlightDynamics.Beta", 0.0); - b_Airspeed = bus->registerLocalDataChannel<double>("FlightDynamics.Airspeed", 0.0); + b_Alpha = bus->registerLocalDataChannel<double>(bus::FlightDynamics::Alpha, 0.0); + b_Beta = bus->registerLocalDataChannel<double>(bus::FlightDynamics::Beta, 0.0); + b_Airspeed = bus->registerLocalDataChannel<double>(bus::FlightDynamics::Airspeed, 0.0); + b_QBar = bus->registerLocalDataChannel<double>(bus::FlightDynamics::QBar, 0.0); + b_G = bus->registerLocalDataChannel<double>(bus::FlightDynamics::GForce, 0.0); } void FlightDynamics::importChannels(Bus *bus) { assert(bus!=0); - b_Aileron = bus->getChannel("ControlSurfaces.AileronDeflection"); - b_Elevator = bus->getChannel("ControlSurfaces.ElevatorDeflection"); - b_Rudder = bus->getChannel("ControlSurfaces.RudderDeflection"); - b_Airbrake = bus->getChannel("ControlSurfaces.AirbrakeDeflection"); - b_Density = bus->getChannel("Conditions.Density"); - b_WindVelocity = bus->getChannel("Conditions.WindVelocity"); - b_GroundZ = bus->getChannel(Kinetics::GroundZ); - b_AccelerationBody = bus->getChannel(Kinetics::AccelerationBody); + b_Aileron = bus->getChannel(bus::ControlSurfaces::AileronDeflection); + b_Elevator = bus->getChannel(bus::ControlSurfaces::ElevatorDeflection); + b_Rudder = bus->getChannel(bus::ControlSurfaces::RudderDeflection); + b_Airbrake = bus->getChannel(bus::ControlSurfaces::AirbrakeDeflection); + b_Density = bus->getChannel(bus::Conditions::Density); + b_WindVelocity = bus->getChannel(bus::Conditions::WindVelocity); + b_GroundZ = bus->getChannel(bus::Kinetics::GroundZ); + b_AccelerationBody = bus->getChannel(bus::Kinetics::AccelerationBody); } void FlightDynamics::initializeSimulationStep(double dt) { @@ -83,7 +88,7 @@ void FlightDynamics::computeForceAndMoment(double x) { updateAirflow(x); double agl = m_PositionLocal->z() - b_GroundZ->value(); - m_FlightModel->setAirstream(m_Alpha, m_AlphaDot, m_Beta, m_Airspeed, b_Density->value()); + m_FlightModel->setAirstream(m_Alpha, m_AlphaDot, m_Beta, m_Airspeed, m_QBar); m_FlightModel->setKinetics(*m_AngularVelocityBody, agl); m_Force = m_FlightModel->calculateForce(); m_Moment = m_FlightModel->calculateMoment(); @@ -95,12 +100,15 @@ b_Alpha->value() = m_Alpha; b_Beta->value() = m_Beta; b_Airspeed->value() = m_Airspeed; + b_QBar->value() = m_QBar; + double G = m_Attitude->invrotate(simdata::Vector3::ZAXIS).z(); + b_G->value() = G + b_AccelerationBody->value().z() / 9.806; } void FlightDynamics::updateAirflow(double h) { simdata::Vector3 airflowBody = *m_VelocityBody - m_WindVelocityBody; m_Airspeed = airflowBody.length(); - m_Alpha = -atan2(airflowBody.z(), airflowBody.y()); + m_Alpha = -atan2(airflowBody.z(), airflowBody.y()); if (h > 0.0) { m_AlphaDot = ( m_Alpha - m_Alpha0 ) / h; @@ -113,17 +121,18 @@ // beta is 0 when v velocity (i.e. side velocity) is 0; note here v is m_AirflowBody.x() //m_Beta = atan2(airflowBody.x(), airflowBody.y()); m_Beta = asin(airflowBody.x()/(1.0 + m_Airspeed)); + + // Dynamic pressure = 1/2 p V^2 (N/m^2) + m_QBar = 0.5 * m_Airspeed * m_Airspeed * b_Density->value(); } void FlightDynamics::getInfo(InfoList &info) const { std::stringstream line; - double G = m_Attitude->invrotate(simdata::Vector3::ZAXIS).z(); - G += b_AccelerationBody->value().z() / 9.806; line.setf(std::ios::fixed | std::ios::showpos); line << "AOA: " << std::setprecision(1) << std::setw(5) << toDegrees(m_Alpha) << ", Sideslip: " << std::setprecision(1) << std::setw(5) << toDegrees(m_Beta) << ", Airspeed: " << std::setprecision(1) << std::setw(6) << m_Airspeed - << ", G: " << std::setprecision(1) << std::setw(4) << G; + << ", G: " << std::setprecision(1) << std::setw(4) << b_G->value(); info.push_back(line.str()); } |