Update of /cvsroot/csp/APPLICATIONS/CSPSim/Source In directory sc8-pr-cvs1:/tmp/cvs-serv4493 Modified Files: PrimaryAeroDynamics.cpp PhysicModel.cpp NumericalMethod.cpp Engine.cpp CSPSim.cpp Collision.cpp AircraftPhysicModel.cpp AircraftObject.cpp Log Message: see CHANGES.current Index: PrimaryAeroDynamics.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/PrimaryAeroDynamics.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrimaryAeroDynamics.cpp 19 Jun 2003 18:06:29 -0000 1.1 --- PrimaryAeroDynamics.cpp 22 Jun 2003 08:59:03 -0000 1.2 *************** *** 180,184 **** m_CD_i = 1.0 / (0.9 * G_PI * m_AspectRatio); m_HalfWingArea = 0.5 * m_WingArea; ! m_depsilon = std::min(m_GMax,fabs(m_GMin)); } --- 180,184 ---- m_CD_i = 1.0 / (0.9 * G_PI * m_AspectRatio); m_HalfWingArea = 0.5 * m_WingArea; ! m_depsilon = 0.5 * std::min(m_GMax,fabs(m_GMin)); } Index: PhysicModel.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/PhysicModel.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PhysicModel.cpp 19 Jun 2003 18:06:29 -0000 1.1 --- PhysicModel.cpp 22 Jun 2003 08:59:03 -0000 1.2 *************** *** 32,36 **** DynamicalSystem(dimension), m_Damping(0.999), ! m_qOrientation(simdata::Quaternion(1,0,0,0)), m_AngularAccelBody(simdata::Vector3::ZERO), m_LinearAccelBody(simdata::Vector3::ZERO), --- 32,36 ---- DynamicalSystem(dimension), m_Damping(0.999), ! m_qOrientation(simdata::Quaternion(1.0,0.0,0.0,0.0)), m_AngularAccelBody(simdata::Vector3::ZERO), m_LinearAccelBody(simdata::Vector3::ZERO), Index: NumericalMethod.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/NumericalMethod.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NumericalMethod.cpp 19 Jun 2003 18:06:29 -0000 1.5 --- NumericalMethod.cpp 22 Jun 2003 08:59:03 -0000 1.6 *************** *** 210,214 **** double const RungeKuttaCK::ERRCON = 1.89e-4; ! unsigned int const RungeKuttaCK::MAXSTP = 4; double const RungeKuttaCK::TINY = std::numeric_limits<float>::epsilon(); --- 210,214 ---- double const RungeKuttaCK::ERRCON = 1.89e-4; ! unsigned int const RungeKuttaCK::MAXSTP = 16;//10000 double const RungeKuttaCK::TINY = std::numeric_limits<float>::epsilon(); Index: Engine.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Engine.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Engine.cpp 20 Jun 2003 17:47:45 -0000 1.2 --- Engine.cpp 22 Jun 2003 08:59:03 -0000 1.3 *************** *** 18,22 **** /** ! * @file Thrust.cpp * **/ --- 18,22 ---- /** ! * @file Engine.cpp * **/ *************** *** 94,99 **** } ! void Engine::setThrottle(float throttle) { ! m_Throttle = throttle; } --- 94,99 ---- } ! void Engine::bindThrottle(float const &throttle) { ! m_Throttle = &throttle; } *************** *** 111,115 **** simdata::Vector3 Engine::getThrust() const { ! float throttle = m_Throttle; if (throttle < 0.0) throttle = 0.0; --- 111,115 ---- simdata::Vector3 Engine::getThrust() const { ! float throttle = *m_Throttle; if (throttle < 0.0) throttle = 0.0; *************** *** 155,163 **** } ! EngineDynamics::EngineDynamics() { } ! void EngineDynamics::bindThrottle(double const &throttle) { ! m_Throttle = &throttle; } --- 155,173 ---- } ! void EngineDynamics::postCreate() { ! if (!m_Engine.empty()) { ! simdata::Link<Engine>::vector::iterator i = m_Engine.begin(); ! simdata::Link<Engine>::vector::const_iterator iEnd = m_Engine.end(); ! for (; i !=iEnd; ++i) ! (*i)->bindThrottle(m_Throttle); ! } } ! EngineDynamics::EngineDynamics(): ! m_Throttle(0.0f) { ! } ! ! void EngineDynamics::setThrottle(double const throttle) { ! m_Throttle = static_cast<float>(throttle); } *************** *** 185,190 **** (*i)->setMach(mach); (*i)->setAltitude(altitude); - // FIXME: calibrate joystick positions for csp - (*i)->setThrottle(2.0f * static_cast<float>(*m_Throttle)); simdata::Vector3 force = (*i)->getThrust(); m_Force += force; --- 195,198 ---- Index: CSPSim.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/CSPSim.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** CSPSim.cpp 19 Jun 2003 18:06:29 -0000 1.29 --- CSPSim.cpp 22 Jun 2003 08:59:03 -0000 1.30 *************** *** 295,299 **** simdata::Ref<AircraftObject> ao = m_DataManager.getObject(vehicle.c_str()); assert(ao.valid()); ! ao->setGlobalPosition(483025, 499000, 88.5); ao->setAttitude(0.0, 0.0, 1.92); ao->setVelocity(0, 1.0, 0); --- 295,300 ---- simdata::Ref<AircraftObject> ao = m_DataManager.getObject(vehicle.c_str()); assert(ao.valid()); ! //ao->setGlobalPosition(483025, 499000, 88.5); ! ao->setGlobalPosition(483025, 499000, 2000.0); ao->setAttitude(0.0, 0.0, 1.92); ao->setVelocity(0, 1.0, 0); *************** *** 370,374 **** m_Battlefield = NULL; m_Scene = NULL; ! if (m_SDLJoystick) { SDL_JoystickClose(m_SDLJoystick); m_SDLJoystick = NULL; --- 371,375 ---- m_Battlefield = NULL; m_Scene = NULL; ! if (m_SDLJoystick) { SDL_JoystickClose(m_SDLJoystick); m_SDLJoystick = NULL; Index: Collision.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Collision.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Collision.cpp 19 Jun 2003 18:06:29 -0000 1.1 --- Collision.cpp 22 Jun 2003 08:59:03 -0000 1.2 *************** *** 175,184 **** m_InertiaInverse(inertia.Inverse()), m_Contacts(contacts), ! m_Elastic(0.7), m_Friction(0.8), m_Vtol(-3.0) { } ! void GroundCollisionDynamics::preSimulationStep(double dt) { m_ContactList.reset(); } --- 175,184 ---- m_InertiaInverse(inertia.Inverse()), m_Contacts(contacts), ! m_Elastic(0.6), m_Friction(0.8), m_Vtol(-3.0) { } ! void GroundCollisionDynamics::reset(double dt) { m_ContactList.reset(); } *************** *** 189,193 **** void GroundCollisionDynamics::update(double dt) { - m_ContactList.reset(); simdata::Quaternion const &q = *m_qOrientation; simdata::Vector3 const &velocity_body = *m_VelocityBody; --- 189,192 ---- *************** *** 197,203 **** simdata::Vector3 const groundReactionBody = - *m_WeightBody; simdata::Vector3 const &p = *m_PositionLocal; ! ! simdata::Vector3 origin(0.0, 0.0, *m_Height); simdata::Vector3 const &normalGroundLocal =*m_NormalGround; simdata::Vector3 normalGroundBody = simdata::QVRotate(q.Bar(),normalGroundLocal); --- 196,202 ---- simdata::Vector3 const groundReactionBody = - *m_WeightBody; simdata::Vector3 const &p = *m_PositionLocal; ! simdata::Vector3 const &normalGroundLocal =*m_NormalGround; + simdata::Vector3 origin(0.0, 0.0, *m_Height); simdata::Vector3 normalGroundBody = simdata::QVRotate(q.Bar(),normalGroundLocal); Index: AircraftPhysicModel.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/AircraftPhysicModel.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AircraftPhysicModel.cpp 20 Jun 2003 21:24:28 -0000 1.2 --- AircraftPhysicModel.cpp 22 Jun 2003 08:59:03 -0000 1.3 *************** *** 38,46 **** // bind(y,p,v,w,q); ! // XXX the following line is incorrect. ! //m_PositionLocal = *m_Position + bodyToLocal(simdata::Vector3(y[0],y[1],y[2])); ! // XXX if, in the future, we need to access the local position here, it should be ! // stored in a temporary: ! // simdata::Vecter3 position = m_LocalPositon + bodyToLocal(simdata::Vector3(y[0],y[1],y[2])); m_VelocityBody = simdata::Vector3(y[3],y[4],y[5]); m_AngularVelocityBody = simdata::Vector3(y[6],y[7],y[8]); --- 38,42 ---- // bind(y,p,v,w,q); ! m_PositionLocal = *m_Position + bodyToLocal(simdata::Vector3(y[0],y[1],y[2])); m_VelocityBody = simdata::Vector3(y[3],y[4],y[5]); m_AngularVelocityBody = simdata::Vector3(y[6],y[7],y[8]); *************** *** 55,58 **** --- 51,56 ---- m_WeightBody = localToBody(m_WeightLocal); + m_GroundCollisionDynamics->reset(x); + if (m_GroundCollisionDynamics && m_NearGround) { m_GroundCollisionDynamics->update(x); *************** *** 121,131 **** m_qOrientation = *m_Orientation; ! for (unsigned short i = 0; i<n; ++i) { m_VelocityBody = localToBody(m_VelocityLocal); m_AngularVelocityBody = localToBody(m_AngularVelocityLocal); - updateNearGround(); - std::vector<double> y0 = bodyToY(simdata::Vector3::ZERO,m_VelocityBody,m_AngularVelocityBody,m_qOrientation); --- 119,129 ---- m_qOrientation = *m_Orientation; ! updateNearGround(); + for (unsigned short i = 0; i<n; ++i) { + m_VelocityBody = localToBody(m_VelocityLocal); m_AngularVelocityBody = localToBody(m_AngularVelocityLocal); std::vector<double> y0 = bodyToY(simdata::Vector3::ZERO,m_VelocityBody,m_AngularVelocityBody,m_qOrientation); *************** *** 152,162 **** if (mag != 0.0) m_qOrientation /= mag; } // returns vehicle data members - *m_Position = m_PositionLocal; - if (m_GroundCollisionDynamics->hasContact() && m_VelocityLocal.z < 0.0) { - m_VelocityLocal.z *= 0.99; - } *m_Velocity = m_VelocityLocal; *m_AngularVelocity = m_AngularVelocityLocal; --- 150,161 ---- if (mag != 0.0) m_qOrientation /= mag; + + if (m_GroundCollisionDynamics->hasContact() && m_VelocityLocal.z < 0.0) { + m_VelocityLocal.z *= 0.9; + } + *m_Position = m_PositionLocal; } // returns vehicle data members *m_Velocity = m_VelocityLocal; *m_AngularVelocity = m_AngularVelocityLocal; Index: AircraftObject.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/AircraftObject.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** AircraftObject.cpp 19 Jun 2003 18:06:29 -0000 1.21 --- AircraftObject.cpp 22 Jun 2003 08:59:03 -0000 1.22 *************** *** 157,165 **** m_EngineDynamics = m_AircraftDynamics->getEngineDynamics(); - m_EngineDynamics->bindThrottle(m_Throttle); m_AircraftPhysicModel->addDynamics(m_EngineDynamics.get()); - //if (!m_SceneModel.valid()) - // createSceneModel(); - //m_SceneModel->setSmokeEmitterLocation(m_EngineDynamics->getSmokeEmitterLocation()); m_GearDynamics = m_AircraftDynamics->getGearDynamics(); --- 157,161 ---- *************** *** 256,262 **** } ! void AircraftObject::setThrottle(double x) ! { ! m_ThrottleInput = 0.5 * (1.0 - x); } --- 252,257 ---- } ! void AircraftObject::setThrottle(double x) { ! m_ThrottleInput = 0.5 *(1.0 - x); } *************** *** 500,503 **** --- 495,500 ---- void AircraftObject::doComplexPhysics(double dt) { m_PrimaryAeroDynamics->setControlSurfaces(m_Aileron, m_Elevator, m_Rudder); + // FIXME: calibrate joystick positions for csp + m_EngineDynamics->setThrottle(2.0 * m_Throttle); //preset various aircraft dimensions and landing/takeoff parameters: |