You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(64) |
May
(260) |
Jun
(65) |
Jul
(28) |
Aug
(13) |
Sep
(46) |
Oct
(55) |
Nov
(25) |
Dec
(57) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(97) |
Feb
(13) |
Mar
(90) |
Apr
(25) |
May
(97) |
Jun
(124) |
Jul
(39) |
Aug
(16) |
Sep
(62) |
Oct
(13) |
Nov
(32) |
Dec
(258) |
2006 |
Jan
(87) |
Feb
(67) |
Mar
(27) |
Apr
(19) |
May
(42) |
Jun
(12) |
Jul
(31) |
Aug
(51) |
Sep
(7) |
Oct
(4) |
Nov
(27) |
Dec
(6) |
2007 |
Jan
(23) |
Feb
(41) |
Mar
(6) |
Apr
(14) |
May
(31) |
Jun
(6) |
Jul
(9) |
Aug
(13) |
Sep
(41) |
Oct
(26) |
Nov
(13) |
Dec
(11) |
2008 |
Jan
(75) |
Feb
(24) |
Mar
(32) |
Apr
(103) |
May
(49) |
Jun
(15) |
Jul
(45) |
Aug
(61) |
Sep
(6) |
Oct
(12) |
Nov
(18) |
Dec
(32) |
2009 |
Jan
(77) |
Feb
(33) |
Mar
(33) |
Apr
(19) |
May
(52) |
Jun
(43) |
Jul
(14) |
Aug
(80) |
Sep
(32) |
Oct
(81) |
Nov
(20) |
Dec
(12) |
2010 |
Jan
(15) |
Feb
(50) |
Mar
(28) |
Apr
(49) |
May
(12) |
Jun
(19) |
Jul
(78) |
Aug
(49) |
Sep
(52) |
Oct
(22) |
Nov
(108) |
Dec
(33) |
2011 |
Jan
(47) |
Feb
(3) |
Mar
(7) |
Apr
(3) |
May
(7) |
Jun
(43) |
Jul
(80) |
Aug
(55) |
Sep
(34) |
Oct
(33) |
Nov
(33) |
Dec
(20) |
2012 |
Jan
(16) |
Feb
(18) |
Mar
(29) |
Apr
(26) |
May
(4) |
Jun
(5) |
Jul
(13) |
Aug
(14) |
Sep
(47) |
Oct
(29) |
Nov
(19) |
Dec
(66) |
2013 |
Jan
(55) |
Feb
(46) |
Mar
|
Apr
(1) |
May
|
Jun
(32) |
Jul
|
Aug
(1) |
Sep
(40) |
Oct
(3) |
Nov
(43) |
Dec
(26) |
2014 |
Jan
(63) |
Feb
(30) |
Mar
(2) |
Apr
(3) |
May
(51) |
Jun
(18) |
Jul
(4) |
Aug
(6) |
Sep
(10) |
Oct
|
Nov
(17) |
Dec
(3) |
2015 |
Jan
(13) |
Feb
(36) |
Mar
(12) |
Apr
(37) |
May
(8) |
Jun
|
Jul
(29) |
Aug
(23) |
Sep
(55) |
Oct
(82) |
Nov
(57) |
Dec
(72) |
2016 |
Jan
(61) |
Feb
(6) |
Mar
(1) |
Apr
(18) |
May
(59) |
Jun
(42) |
Jul
(24) |
Aug
(20) |
Sep
(6) |
Oct
|
Nov
(8) |
Dec
(1) |
2017 |
Jan
(2) |
Feb
(20) |
Mar
(14) |
Apr
(4) |
May
(9) |
Jun
(7) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Bertrand <bco...@us...> - 2016-04-16 10:57:30
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv21813/tests Modified Files: TestAccelerometer.py Log Message: Increased the rotation rate so that the centrifugal acceleration can be easily distinguished from numerical round off Index: TestAccelerometer.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestAccelerometer.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** TestAccelerometer.py 30 Jan 2016 18:50:24 -0000 1.4 --- TestAccelerometer.py 16 Apr 2016 10:57:27 -0000 1.5 *************** *** 98,102 **** self.assertAlmostEqual(fdm['fcs/accelerometer/X'], fax, delta=1E-7) self.assertAlmostEqual(fdm['fcs/accelerometer/Y'], 0.0, delta=1E-7) ! self.assertAlmostEqual(fdm['fcs/accelerometer/Z'], faz, delta=1E-7) del fdm --- 98,102 ---- self.assertAlmostEqual(fdm['fcs/accelerometer/X'], fax, delta=1E-7) self.assertAlmostEqual(fdm['fcs/accelerometer/Y'], 0.0, delta=1E-7) ! self.assertAlmostEqual(fdm['fcs/accelerometer/Z'], faz, delta=1E-6) del fdm *************** *** 135,139 **** math.sin(pitch - latitude) * math.cos(roll)]) ! # Compute the acceleration measured by the accelrometer as the sum of # the gravity and the centrifugal and Coriolis forces. fa_yz = (fc * math.cos(latitude - pitch) - g * math.cos(pitch)) --- 135,139 ---- math.sin(pitch - latitude) * math.cos(roll)]) ! # Compute the acceleration measured by the accelerometer as the sum of # the gravity and the centrifugal and Coriolis forces. fa_yz = (fc * math.cos(latitude - pitch) - g * math.cos(pitch)) *************** *** 174,183 **** fdm['ic/phi-rad'] = 0.5*math.pi ! # Set the angular velocities to 0.0 in the ECEF frame. The angular ! # velocity R_{inertial} will therefore be equal to the Earth rotation ! # rate 7.292115E-5 rad/sec fdm['ic/p-rad_sec'] = 0.0 fdm['ic/q-rad_sec'] = 0.0 ! fdm['ic/r-rad_sec'] = 0.0 fdm.run_ic() --- 174,183 ---- fdm['ic/phi-rad'] = 0.5*math.pi ! # Set the angular velocities so that angular velocity R_{inertial} will ! # be equal to 1.0 rad/sec. ! omega = 0.00007292115 # Earth rotation rate in rad/sec fdm['ic/p-rad_sec'] = 0.0 fdm['ic/q-rad_sec'] = 0.0 ! fdm['ic/r-rad_sec'] = 1.0 - omega fdm.run_ic() *************** *** 186,190 **** faz = fdm['fcs/accelerometer/Z'] cgy_ft = fdm['inertia/cg-y-in'] / 12. - omega = 0.00007292115 # Earth rotation rate in rad/sec self.assertAlmostEqual(fdm['accelerations/a-pilot-x-ft_sec2'], fax, --- 186,189 ---- *************** *** 197,202 **** # Acceleration along X should be zero self.assertAlmostEqual(fax, 0.0, delta=1E-8) ! # Acceleration along Y should be equal to r*omega^2 ! self.assertAlmostEqual(fay / (cgy_ft * omega * omega), 1.0, delta=1E-7) # Acceleration along Z should be zero self.assertAlmostEqual(faz, 0.0, delta=1E-8) --- 196,201 ---- # Acceleration along X should be zero self.assertAlmostEqual(fax, 0.0, delta=1E-8) ! # Acceleration along Y should be equal to d*r_dot^2 ! self.assertAlmostEqual(fay / cgy_ft, 1.0, delta=1E-7) # Acceleration along Z should be zero self.assertAlmostEqual(faz, 0.0, delta=1E-8) |
From: Bertrand <bco...@us...> - 2016-04-03 17:10:49
|
Update of /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5875/check_cases/ground_tests/scripts Modified Files: systems-rate-test-0.xml Log Message: Properties defined by scripts are now automatically reset to their initial value. Index: systems-rate-test-0.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/scripts/systems-rate-test-0.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** systems-rate-test-0.xml 3 Apr 2016 11:11:44 -0000 1.2 --- systems-rate-test-0.xml 3 Apr 2016 17:10:46 -0000 1.3 *************** *** 8,12 **** <!-- launch with JSBSim root=check_cases/ground_tests scriptx=aircraft/systemsrate/systems-rate-test-0.xml --> <run start="0.0" end="60" dt="0.033333"> ! <property value="1" persistent="true">tests/system-rate-enabled</property> <event name="monitor"> --- 8,12 ---- <!-- launch with JSBSim root=check_cases/ground_tests scriptx=aircraft/systemsrate/systems-rate-test-0.xml --> <run start="0.0" end="60" dt="0.033333"> ! <property value="1">tests/system-rate-enabled</property> <event name="monitor"> |
From: Bertrand <bco...@us...> - 2016-04-03 17:10:49
|
Update of /cvsroot/jsbsim/JSBSim/src/input_output In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5875/src/input_output Modified Files: FGScript.cpp Log Message: Properties defined by scripts are now automatically reset to their initial value. Index: FGScript.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/input_output/FGScript.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -r1.63 -r1.64 *** FGScript.cpp 28 Sep 2015 21:14:15 -0000 1.63 --- FGScript.cpp 3 Apr 2016 17:10:46 -0000 1.64 *************** *** 354,358 **** void FGScript::ResetEvents(void) { ! //LocalProperties.ResetToIC(); FDMExec->Setsim_time(StartTime); --- 354,358 ---- void FGScript::ResetEvents(void) { ! LocalProperties.ResetToIC(); FDMExec->Setsim_time(StartTime); |
From: Bertrand <bco...@us...> - 2016-04-03 17:06:28
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5707/src/models Modified Files: FGFCSChannel.h Log Message: Do not reset the frame counter repeatedly during trim otherwise the channel rate will be offset against the simulation frame. Index: FGFCSChannel.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCSChannel.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** FGFCSChannel.h 3 Apr 2016 11:13:19 -0000 1.8 --- FGFCSChannel.h 3 Apr 2016 17:06:24 -0000 1.9 *************** *** 136,142 **** for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); ExecFrameCountSinceLastRun = 0; - } } /// Get the channel rate --- 136,143 ---- for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); + } + if (ExecFrameCountSinceLastRun >= ExecRate) ExecFrameCountSinceLastRun = 0; } /// Get the channel rate |
From: Bertrand <bco...@us...> - 2016-04-03 17:06:28
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5707/tests Modified Files: TestChannelRate.py Log Message: Do not reset the frame counter repeatedly during trim otherwise the channel rate will be offset against the simulation frame. Index: TestChannelRate.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestChannelRate.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** TestChannelRate.py 3 Apr 2016 11:11:44 -0000 1.2 --- TestChannelRate.py 3 Apr 2016 17:06:25 -0000 1.3 *************** *** 20,24 **** import os ! from JSBSim_utils import JSBSimTestCase, CreateFDM, RunTest, ExecuteUntil --- 20,24 ---- import os ! from JSBSim_utils import JSBSimTestCase, CreateFDM, RunTest *************** *** 41,45 **** self.assertEqual(fdm['simulation/sim-time-sec'], fdm['tests/rate-1-dt-sum']) ! self.assertAlmostEqual(fdm['simulation/dt'] * fdm['tests/rate-4'] * 4, fdm['tests/rate-4-dt-sum']) --- 41,45 ---- self.assertEqual(fdm['simulation/sim-time-sec'], fdm['tests/rate-1-dt-sum']) ! self.assertAlmostEqual(fdm['simulation/dt']*fdm['tests/rate-4']*4, fdm['tests/rate-4-dt-sum']) *************** *** 47,50 **** --- 47,68 ---- self.assertEqual(fdm['simulation/dt']*4, fdm['tests/rate-4-dt']) + try: + fdm['simulation/do_simple_trim'] = 1 + except RuntimeError as e: + # The trim cannot succeed. Just make sure that the raised exception + # is due to the trim failure otherwise rethrow. + if e.args[0] != 'Trim Failed': + raise + + while fdm['simulation/sim-time-sec'] < 40: + self.assertEqual(fdm['simulation/frame'], fdm['tests/rate-1']) + self.assertEqual(int(fdm['simulation/frame']/4), + fdm['tests/rate-4']) + self.assertEqual(fdm['simulation/sim-time-sec'], + fdm['tests/rate-1-dt-sum']) + self.assertAlmostEqual(fdm['simulation/dt']*fdm['tests/rate-4']*4, + fdm['tests/rate-4-dt-sum']) + fdm.run() + fdm.reset_to_initial_conditions(1) tf = fdm['tests/rate-1-dt-sum'] |
From: Bertrand <bco...@us...> - 2016-04-03 11:13:23
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24125/src/models Modified Files: FGFCSChannel.h FGFCS.cpp Log Message: Fixed channels to fix their behaviour after a reset. Also make sure that the frame counter is frozen when the integration is suspended (i.e. when dt == 0.0) Index: FGFCSChannel.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCSChannel.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** FGFCSChannel.h 27 Feb 2016 16:54:15 -0000 1.7 --- FGFCSChannel.h 3 Apr 2016 11:13:19 -0000 1.8 *************** *** 79,86 **** public: /// Constructor ! FGFCSChannel(const std::string &name, int execRate, FGPropertyNode* node=0) ! : OnOffNode(node), Name(name), ExecFrameCountSinceLastRun(1) { ExecRate = execRate < 1 ? 1 : execRate; } --- 79,89 ---- public: /// Constructor ! FGFCSChannel(FGFCS* FCS, const std::string &name, int execRate, ! FGPropertyNode* node=0) ! : fcs(FCS), OnOffNode(node), Name(name) { ExecRate = execRate < 1 ? 1 : execRate; + // Set ExecFrameCountSinceLastRun so that each components are initialized + ExecFrameCountSinceLastRun = ExecRate; } *************** *** 113,119 **** for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->ResetPastStates(); } /// Executes all the components in a channel. ! void Execute(bool trimStatus) { // If there is an on/off property supplied for this channel, check // the value. If it is true, permit execution to continue. If not, return --- 116,126 ---- for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->ResetPastStates(); + + // Set ExecFrameCountSinceLastRun so that each components are initialized + // after a reset. + ExecFrameCountSinceLastRun = ExecRate; } /// Executes all the components in a channel. ! void Execute() { // If there is an on/off property supplied for this channel, check // the value. If it is true, permit execution to continue. If not, return *************** *** 121,132 **** if (OnOffNode && !OnOffNode->getBoolValue()) return; // channel will be run at rate 1 if trimming, or when the next execrate // frame is reached ! if (trimStatus || ExecFrameCountSinceLastRun >= ExecRate) { for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); ExecFrameCountSinceLastRun = 0; } - ExecFrameCountSinceLastRun++; } /// Get the channel rate --- 128,142 ---- if (OnOffNode && !OnOffNode->getBoolValue()) return; + if (fcs->GetDt() != 0.0) + ++ExecFrameCountSinceLastRun; + // channel will be run at rate 1 if trimming, or when the next execrate // frame is reached ! if (fcs->GetTrimStatus() || ExecFrameCountSinceLastRun >= ExecRate) { for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); + ExecFrameCountSinceLastRun = 0; } } /// Get the channel rate *************** *** 134,137 **** --- 144,148 ---- private: + FGFCS* fcs; FCSCompVec FCSComponents; FGConstPropertyNode_ptr OnOffNode; Index: FGFCS.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCS.cpp,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -r1.93 -r1.94 *** FGFCS.cpp 27 Feb 2016 16:54:15 -0000 1.93 --- FGFCS.cpp 3 Apr 2016 11:13:19 -0000 1.94 *************** *** 183,187 **** if (debug_lvl & 4) cout << " Executing System Channel: " << SystemChannels[i]->GetName() << endl; ChannelRate = SystemChannels[i]->GetRate(); ! SystemChannels[i]->Execute(GetTrimStatus()); } ChannelRate = 1; --- 183,187 ---- if (debug_lvl & 4) cout << " Executing System Channel: " << SystemChannels[i]->GetName() << endl; ChannelRate = SystemChannels[i]->GetRate(); ! SystemChannels[i]->Execute(); } ChannelRate = 1; *************** *** 522,526 **** FGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty); if (OnOffPropertyNode == 0) { ! cerr << highint << fgred << "The On/Off property, " << sOnOffProperty << " specified for channel " << channel_element->GetAttributeValue("name") << " is undefined or not " --- 522,526 ---- FGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty); if (OnOffPropertyNode == 0) { ! cerr << channel_element->ReadFrom() << highint << fgred << "The On/Off property, " << sOnOffProperty << " specified for channel " << channel_element->GetAttributeValue("name") << " is undefined or not " *************** *** 528,534 **** throw("Bad system definition"); } else ! newChannel = new FGFCSChannel(sChannelName, Rate, OnOffPropertyNode); } else ! newChannel = new FGFCSChannel(sChannelName, Rate); SystemChannels.push_back(newChannel); --- 528,535 ---- throw("Bad system definition"); } else ! newChannel = new FGFCSChannel(this, sChannelName, Rate, ! OnOffPropertyNode); } else ! newChannel = new FGFCSChannel(this, sChannelName, Rate); SystemChannels.push_back(newChannel); |
From: Bertrand <bco...@us...> - 2016-04-03 11:11:47
|
Update of /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24027/check_cases/ground_tests/scripts Modified Files: systems-rate-test-0.xml Log Message: Check that channels behave properly after a reset Index: systems-rate-test-0.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/scripts/systems-rate-test-0.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** systems-rate-test-0.xml 27 Feb 2016 17:49:12 -0000 1.1 --- systems-rate-test-0.xml 3 Apr 2016 11:11:44 -0000 1.2 *************** *** 8,12 **** <!-- launch with JSBSim root=check_cases/ground_tests scriptx=aircraft/systemsrate/systems-rate-test-0.xml --> <run start="0.0" end="60" dt="0.033333"> ! <property value="1">tests/system-rate-enabled</property> <event name="monitor"> --- 8,12 ---- <!-- launch with JSBSim root=check_cases/ground_tests scriptx=aircraft/systemsrate/systems-rate-test-0.xml --> <run start="0.0" end="60" dt="0.033333"> ! <property value="1" persistent="true">tests/system-rate-enabled</property> <event name="monitor"> |
From: Bertrand <bco...@us...> - 2016-04-03 11:11:47
|
Update of /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/systems In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24027/check_cases/ground_tests/systems Modified Files: system-rate-1.xml system-rate-4.xml Log Message: Check that channels behave properly after a reset Index: system-rate-1.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/systems/system-rate-1.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** system-rate-1.xml 27 Feb 2016 17:49:12 -0000 1.1 --- system-rate-1.xml 3 Apr 2016 11:11:44 -0000 1.2 *************** *** 2,6 **** <system name="FULL"> ! <property value="-10.0">tests/rate-1</property> <property value="0">tests/rate-1-dt-sum</property> <property value="0">tests/rate-1-actuator-dmd</property> --- 2,6 ---- <system name="FULL"> ! <property value="0">tests/rate-1</property> <property value="0">tests/rate-1-dt-sum</property> <property value="0">tests/rate-1-actuator-dmd</property> *************** *** 8,12 **** <property value="0">tests/system-rate-enabled</property> ! <channel name="control" execrate="1" execute="tests/system-rate-enabled"> <!-- this is just to do rate-1 = rate-1 + 1 --> <actuator name="tests/rate-1-actuator-value"> --- 8,12 ---- <property value="0">tests/system-rate-enabled</property> ! <channel name="control1" execrate="1" execute="tests/system-rate-enabled"> <!-- this is just to do rate-1 = rate-1 + 1 --> <actuator name="tests/rate-1-actuator-value"> *************** *** 24,27 **** --- 24,35 ---- </fcs_function> + <!-- skip the tests/rate-1 increment if dt == 0.0 --> + <switch name="tests/increment"> + <default value="1.0"/> + <test value="simulation/dt"> + simulation/dt == 0.0 + </test> + </switch> + <!-- use actuator to test dt is correctly set --> <fcs_function name="tests/rate-1"> *************** *** 29,34 **** <integer> <sum> - <value>1.0</value> <property>tests/rate-1-v</property> </sum> </integer> --- 37,42 ---- <integer> <sum> <property>tests/rate-1-v</property> + <property>tests/increment</property> </sum> </integer> Index: system-rate-4.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/systems/system-rate-4.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** system-rate-4.xml 27 Feb 2016 17:49:12 -0000 1.1 --- system-rate-4.xml 3 Apr 2016 11:11:44 -0000 1.2 *************** *** 4,8 **** <property value="1">tests/rate-4-actuator-rate</property> ! <channel name="control" execrate="4" execute="tests/system-rate-enabled"> <!-- this is just to do rate-4 = rate-4 + 1 --> <fcs_function name="tests/rate-4-v"> --- 4,8 ---- <property value="1">tests/rate-4-actuator-rate</property> ! <channel name="control4" execrate="4" execute="tests/system-rate-enabled"> <!-- this is just to do rate-4 = rate-4 + 1 --> <fcs_function name="tests/rate-4-v"> *************** *** 18,23 **** <integer> <sum> - <value>1.0</value> <property>tests/rate-4-v</property> </sum> </integer> --- 18,23 ---- <integer> <sum> <property>tests/rate-4-v</property> + <property>tests/increment</property> </sum> </integer> |
From: Bertrand <bco...@us...> - 2016-04-03 11:11:47
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24027/tests Modified Files: TestChannelRate.py Log Message: Check that channels behave properly after a reset Index: TestChannelRate.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestChannelRate.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** TestChannelRate.py 27 Feb 2016 17:49:12 -0000 1.1 --- TestChannelRate.py 3 Apr 2016 11:11:44 -0000 1.2 *************** *** 34,48 **** fdm.run_ic() ! ExecuteUntil(fdm, 30.) - self.assertEqual(fdm['simulation/frame'], fdm['tests/rate-1-v']-1) - self.assertEqual(int(fdm['simulation/frame']/4), - fdm['tests/rate-4']) self.assertEqual(fdm['simulation/dt'], fdm['tests/rate-1-dt']) self.assertEqual(fdm['simulation/dt']*4, fdm['tests/rate-4-dt']) ! self.assertEqual(fdm['simulation/sim-time-sec'], ! fdm['tests/rate-1-dt-sum']) ! self.assertAlmostEqual(fdm['simulation/dt'] * fdm['tests/rate-4'] * 4, ! fdm['tests/rate-4-dt-sum']) RunTest(TestChannelRate) --- 34,63 ---- fdm.run_ic() ! while fdm['simulation/sim-time-sec'] < 30: ! fdm.run() ! self.assertEqual(fdm['simulation/frame'], fdm['tests/rate-1']) ! self.assertEqual(int(fdm['simulation/frame']/4), ! fdm['tests/rate-4']) ! self.assertEqual(fdm['simulation/sim-time-sec'], ! fdm['tests/rate-1-dt-sum']) ! self.assertAlmostEqual(fdm['simulation/dt'] * fdm['tests/rate-4'] * 4, ! fdm['tests/rate-4-dt-sum']) self.assertEqual(fdm['simulation/dt'], fdm['tests/rate-1-dt']) self.assertEqual(fdm['simulation/dt']*4, fdm['tests/rate-4-dt']) ! ! fdm.reset_to_initial_conditions(1) ! tf = fdm['tests/rate-1-dt-sum'] ! xtraFrames = fdm['simulation/frame'] % 4 ! ! while fdm['simulation/sim-time-sec'] < 30: ! fdm.run() ! self.assertEqual(fdm['simulation/frame'], fdm['tests/rate-1']) ! self.assertEqual(int((fdm['simulation/frame']-xtraFrames)/4), ! fdm['tests/rate-4']) ! self.assertAlmostEqual(fdm['simulation/sim-time-sec'], ! fdm['tests/rate-1-dt-sum']-tf) ! self.assertAlmostEqual(fdm['simulation/dt']*fdm['tests/rate-4']*4, ! fdm['tests/rate-4-dt-sum']) RunTest(TestChannelRate) |
From: Bertrand <bco...@us...> - 2016-03-26 18:54:30
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16245/src/models Modified Files: FGMassBalance.h FGMassBalance.cpp Log Message: Added the inertias to the property tree Index: FGMassBalance.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGMassBalance.h,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -r1.36 -r1.37 *** FGMassBalance.h 22 Aug 2015 18:09:00 -0000 1.36 --- FGMassBalance.h 26 Mar 2016 18:54:27 -0000 1.37 *************** *** 203,207 **** FGColumnVector3 PointMassCG; const FGMatrix33& CalculatePMInertias(void); ! /** The PointMass structure encapsulates a point mass object, moments of inertia --- 203,212 ---- FGColumnVector3 PointMassCG; const FGMatrix33& CalculatePMInertias(void); ! double GetIxx(void) const { return mJ(1,1); } ! double GetIyy(void) const { return mJ(2,2); } ! double GetIzz(void) const { return mJ(3,3); } ! double GetIxy(void) const { return -mJ(1,2); } ! double GetIxz(void) const { return -mJ(1,3); } ! double GetIyz(void) const { return -mJ(2,3); } /** The PointMass structure encapsulates a point mass object, moments of inertia Index: FGMassBalance.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGMassBalance.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** FGMassBalance.cpp 9 Dec 2015 04:28:18 -0000 1.54 --- FGMassBalance.cpp 26 Mar 2016 18:54:27 -0000 1.55 *************** *** 259,267 **** void FGMassBalance::AddPointMass(Element* el) { - double radius=0, length=0; Element* loc_element = el->FindElement("location"); string pointmass_name = el->GetAttributeValue("name"); if (!loc_element) { ! cerr << "Pointmass " << pointmass_name << " has no location." << endl; exit(-1); } --- 259,267 ---- void FGMassBalance::AddPointMass(Element* el) { Element* loc_element = el->FindElement("location"); string pointmass_name = el->GetAttributeValue("name"); if (!loc_element) { ! cerr << el->ReadFrom() << "Pointmass " << pointmass_name ! << " has no location." << endl; exit(-1); } *************** *** 275,278 **** --- 275,279 ---- Element* form_element = el->FindElement("form"); if (form_element) { + double radius=0, length=0; string shape = form_element->GetAttributeValue("shape"); Element* radius_element = form_element->FindElement("radius"); *************** *** 402,405 **** --- 403,418 ---- PropertyManager->Tie("inertia/cg-z-in", this,3, (PMF)&FGMassBalance::GetXYZcg); + PropertyManager->Tie("inertia/ixx-slugs_ft2", this, + &FGMassBalance::GetIxx); + PropertyManager->Tie("inertia/iyy-slugs_ft2", this, + &FGMassBalance::GetIyy); + PropertyManager->Tie("inertia/izz-slugs_ft2", this, + &FGMassBalance::GetIzz); + PropertyManager->Tie("inertia/ixy-slugs_ft2", this, + &FGMassBalance::GetIxy); + PropertyManager->Tie("inertia/ixz-slugs_ft2", this, + &FGMassBalance::GetIxz); + PropertyManager->Tie("inertia/iyz-slugs_ft2", this, + &FGMassBalance::GetIyz); typedef int (FGMassBalance::*iOPV)() const; PropertyManager->Tie("inertia/print-mass-properties", this, (iOPV)0, |
From: Bertrand <bco...@us...> - 2016-02-27 17:49:15
|
Update of /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/aircraft/groundtest In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv956/check_cases/ground_tests/aircraft/groundtest Modified Files: groundtest.xml Log Message: Added a test case made after Richard Harrison's check case for his patch on channels rate Index: groundtest.xml =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/aircraft/groundtest/groundtest.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** groundtest.xml 12 Apr 2010 12:24:43 -0000 1.1 --- groundtest.xml 27 Feb 2016 17:49:12 -0000 1.2 *************** *** 48,51 **** --- 48,53 ---- <flight_control name="FCS: blank"/> + <system file="system-rate-1"/> + <system file="system-rate-4"/> <aerodynamics> |
From: Bertrand <bco...@us...> - 2016-02-27 17:49:15
|
Update of /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/systems In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv956/check_cases/ground_tests/systems Added Files: system-rate-1.xml system-rate-4.xml Log Message: Added a test case made after Richard Harrison's check case for his patch on channels rate --- NEW FILE --- <?xml version="1.0"?> <system name="FULL"> <property value="-10.0">tests/rate-1</property> <property value="0">tests/rate-1-dt-sum</property> <property value="0">tests/rate-1-actuator-dmd</property> <property value="1">tests/rate-1-actuator-rate</property> <property value="0">tests/system-rate-enabled</property> <channel name="control" execrate="1" execute="tests/system-rate-enabled"> <!-- this is just to do rate-1 = rate-1 + 1 --> <actuator name="tests/rate-1-actuator-value"> <input>tests/rate-1-actuator-dmd</input> <rate_limit>tests/rate-1-actuator-rate</rate_limit> <output>tests/rate-1-actuator-value</output> </actuator> <fcs_function name="tests/rate-1-v"> <function> <sum> <property>tests/rate-1</property> </sum> </function> </fcs_function> <!-- use actuator to test dt is correctly set --> <fcs_function name="tests/rate-1"> <function> <integer> <sum> <value>1.0</value> <property>tests/rate-1-v</property> </sum> </integer> </function> </fcs_function> <!-- extract dT into a property for examination --> <fcs_function name="tests/rate-1-dt"> <function> <sum> <property>simulation/dt</property> </sum> </function> </fcs_function> <fcs_function name="tests/rate-1-dt-sum"> <function> <sum> <property>tests/rate-1-dt-sum</property> <property>simulation/dt</property> </sum> </function> </fcs_function> </channel> </system> --- NEW FILE --- <system name="QUARTER" > <property value="0">tests/rate-4</property> <property value="0">tests/rate-4-actuator-dmd</property> <property value="1">tests/rate-4-actuator-rate</property> <channel name="control" execrate="4" execute="tests/system-rate-enabled"> <!-- this is just to do rate-4 = rate-4 + 1 --> <fcs_function name="tests/rate-4-v"> <function> <sum> <property>tests/rate-4</property> </sum> </function> </fcs_function> <fcs_function name="tests/rate-4"> <function> <integer> <sum> <value>1.0</value> <property>tests/rate-4-v</property> </sum> </integer> </function> </fcs_function> <!-- use actuator to test dt is correctly set --> <actuator name="tests/rate-4-actuator-value"> <input>tests/rate-4-actuator-dmd</input> <rate_limit>tests/rate-4-actuator-rate</rate_limit> <output>tests/rate-4-actuator-value</output> </actuator> <!-- extract dT into a property for examination --> <fcs_function name="tests/rate-4-dt"> <function> <sum> <property>simulation/channel-dt</property> </sum> </function> </fcs_function> <fcs_function name="tests/rate-4-dt-sum"> <function> <sum> <property>tests/rate-4-dt-sum</property> <property>simulation/channel-dt</property> </sum> </function> </fcs_function> </channel> </system> |
From: Bertrand <bco...@us...> - 2016-02-27 17:49:15
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv956/tests Modified Files: CMakeLists.txt Added Files: TestChannelRate.py Log Message: Added a test case made after Richard Harrison's check case for his patch on channels rate --- NEW FILE --- # TestChannelRate.py # # Test the channel rate feature introduced by Richard Harrison. # # Copyright (c) 2016 Bertrand Coconnier # # 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 3 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, see <http://www.gnu.org/licenses/> # import os from JSBSim_utils import JSBSimTestCase, CreateFDM, RunTest, ExecuteUntil class TestChannelRate(JSBSimTestCase): def setUp(self): JSBSimTestCase.setUp(self, 'check_cases', 'ground_tests') def testChannelRate(self): os.environ['JSBSIM_DEBUG'] = str(0) fdm = CreateFDM(self.sandbox) fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'systems-rate-test-0.xml')) fdm.run_ic() ExecuteUntil(fdm, 30.) self.assertEqual(fdm['simulation/frame'], fdm['tests/rate-1-v']-1) self.assertEqual(int(fdm['simulation/frame']/4), fdm['tests/rate-4']) self.assertEqual(fdm['simulation/dt'], fdm['tests/rate-1-dt']) self.assertEqual(fdm['simulation/dt']*4, fdm['tests/rate-4-dt']) self.assertEqual(fdm['simulation/sim-time-sec'], fdm['tests/rate-1-dt-sum']) self.assertAlmostEqual(fdm['simulation/dt'] * fdm['tests/rate-4'] * 4, fdm['tests/rate-4-dt-sum']) RunTest(TestChannelRate) Index: CMakeLists.txt =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CMakeLists.txt,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** CMakeLists.txt 17 Jan 2016 11:31:59 -0000 1.23 --- CMakeLists.txt 27 Feb 2016 17:49:12 -0000 1.24 *************** *** 39,43 **** TestHoldDown TestPitotAngle ! CheckTrim) foreach(test ${PYTHON_TESTS}) --- 39,44 ---- TestHoldDown TestPitotAngle ! CheckTrim ! TestChannelRate) foreach(test ${PYTHON_TESTS}) |
From: Bertrand <bco...@us...> - 2016-02-27 17:49:15
|
Update of /cvsroot/jsbsim/JSBSim/check_cases/ground_tests/scripts In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv956/check_cases/ground_tests/scripts Added Files: systems-rate-test-0.xml Log Message: Added a test case made after Richard Harrison's check case for his patch on channels rate --- NEW FILE --- <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="http://jsbsim.sf.net/JSBSimScript.xsl"?> <runscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://jsbsim.sf.net/JSBSimScript.xsd" name="Exec Systems rate"> <description>Exec Systems rate</description> <use aircraft="groundtest" initialize="reset00"/> <!-- launch with JSBSim root=check_cases/ground_tests scriptx=aircraft/systemsrate/systems-rate-test-0.xml --> <run start="0.0" end="60" dt="0.033333"> <property value="1">tests/system-rate-enabled</property> <event name="monitor"> <condition> simulation/sim-time-sec le 1 </condition> <notify> <property>tests/rate-1</property> <property>tests/rate-4</property> <property>tests/rate-1-actuator-value</property> <property>tests/rate-4-actuator-value</property> <property>simulation/dt</property> <property>simulation/channel-dt</property> </notify> </event> <event name="Actuator demands"> <condition> simulation/sim-time-sec ge 1 </condition> <!--<set name="simulation/do_simple_trim" value="1"/>--> <set name="tests/rate-1-actuator-dmd" value="123456" /> <set name="tests/rate-4-actuator-dmd" value="123456" /> <notify/> </event> <event name="Report"> <condition> simulation/sim-time-sec ge 30 </condition> <notify> <property>simulation/channel-dt</property> <property>simulation/dt</property> <property>simulation/frame</property> <property>tests/rate-1</property> <property>tests/rate-4</property> <property>tests/rate-1-actuator-value</property> <property>tests/rate-4-actuator-value</property> <property>tests/rate-1-dt-sum</property> <property>tests/rate-1-dt</property> <property>tests/rate-4-dt</property> <property>tests/rate-4-dt-sum</property> </notify> </event> </run> </runscript> |
From: Bertrand <bco...@us...> - 2016-02-27 16:54:19
|
Update of /cvsroot/jsbsim/JSBSim/src/models/flight_control In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31378/src/models/flight_control Modified Files: FGFCSComponent.cpp FGFCSComponent.h Log Message: Patch from Richard Harrison : an exec rate can now be specified for system channels Index: FGFCSComponent.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/flight_control/FGFCSComponent.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -r1.41 -r1.42 *** FGFCSComponent.cpp 12 Jul 2015 19:34:08 -0000 1.41 --- FGFCSComponent.cpp 27 Feb 2016 16:54:15 -0000 1.42 *************** *** 254,260 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! bool FGFCSComponent::Run(void) { ! return true; } --- 254,260 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! void FGFCSComponent::SetDtForFrameCount(int FrameCount) { ! dt = fcs->GetDt() * FrameCount; } *************** *** 283,291 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ! // The old way of naming FCS components allowed upper or lower case, spaces, etc. ! // but then the names were modified to fit into a property name heirarchy. This ! // was confusing (it wasn't done intentionally - it was a carryover from the early ! // design). We now support the direct naming of properties in the FCS component ! // name attribute. The old way is supported in code at this time, but deprecated. void FGFCSComponent::bind(void) --- 283,292 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // ! // The old way of naming FCS components allowed upper or lower case, spaces, ! // etc. but then the names were modified to fit into a property name ! // hierarchy. This was confusing (it wasn't done intentionally - it was a ! // carryover from the early design). We now support the direct naming of ! // properties in the FCS component name attribute. The old way is supported in ! // code at this time, but deprecated. void FGFCSComponent::bind(void) Index: FGFCSComponent.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/flight_control/FGFCSComponent.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** FGFCSComponent.h 12 Jul 2015 19:34:08 -0000 1.27 --- FGFCSComponent.h 27 Feb 2016 16:54:16 -0000 1.28 *************** *** 100,105 **** virtual ~FGFCSComponent(); ! virtual bool Run(void); virtual void SetOutput(void); double GetOutput (void) const {return Output;} std::string GetName(void) const {return Name;} --- 100,106 ---- virtual ~FGFCSComponent(); ! virtual bool Run(void) { return true; } virtual void SetOutput(void); + void SetDtForFrameCount(int FrameCount); double GetOutput (void) const {return Output;} std::string GetName(void) const {return Name;} |
From: Bertrand <bco...@us...> - 2016-02-27 16:54:19
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31378/src/models Modified Files: FGFCS.cpp FGFCS.h FGFCSChannel.h Log Message: Patch from Richard Harrison : an exec rate can now be specified for system channels Index: FGFCS.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCS.cpp,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -r1.92 -r1.93 *** FGFCS.cpp 12 Jul 2015 19:34:08 -0000 1.92 --- FGFCS.cpp 27 Feb 2016 16:54:15 -0000 1.93 *************** *** 78,82 **** %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex) { int i; --- 78,82 ---- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ ! FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex), ChannelRate(1) { int i; *************** *** 182,187 **** for (i=0; i<SystemChannels.size(); i++) { if (debug_lvl & 4) cout << " Executing System Channel: " << SystemChannels[i]->GetName() << endl; ! SystemChannels[i]->Execute(); } RunPostFunctions(); --- 182,189 ---- for (i=0; i<SystemChannels.size(); i++) { if (debug_lvl & 4) cout << " Executing System Channel: " << SystemChannels[i]->GetName() << endl; ! ChannelRate = SystemChannels[i]->GetRate(); ! SystemChannels[i]->Execute(GetTrimStatus()); } + ChannelRate = 1; RunPostFunctions(); *************** *** 512,515 **** --- 514,522 ---- string sOnOffProperty = channel_element->GetAttributeValue("execute"); string sChannelName = channel_element->GetAttributeValue("name"); + + int Rate = 0; + if (!channel_element->GetAttributeValue("execrate").empty()) + Rate = channel_element->GetAttributeValueAsNumber("execrate"); + if (sOnOffProperty.length() > 0) { FGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty); *************** *** 520,529 **** << "understood. The simulation will abort" << reset << endl; throw("Bad system definition"); ! } else { ! newChannel = new FGFCSChannel(sChannelName, OnOffPropertyNode); ! } ! } else { ! newChannel = new FGFCSChannel(sChannelName); ! } SystemChannels.push_back(newChannel); --- 527,534 ---- << "understood. The simulation will abort" << reset << endl; throw("Bad system definition"); ! } else ! newChannel = new FGFCSChannel(sChannelName, Rate, OnOffPropertyNode); ! } else ! newChannel = new FGFCSChannel(sChannelName, Rate); SystemChannels.push_back(newChannel); *************** *** 691,695 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! double FGFCS::GetDt(void) { return FDMExec->GetDeltaT()*rate; --- 696,700 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! double FGFCS::GetDt(void) const { return FDMExec->GetDeltaT()*rate; *************** *** 753,756 **** --- 758,762 ---- PropertyManager->Tie("gear/tailhook-pos-norm", this, &FGFCS::GetTailhookPos, &FGFCS::SetTailhookPos); PropertyManager->Tie("fcs/wing-fold-pos-norm", this, &FGFCS::GetWingFoldPos, &FGFCS::SetWingFoldPos); + PropertyManager->Tie("simulation/channel-dt", this, &FGFCS::GetChannelDeltaT); } Index: FGFCS.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCS.h,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -r1.49 -r1.50 *** FGFCS.h 12 Jul 2015 19:34:08 -0000 1.49 --- FGFCS.h 27 Feb 2016 16:54:15 -0000 1.50 *************** *** 558,566 **** void AddThrottle(void); void AddGear(unsigned int NumGear); ! double GetDt(void); FGPropertyManager* GetPropertyManager(void) { return PropertyManager; } bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); } private: --- 558,567 ---- void AddThrottle(void); void AddGear(unsigned int NumGear); ! double GetDt(void) const; FGPropertyManager* GetPropertyManager(void) { return PropertyManager; } bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); } + double GetChannelDeltaT(void) const { return GetDt() * ChannelRate; } private: *************** *** 583,586 **** --- 584,588 ---- double TailhookPos, WingFoldPos; SystemType systype; + int ChannelRate; typedef std::vector <FGFCSChannel*> Channels; Index: FGFCSChannel.h =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGFCSChannel.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** FGFCSChannel.h 28 Sep 2015 08:57:32 -0000 1.6 --- FGFCSChannel.h 27 Feb 2016 16:54:15 -0000 1.7 *************** *** 60,64 **** The <channel> may be defined within a <system>, <autopilot> or <flight_control> element. Channels are a way to group sets of components that perform ! a specific purpose or algorithm. */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --- 60,72 ---- The <channel> may be defined within a <system>, <autopilot> or <flight_control> element. Channels are a way to group sets of components that perform ! a specific purpose or algorithm. ! Created within a <system> tag, the channel is defined as follows ! <channel name="name" [execute="property"] [execrate="rate"]> ! name is the name of the channel - in the old way this would also be used to bind elements ! execute [optional] is the property that defines when to execute this channel; an on/off switch ! execrate [optional] is the rate at which the channel should execute. ! A value of 0 or 1 will execute the channel every frame, a value of 2 ! every other frame (half rate), a value of 4 is every 4th frame (quarter rate) ! */ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% *************** *** 71,78 **** public: /// Constructor ! FGFCSChannel(std::string name, FGPropertyNode* node=0) : ! OnOffNode(node), Name(name) { } /// Destructor ~FGFCSChannel() { --- 79,88 ---- public: /// Constructor ! FGFCSChannel(const std::string &name, int execRate, FGPropertyNode* node=0) ! : OnOffNode(node), Name(name), ExecFrameCountSinceLastRun(1) { + ExecRate = execRate < 1 ? 1 : execRate; } + /// Destructor ~FGFCSChannel() { *************** *** 84,88 **** /// Adds a component to a channel ! void Add(FGFCSComponent* comp) {FCSComponents.push_back(comp);} /// Returns the number of components in the channel. size_t GetNumComponents() {return FCSComponents.size();} --- 94,101 ---- /// Adds a component to a channel ! void Add(FGFCSComponent* comp) { ! FCSComponents.push_back(comp); ! comp->SetDtForFrameCount(ExecRate); ! } /// Returns the number of components in the channel. size_t GetNumComponents() {return FCSComponents.size();} *************** *** 102,114 **** } /// Executes all the components in a channel. ! void Execute() { // If there is an on/off property supplied for this channel, check // the value. If it is true, permit execution to continue. If not, return // and do not execute the channel. ! if (OnOffNode != 0) ! if (!OnOffNode->getBoolValue()) return; ! for (unsigned int i=0; i<FCSComponents.size(); i++) FCSComponents[i]->Run(); } private: --- 115,135 ---- } /// Executes all the components in a channel. ! void Execute(bool trimStatus) { // If there is an on/off property supplied for this channel, check // the value. If it is true, permit execution to continue. If not, return // and do not execute the channel. ! if (OnOffNode && !OnOffNode->getBoolValue()) return; ! // channel will be run at rate 1 if trimming, or when the next execrate ! // frame is reached ! if (trimStatus || ExecFrameCountSinceLastRun >= ExecRate) { ! for (unsigned int i=0; i<FCSComponents.size(); i++) ! FCSComponents[i]->Run(); ! ExecFrameCountSinceLastRun = 0; ! } ! ExecFrameCountSinceLastRun++; } + /// Get the channel rate + int GetRate(void) const { return ExecRate; } private: *************** *** 116,119 **** --- 137,143 ---- FGConstPropertyNode_ptr OnOffNode; std::string Name; + + int ExecRate; // rate at which this system executes, 0 or 1 every frame, 2 every second frame etc.. + int ExecFrameCountSinceLastRun; }; |
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv25015/tests Modified Files: CheckDebugLvl.py JSBSim_utils.py RunCheckCases.py TestGustReset.py TestModelLoading.py TestPointMassInertia.py TestScriptOutput.py Log Message: Replaced the homemade Table class by the much more reliable pandas library Index: CheckDebugLvl.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckDebugLvl.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** CheckDebugLvl.py 30 Jan 2016 18:50:23 -0000 1.2 --- CheckDebugLvl.py 31 Jan 2016 16:40:06 -0000 1.3 *************** *** 21,25 **** import os ! from JSBSim_utils import JSBSimTestCase, CreateFDM, Table, ExecuteUntil, RunTest --- 21,27 ---- import os ! import pandas as pd ! from JSBSim_utils import (JSBSimTestCase, CreateFDM, ExecuteUntil, ! isDataMatching, FindDifferences, RunTest) *************** *** 36,41 **** ExecuteUntil(fdm, 1000.) ! ref, current = Table(), Table() ! ref.ReadCSV('BallOut.csv') del fdm --- 38,42 ---- ExecuteUntil(fdm, 1000.) ! ref = pd.read_csv('BallOut.csv', index_col=0) del fdm *************** *** 48,56 **** ExecuteUntil(fdm, 1000.) ! current.ReadCSV('BallOut.csv') ! diff = ref.compare(current) self.longMessage = True ! self.assertTrue(diff.empty(), msg='\n'+repr(diff)) RunTest(TestDebugLvl) --- 49,63 ---- ExecuteUntil(fdm, 1000.) ! current = pd.read_csv('BallOut.csv', index_col=0) ! # Check the data are matching i.e. the time steps are the same between ! # the two data sets and that the output data are also the same. ! self.assertTrue(isDataMatching(ref, current)) ! ! # Find all the data that are differing by more than 1E-8 between the ! # two data sets. ! diff = FindDifferences(ref, current, 1E-8) self.longMessage = True ! self.assertEqual(len(diff), 0, msg='\n'+diff.to_string()) RunTest(TestDebugLvl) Index: JSBSim_utils.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/JSBSim_utils.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** JSBSim_utils.py 30 Jan 2016 18:50:24 -0000 1.9 --- JSBSim_utils.py 31 Jan 2016 16:40:06 -0000 1.10 *************** *** 20,23 **** --- 20,25 ---- import os, sys, csv, string, tempfile, shutil, unittest import xml.etree.ElementTree as et + import numpy as np + import pandas as pd import jsbsim *************** *** 84,182 **** - class MismatchError(Exception): - pass - - - class Table: - def __init__(self, headers=[]): - if headers: - self._lines = [headers] - else: - self._lines = [] - self._missing = [] - - def ReadCSV(self, filename): - self._lines = [] - self.missing = [] - - file_csv = open(filename, 'r') - first_line = True - for line in csv.reader(file_csv, delimiter=','): - if first_line: - first_line = False - line = map(string.strip, line) - else: - line = map(float, line) - self._lines += [line] - - file_csv.close() - - def add_line(self, line): - if len(line) != len(self._lines[0]): - raise MismatchError - self._lines += [line] - - def get_column(self, col): - column = [] - - if isinstance(col, int): - if col < 0 or col >= len(self._lines[0]): - raise AttributeError - elif isinstance(col, str): - header = string.strip(col) - for col in xrange(len(self._lines[0])): - if header == self._lines[0][col]: - break - else: - raise AttributeError - else: - raise TypeError - - for line in self._lines: - column += [line[col]] - return column - - def compare(self, other, precision=1E-5): - result = Table(['Property', 'delta', 'Time', 'ref value', 'value']) - - if len(self._lines) != len(other._lines): - raise MismatchError - - for row, line in enumerate(self._lines[1:]): - if abs(line[0] - other._lines[row+1][0]) > 1E-10: - print row, line[0], other._lines[row+1][0] - raise MismatchError - - for col, key in enumerate(self._lines[0][1:]): - for col0, key0 in enumerate(other._lines[0]): - if key == key0: - break - else: - result._missing += [key] - continue - - comparison = [key, 0.0] - for row, line in enumerate(self._lines[1:]): - delta = abs(line[col+1] - other._lines[row+1][col0]) - if delta > comparison[1]: - comparison = [key, delta, line[0], line[col+1], - other._lines[row+1][col0]] - - if comparison[1] > precision: - result.add_line(comparison) - - return result - - def empty(self): - return len(self._lines) <= 1 - - def __repr__(self): - col_width = [max(len(str(item)) for item in col) for col in zip(*self._lines)] - output = '' - for line in self._lines: - output += "|" + "|".join("{:{}}".format(str(item), col_width[i]) for i, item in enumerate(line)) + "|\n" - return output - - def CopyAircraftDef(script_path, sandbox): # Get the aircraft name --- 86,89 ---- *************** *** 255,256 **** --- 162,184 ---- if test_result.failures or test_result.errors: sys.exit(-1) # 'make test' will report the test failed. + + + def isDataMatching(ref, other): + delta = np.abs(ref - other) + # Check the data are matching i.e. the time steps are the same between the + # two data sets and is also the same for the output data. If it does not, + # pandas will fill the missing data with NaNs. Below we are checking there + # are no NaNs in delta. + return delta.notnull().any().any() + + + def FindDifferences(ref, other, tol): + delta = np.abs(ref - other) + + idxmax = delta.idxmax() + ref_max = pd.Series(ref.lookup(idxmax, ref.columns), index=ref.columns) + other_max = pd.Series(other.lookup(idxmax, other.columns), + index=other.columns) + diff = pd.concat([idxmax, delta.max(), ref_max, other_max], axis=1) + diff.columns = ['Time', 'delta', 'ref value', 'value'] + return diff[diff['delta'] > tol] Index: RunCheckCases.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/RunCheckCases.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** RunCheckCases.py 30 Jan 2016 18:50:24 -0000 1.5 --- RunCheckCases.py 31 Jan 2016 16:40:06 -0000 1.6 *************** *** 21,25 **** import os ! from JSBSim_utils import JSBSimTestCase, CreateFDM, Table, RunTest --- 21,27 ---- import os ! import pandas as pd ! from JSBSim_utils import (JSBSimTestCase, CreateFDM, isDataMatching, ! FindDifferences, RunTest) *************** *** 38,49 **** pass ! ref, current = Table(), Table() ! ref.ReadCSV(self.sandbox.path_to_jsbsim_file('logged_data', ! 'BallOut.csv')) ! current.ReadCSV('BallOut.csv') ! ! diff = ref.compare(current) self.longMessage = True ! self.assertTrue(diff.empty(), msg='\n'+repr(diff)) RunTest(TestOrbitCheckCase) --- 40,57 ---- pass ! ref = pd.read_csv(self.sandbox.path_to_jsbsim_file('logged_data', ! 'BallOut.csv'), ! index_col=0) ! current = pd.read_csv('BallOut.csv', index_col=0) ! ! # Check the data are matching i.e. the time steps are the same between ! # the two data sets and that the output data are also the same. ! self.assertTrue(isDataMatching(ref, current)) ! ! # Find all the data that are differing by more than 1E-5 between the ! # two data sets. ! diff = FindDifferences(ref, current, 1E-5) self.longMessage = True ! self.assertEqual(len(diff), 0, msg='\n'+diff.to_string()) RunTest(TestOrbitCheckCase) Index: TestGustReset.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestGustReset.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** TestGustReset.py 30 Jan 2016 18:50:24 -0000 1.2 --- TestGustReset.py 31 Jan 2016 16:40:06 -0000 1.3 *************** *** 20,24 **** # ! from JSBSim_utils import JSBSimTestCase, CreateFDM, Table, ExecuteUntil, RunTest --- 20,26 ---- # ! import pandas as pd ! from JSBSim_utils import (JSBSimTestCase, CreateFDM, ExecuteUntil, ! isDataMatching, FindDifferences, RunTest) *************** *** 34,39 **** ExecuteUntil(fdm, 15.5) ! ref, current = Table(), Table() ! ref.ReadCSV(self.sandbox('output.csv')) fdm['simulation/randomseed'] = 0.0 --- 36,40 ---- ExecuteUntil(fdm, 15.5) ! ref = pd.read_csv('output.csv', index_col=0) fdm['simulation/randomseed'] = 0.0 *************** *** 41,49 **** ExecuteUntil(fdm, 15.5) ! current.ReadCSV(self.sandbox('output_0.csv')) ! diff = ref.compare(current) self.longMessage = True ! self.assertTrue(diff.empty(), msg='\n'+repr(diff)) RunTest(TestGustReset) --- 42,56 ---- ExecuteUntil(fdm, 15.5) ! current = pd.read_csv('output_0.csv', index_col=0) ! # Check the data are matching i.e. the time steps are the same between ! # the two data sets and that the output data are also the same. ! self.assertTrue(isDataMatching(ref, current)) ! ! # Find all the data that are differing by more than 1E-8 between the ! # two data sets. ! diff = FindDifferences(ref, current, 1E-8) self.longMessage = True ! self.assertEqual(len(diff), 0, msg='\n'+diff.to_string()) RunTest(TestGustReset) Index: TestModelLoading.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestModelLoading.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** TestModelLoading.py 30 Jan 2016 18:50:24 -0000 1.5 --- TestModelLoading.py 31 Jan 2016 16:40:06 -0000 1.6 *************** *** 22,26 **** import os import xml.etree.ElementTree as et ! from JSBSim_utils import JSBSimTestCase, Table, CreateFDM, ExecuteUntil, append_xml, CopyAircraftDef, RunTest --- 22,29 ---- import os import xml.etree.ElementTree as et ! import pandas as pd ! from JSBSim_utils import (JSBSimTestCase, CreateFDM, ExecuteUntil, append_xml, ! CopyAircraftDef, isDataMatching, FindDifferences, ! RunTest) *************** *** 39,48 **** ExecuteUntil(fdm, 50.0) ! self.ref = Table() ! self.ref.ReadCSV("output.csv") # Since the script will work with modified versions of the aircraft XML ! # definition file, we need to make a copy of the directory that contains ! # all the input data of that aircraft tree, self.aircraft_name, self.path_to_jsbsim_aircrafts = CopyAircraftDef(self.script, self.sandbox) --- 42,50 ---- ExecuteUntil(fdm, 50.0) ! self.ref = pd.read_csv("output.csv", index_col=0) # Since the script will work with modified versions of the aircraft XML ! # definition file, we need to make a copy of the directory that ! # contains all the input data of that aircraft tree, self.aircraft_name, self.path_to_jsbsim_aircrafts = CopyAircraftDef(self.script, self.sandbox) *************** *** 95,101 **** # is located. if not os.path.exists(section_file) and section_element.tag == 'system': ! section_file = os.path.join(self.path_to_jsbsim_aircrafts, "systems", file_name) if not os.path.exists(section_file): ! section_file = self.sandbox.path_to_jsbsim_file("systems", file_name) # The original <section> tag is dropped and replaced by the content of --- 97,105 ---- # is located. if not os.path.exists(section_file) and section_element.tag == 'system': ! section_file = os.path.join(self.path_to_jsbsim_aircrafts, ! "systems", file_name) if not os.path.exists(section_file): ! section_file = self.sandbox.path_to_jsbsim_file("systems", ! file_name) # The original <section> tag is dropped and replaced by the content of *************** *** 118,122 **** # directory build/.../aircraft fdm.set_aircraft_path('aircraft') ! fdm.set_output_directive(self.sandbox.path_to_jsbsim_file('tests', 'output.xml')) fdm.load_script(self.script) fdm['simulation/randomseed'] = 0.0 --- 122,127 ---- # directory build/.../aircraft fdm.set_aircraft_path('aircraft') ! fdm.set_output_directive(self.sandbox.path_to_jsbsim_file('tests', ! 'output.xml')) fdm.load_script(self.script) fdm['simulation/randomseed'] = 0.0 *************** *** 125,137 **** ExecuteUntil(fdm, 50.0) ! mod = Table() ! mod.ReadCSV('output.csv') # Whether the data is read from the aircraft definition file or from an # external file, the results shall be exactly identical. Hence the # precision set to 0.0. ! diff = self.ref.compare(mod, 0.0) ! self.assertTrue(diff.empty(), ! msg='\nTesting section "'+section+'"\n'+repr(diff)) def test_model_loading(self): --- 130,145 ---- ExecuteUntil(fdm, 50.0) ! mod = pd.read_csv('output.csv', index_col=0) ! ! # Check the data are matching i.e. the time steps are the same between ! # the two data sets and that the output data are also the same. ! self.assertTrue(isDataMatching(self.ref, mod)) # Whether the data is read from the aircraft definition file or from an # external file, the results shall be exactly identical. Hence the # precision set to 0.0. ! diff = FindDifferences(self.ref, mod, 0.0) ! self.assertEqual(len(diff), 0, ! msg='\nTesting section "'+section+'"\n'+diff.to_string()) def test_model_loading(self): *************** *** 139,144 **** self.BuildReference('c1724.xml') ! output_ref = Table() ! output_ref.ReadCSV('JSBout172B.csv') self.ProcessAndCompare('aerodynamics') --- 147,151 ---- self.BuildReference('c1724.xml') ! output_ref = pd.read_csv('JSBout172B.csv', index_col=0) self.ProcessAndCompare('aerodynamics') *************** *** 159,167 **** # file. self.ProcessAndCompare('output') ! mod = Table() ! mod.ReadCSV('JSBout172B.csv') ! diff = output_ref.compare(mod, 0.0) ! self.assertTrue(diff.empty(), ! msg='\nTesting section "output"\n'+repr(diff)) self.BuildReference('weather-balloon.xml') --- 166,174 ---- # file. self.ProcessAndCompare('output') ! mod = pd.read_csv('JSBout172B.csv', index_col=0) ! self.assertTrue(isDataMatching(output_ref, mod)) ! diff = FindDifferences(output_ref, mod, 0.0) ! self.assertEqual(len(diff), 0, ! msg='\nTesting section "output"\n'+diff.to_string()) self.BuildReference('weather-balloon.xml') Index: TestPointMassInertia.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestPointMassInertia.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** TestPointMassInertia.py 30 Jan 2016 18:50:24 -0000 1.3 --- TestPointMassInertia.py 31 Jan 2016 16:40:06 -0000 1.4 *************** *** 19,25 **** # ! import string, numpy import xml.etree.ElementTree as et ! from JSBSim_utils import JSBSimTestCase, CreateFDM, ExecuteUntil, Table, CopyAircraftDef, RunTest --- 19,29 ---- # ! import string ! import numpy as np ! import pandas as pd import xml.etree.ElementTree as et ! from JSBSim_utils import (JSBSimTestCase, CreateFDM, ExecuteUntil, ! CopyAircraftDef, isDataMatching, FindDifferences, ! RunTest) *************** *** 35,40 **** ExecuteUntil(fdm, 50.0) ! ref = Table() ! ref.ReadCSV("output.csv") tree, aircraft_name, path_to_jsbsim_aircrafts = CopyAircraftDef(script_path, self.sandbox) --- 39,43 ---- ExecuteUntil(fdm, 50.0) ! ref = pd.read_csv("output.csv", index_col=0) tree, aircraft_name, path_to_jsbsim_aircrafts = CopyAircraftDef(script_path, self.sandbox) *************** *** 54,58 **** pointmass_element.remove(form_element) ! inertia = numpy.zeros((3, 3)) if string.strip(shape) == 'tube': inertia[0, 0] = radius * radius --- 57,61 ---- pointmass_element.remove(form_element) ! inertia = np.zeros((3, 3)) if string.strip(shape) == 'tube': inertia[0, 0] = radius * radius *************** *** 86,95 **** ExecuteUntil(fdm, 50.0) ! mod = Table() ! mod.ReadCSV("output.csv") ! diff = ref.compare(mod) ! self.assertTrue(diff.empty(), ! msg='\n'+repr(diff)) RunTest(TestPointMassInertia) --- 89,103 ---- ExecuteUntil(fdm, 50.0) ! mod = pd.read_csv("output.csv", index_col=0) ! # Check the data are matching i.e. the time steps are the same between ! # the two data sets and that the output data are also the same. ! self.assertTrue(isDataMatching(ref, mod)) ! ! # Find all the data that are differing by more than 1E-8 between the ! # two data sets. ! diff = FindDifferences(ref, mod, 1E-8) ! self.longMessage = True ! self.assertEqual(len(diff), 0, msg='\n'+diff.to_string()) RunTest(TestPointMassInertia) Index: TestScriptOutput.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestScriptOutput.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** TestScriptOutput.py 30 Jan 2016 18:50:24 -0000 1.3 --- TestScriptOutput.py 31 Jan 2016 16:40:06 -0000 1.4 *************** *** 23,27 **** import pandas as pd import numpy as np ! from JSBSim_utils import JSBSimTestCase, CreateFDM, ExecuteUntil, RunTest --- 23,28 ---- import pandas as pd import numpy as np ! from JSBSim_utils import (JSBSimTestCase, CreateFDM, ExecuteUntil, ! isDataMatching, RunTest) *************** *** 75,83 **** self.assertTrue(self.sandbox.exists(output_tag.attrib['name']), msg="The file 'output.csv' has not been created") ! orig = pd.read_csv('JSBout172B.csv') ! test = pd.read_csv('test.csv') ! self.assertEqual(np.max(orig['Time']-test['Time']), 0.0) pname = '/fdm/jsbsim/' + property_tag.text ! self.assertEqual(np.max(orig[pname]-test[pname]), 0.0) RunTest(TestScriptOutput) --- 76,96 ---- self.assertTrue(self.sandbox.exists(output_tag.attrib['name']), msg="The file 'output.csv' has not been created") ! orig = pd.read_csv('JSBout172B.csv', index_col=0) ! test = pd.read_csv('test.csv', index_col=0) pname = '/fdm/jsbsim/' + property_tag.text ! ref = orig[pname] ! mod = test[pname] ! ! # Check the data are matching i.e. the time steps are the same between ! # the two data sets. ! self.assertTrue(isDataMatching(ref, mod)) ! ! # Find all the data that are differing by more than 1E-8 between the ! # two data sets. ! delta = pd.concat([np.abs(ref - mod), ref, mod], axis=1) ! delta.columns = ['delta', 'ref value', 'value'] ! diff = delta[delta['delta'] > 1E-8] ! self.longMessage = True ! self.assertEqual(len(diff), 0, msg='\n'+diff.to_string()) RunTest(TestScriptOutput) |
From: Bertrand <bco...@us...> - 2016-01-31 11:29:44
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv12453/tests Modified Files: CheckMomentsUpdate.py CheckOutputRate.py Log Message: Use the pandas library instead of JSBSim_utils.Table Index: CheckMomentsUpdate.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckMomentsUpdate.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** CheckMomentsUpdate.py 30 Jan 2016 18:50:24 -0000 1.4 --- CheckMomentsUpdate.py 31 Jan 2016 11:29:41 -0000 1.5 *************** *** 20,24 **** # ! from JSBSim_utils import JSBSimTestCase, CreateFDM, Table, ExecuteUntil, RunTest mol2lbs = 0.00013841 * 32.174049 --- 20,25 ---- # ! import pandas as pd ! from JSBSim_utils import JSBSimTestCase, CreateFDM, ExecuteUntil, RunTest mol2lbs = 0.00013841 * 32.174049 *************** *** 79,87 **** self.CheckCGPosition() ! csv = Table() ! csv.ReadCSV('output.csv') ! Mby = csv.get_column('M_{Buoyant} (ft-lbs)')[-1] ! Fbx = csv.get_column('F_{Buoyant x} (lbs)')[-1] ! Fbz = csv.get_column('F_{Buoyant z} (lbs)')[-1] self.assertAlmostEqual(Fbx * CGz - Fbz * CGx, Mby, delta=1E-7, --- 80,87 ---- self.CheckCGPosition() ! csv = pd.read_csv('output.csv') ! Mby = csv['M_{Buoyant} (ft-lbs)'].iget(-1) ! Fbx = csv['F_{Buoyant x} (lbs)'].iget(-1) ! Fbz = csv['F_{Buoyant z} (lbs)'].iget(-1) self.assertAlmostEqual(Fbx * CGz - Fbz * CGx, Mby, delta=1E-7, Index: CheckOutputRate.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckOutputRate.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** CheckOutputRate.py 30 Jan 2016 18:50:24 -0000 1.5 --- CheckOutputRate.py 31 Jan 2016 11:29:41 -0000 1.6 *************** *** 22,26 **** import string import xml.etree.ElementTree as et ! from JSBSim_utils import JSBSimTestCase, CreateFDM, append_xml, Table, RunTest --- 22,27 ---- import string import xml.etree.ElementTree as et ! import pandas as pd ! from JSBSim_utils import JSBSimTestCase, CreateFDM, append_xml, RunTest *************** *** 78,83 **** self.fdm.run() ! output = Table() ! output.ReadCSV(self.output_file) # According to the settings, the output file must contain 2 lines in --- 79,83 ---- self.fdm.run() ! output = pd.read_csv(self.output_file) # According to the settings, the output file must contain 2 lines in *************** *** 85,91 **** # 1. The initial conditions # 2. The output after 'rate' iterations ! self.assertEqual(output.get_column(0)[1], 0.0) ! self.assertEqual(output.get_column(0)[2], self.rate * self.dt) ! self.assertEqual(output.get_column(0)[2], self.fdm["simulation/sim-time-sec"]) --- 85,91 ---- # 1. The initial conditions # 2. The output after 'rate' iterations ! self.assertEqual(output['Time'].iget(0), 0.0) ! self.assertEqual(output['Time'].iget(1), self.rate * self.dt) ! self.assertEqual(output['Time'].iget(1), self.fdm["simulation/sim-time-sec"]) *************** *** 101,111 **** self.fdm.run() ! output = Table() ! output.ReadCSV(self.output_file) # According to the settings, the output file must contain 1 line in # addition to the headers : # 1. The output after 'rate' iterations ! self.assertEqual(output.get_column(0)[1], self.fdm["simulation/sim-time-sec"]) --- 101,110 ---- self.fdm.run() ! output = pd.read_csv(self.output_file) # According to the settings, the output file must contain 1 line in # addition to the headers : # 1. The output after 'rate' iterations ! self.assertEqual(output['Time'].iget(0), self.fdm["simulation/sim-time-sec"]) *************** *** 131,140 **** self.fdm.run() ! output = Table() ! output.ReadCSV(self.output_file) # The frame at which the data is logged must be the next multiple of # the output rate ! self.assertEqual(int(output.get_column(0)[1]/self.dt), (1 + frame/self.rate)*self.rate) --- 130,138 ---- self.fdm.run() ! output = pd.read_csv(self.output_file) # The frame at which the data is logged must be the next multiple of # the output rate ! self.assertEqual(int(output['Time'].iget(0)/self.dt), (1 + frame/self.rate)*self.rate) *************** *** 156,166 **** self.fdm.run() ! output = Table() ! output.ReadCSV(self.output_file) # According to the settings, the output file must contain 1 line in # addition to the headers : # 1. The output after 'rate' iterations ! self.assertEqual(output.get_column(0)[1], self.fdm["simulation/sim-time-sec"]) --- 154,163 ---- self.fdm.run() ! output = pd.read_csv(self.output_file) # According to the settings, the output file must contain 1 line in # addition to the headers : # 1. The output after 'rate' iterations ! self.assertEqual(output['Time'].iget(0), self.fdm["simulation/sim-time-sec"]) |
From: Bertrand <bco...@us...> - 2016-01-31 11:13:03
|
Update of /cvsroot/jsbsim/JSBSim/src/models In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11768/src/models Modified Files: FGAccelerations.cpp Log Message: Fixed a bug that made the test TestGustReset to fail : the acceleration vUVWdot was not reset to zero and the time was reset to zero *after* the ICs were written to the output CSV file. Index: FGAccelerations.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/models/FGAccelerations.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** FGAccelerations.cpp 9 Dec 2015 04:28:18 -0000 1.25 --- FGAccelerations.cpp 31 Jan 2016 11:13:00 -0000 1.26 *************** *** 79,82 **** --- 79,83 ---- vPQRidot.InitMatrix(); vUVWidot.InitMatrix(); + vUVWdot.InitMatrix(); vGravAccel.InitMatrix(); vBodyAccel.InitMatrix(); *************** *** 102,105 **** --- 103,107 ---- vPQRidot.InitMatrix(); vUVWidot.InitMatrix(); + vUVWdot.InitMatrix(); vGravAccel.InitMatrix(); vBodyAccel.InitMatrix(); |
From: Bertrand <bco...@us...> - 2016-01-31 11:13:03
|
Update of /cvsroot/jsbsim/JSBSim/src In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11768/src Modified Files: FGFDMExec.cpp Log Message: Fixed a bug that made the test TestGustReset to fail : the acceleration vUVWdot was not reset to zero and the time was reset to zero *after* the ICs were written to the output CSV file. Index: FGFDMExec.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/FGFDMExec.cpp,v retrieving revision 1.186 retrieving revision 1.187 diff -C2 -r1.186 -r1.187 *** FGFDMExec.cpp 10 Jan 2016 16:32:26 -0000 1.186 --- FGFDMExec.cpp 31 Jan 2016 11:12:59 -0000 1.187 *************** *** 613,622 **** } - RunIC(); - if (Script) Script->ResetEvents(); else Setsim_time(0.0); } --- 613,622 ---- } if (Script) Script->ResetEvents(); else Setsim_time(0.0); + + RunIC(); } |
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv3654/tests Modified Files: CheckAircrafts.py CheckDebugLvl.py CheckFGBug1503.py CheckMomentsUpdate.py CheckOutputRate.py CheckSimTimeReset.py CheckTrim.py JSBSim_utils.py ResetOutputFiles.py RunCheckCases.py TestAccelerometer.py TestCosineGust.py TestFuelTanksInertia.py TestGustReset.py TestHoldDown.py TestICOverride.py TestInitialConditions.py TestInputSocket.py TestModelLoading.py TestPitotAngle.py TestPointMassInertia.py TestScriptOutput.py Log Message: Refactorized the code taking opportunity of the new class JSBSimTestCase that all test cases are now inheriting from. In addition, all the relative paths are now taken from the sandbox in which JSBSim executes. Index: CheckAircrafts.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckAircrafts.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** CheckAircrafts.py 12 Jul 2015 15:38:09 -0000 1.2 --- CheckAircrafts.py 30 Jan 2016 18:50:23 -0000 1.3 *************** *** 20,37 **** # ! import os, unittest, sys, string ! import xml.etree.ElementTree as et ! from JSBSim_utils import SandBox, append_xml, CreateFDM, CheckXMLFile ! class CheckAircrafts(unittest.TestCase): ! def setUp(self): ! self.sandbox = SandBox() ! ! def tearDown(self): ! self.sandbox.erase() ! def testAircrafts(self): ! aircraft_path = self.sandbox.elude(self.sandbox.path_to_jsbsim_file('aircraft')) for d in os.listdir(aircraft_path): fullpath = os.path.join(aircraft_path, d) --- 20,30 ---- # ! import os ! from JSBSim_utils import JSBSimTestCase, append_xml, CreateFDM, CheckXMLFile, RunTest ! class CheckAircrafts(JSBSimTestCase): def testAircrafts(self): ! aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft') for d in os.listdir(aircraft_path): fullpath = os.path.join(aircraft_path, d) *************** *** 58,66 **** if CheckXMLFile(f, 'initialize'): self.assertTrue(fdm.load_ic(f, False), ! msg='Failed to load IC %s for aircraft %s' %(f,d)) try: fdm.run_ic() except RuntimeError: ! self.fail('Failed to run IC %s for aircraft %s' %(f,d)) break --- 51,59 ---- if CheckXMLFile(f, 'initialize'): self.assertTrue(fdm.load_ic(f, False), ! msg='Failed to load IC %s for aircraft %s' % (f, d)) try: fdm.run_ic() except RuntimeError: ! self.fail('Failed to run IC %s for aircraft %s' % (f, d)) break *************** *** 68,74 **** del fdm ! ! suite = unittest.TestLoader().loadTestsFromTestCase(CheckAircrafts) ! test_result = unittest.TextTestRunner(verbosity=2).run(suite) ! if test_result.failures or test_result.errors: ! sys.exit(-1) # 'make test' will report the test failed. --- 61,63 ---- del fdm ! RunTest(CheckAircrafts) Index: CheckDebugLvl.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckDebugLvl.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CheckDebugLvl.py 16 Aug 2015 10:33:26 -0000 1.1 --- CheckDebugLvl.py 30 Jan 2016 18:50:23 -0000 1.2 *************** *** 1,6 **** ! # RunCheckCases.py # # Regression test that check that the same results are obtained whether the ! # environment variable is set ot zero or not. # # Copyright (c) 2015 Bertrand Coconnier --- 1,6 ---- ! # CheckDebugLvl.py # # Regression test that check that the same results are obtained whether the ! # environment variable JSBSIM_DEBUG is set ot zero or not. # # Copyright (c) 2015 Bertrand Coconnier *************** *** 20,37 **** # ! import sys, unittest, os ! from JSBSim_utils import CreateFDM, Table, SandBox, ExecuteUntil ! class TestDebugLvl(unittest.TestCase): def setUp(self): ! self.sandbox = SandBox('check_cases', 'orbit') ! ! def tearDown(self): ! self.sandbox.erase() def testDebugLvl(self): fdm = CreateFDM(self.sandbox) ! fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'ball_orbit.xml')) fdm.run_ic() --- 20,35 ---- # ! import os ! from JSBSim_utils import JSBSimTestCase, CreateFDM, Table, ExecuteUntil, RunTest ! class TestDebugLvl(JSBSimTestCase): def setUp(self): ! JSBSimTestCase.setUp(self, 'check_cases', 'orbit') def testDebugLvl(self): fdm = CreateFDM(self.sandbox) ! fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', ! 'ball_orbit.xml')) fdm.run_ic() *************** *** 39,53 **** ref, current = Table(), Table() ! ref.ReadCSV(self.sandbox('BallOut.csv')) del fdm ! os.environ["JSBSIM_DEBUG"]=str(0) fdm = CreateFDM(self.sandbox) ! fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', 'ball_orbit.xml')) fdm.run_ic() ExecuteUntil(fdm, 1000.) ! current.ReadCSV(self.sandbox('BallOut.csv')) diff = ref.compare(current) --- 37,52 ---- ref, current = Table(), Table() ! ref.ReadCSV('BallOut.csv') del fdm ! os.environ["JSBSIM_DEBUG"] = str(0) fdm = CreateFDM(self.sandbox) ! fdm.load_script(self.sandbox.path_to_jsbsim_file('scripts', ! 'ball_orbit.xml')) fdm.run_ic() ExecuteUntil(fdm, 1000.) ! current.ReadCSV('BallOut.csv') diff = ref.compare(current) *************** *** 55,60 **** self.assertTrue(diff.empty(), msg='\n'+repr(diff)) ! suite = unittest.TestLoader().loadTestsFromTestCase(TestDebugLvl) ! test_result = unittest.TextTestRunner(verbosity=2).run(suite) ! if test_result.failures or test_result.errors: ! sys.exit(-1) # 'make test' will report the test failed. --- 54,56 ---- self.assertTrue(diff.empty(), msg='\n'+repr(diff)) ! RunTest(TestDebugLvl) Index: CheckFGBug1503.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckFGBug1503.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** CheckFGBug1503.py 20 Mar 2015 18:43:50 -0000 1.6 --- CheckFGBug1503.py 30 Jan 2016 18:50:23 -0000 1.7 *************** *** 24,41 **** # is used. # 2. The property 'fcs/left-aileron-pos-rad' remains equal to 0.0 during the ! # execution of the script c1724.xml when <rate_limit> is read from a property. # 3. The actuator output value is correctly driven by rate_limit. ! import unittest, os, time, sys, string import xml.etree.ElementTree as et from multiprocessing import Process from scipy import stats ! from JSBSim_utils import SandBox, CreateFDM, CopyAircraftDef ! class CheckFGBug1503(unittest.TestCase): def setUp(self): ! self.sandbox = SandBox() ! self.script_path = self.sandbox.path_to_jsbsim_file('scripts', 'c1724.xml') # Since we will alter the aircraft definition file, we need make a copy --- 24,43 ---- # is used. # 2. The property 'fcs/left-aileron-pos-rad' remains equal to 0.0 during the ! # execution of the script c1724.xml when <rate_limit> is read from a ! # property. # 3. The actuator output value is correctly driven by rate_limit. ! import os, time, string import xml.etree.ElementTree as et from multiprocessing import Process from scipy import stats ! from JSBSim_utils import JSBSimTestCase, CreateFDM, CopyAircraftDef, RunTest ! class CheckFGBug1503(JSBSimTestCase): def setUp(self): ! JSBSimTestCase.setUp(self) ! self.script_path = self.sandbox.path_to_jsbsim_file('scripts', ! 'c1724.xml') # Since we will alter the aircraft definition file, we need make a copy *************** *** 43,49 **** self.tree, self.aircraft_name, self.path_to_jsbsim_aircrafts = CopyAircraftDef(self.script_path, self.sandbox) - def tearDown(self): - self.sandbox.erase() - def ScriptExecution(self, fdm, time_limit=1E+9): fdm.load_script(self.script_path) --- 45,48 ---- *************** *** 51,56 **** while fdm.run() and fdm.get_sim_time() < time_limit: ! aileron_pos = fdm.get_property_value('fcs/left-aileron-pos-rad') ! self.assertTrue(aileron_pos == 0.0, msg="Failed running the script %s at time step %f\nProperty fcs/left-aileron-pos-rad is non-zero (%f)" % (self.script_path, fdm.get_sim_time(), aileron_pos)) --- 50,55 ---- while fdm.run() and fdm.get_sim_time() < time_limit: ! aileron_pos = fdm['fcs/left-aileron-pos-rad'] ! self.assertEqual(aileron_pos, 0.0, msg="Failed running the script %s at time step %f\nProperty fcs/left-aileron-pos-rad is non-zero (%f)" % (self.script_path, fdm.get_sim_time(), aileron_pos)) *************** *** 60,65 **** t0 = fdm.get_sim_time() while fdm.run() and fdm.get_sim_time() <= t0 + 1.0: ! aileron_course += [(fdm.get_sim_time(), ! fdm.get_property_value(output_prop))] # Thanks to a linear regression on the values, we can check that the --- 59,63 ---- t0 = fdm.get_sim_time() while fdm.run() and fdm.get_sim_time() <= t0 + 1.0: ! aileron_course += [(fdm.get_sim_time(), fdm[output_prop])] # Thanks to a linear regression on the values, we can check that the *************** *** 77,95 **** self.ScriptExecution(fdm, 1.0) ! fdm.set_property_value(input_prop, 1.0) self.CheckRateValue(fdm, output_prop, incr_limit) ! fdm.set_property_value(input_prop, 0.0) self.CheckRateValue(fdm, output_prop, decr_limit) ! # Because JSBSim internals use static pointers, we cannot rely on Python ! # garbage collector to decide when the FDM is destroyed otherwise we can ! # get dangling pointers. del fdm def test_regression_bug_1503(self): ! # First, the execution time of the script c1724.xml is measured. It will ! # be used as a reference to check if JSBSim hangs or not. fdm = CreateFDM(self.sandbox) start_time = time.time() --- 75,93 ---- self.ScriptExecution(fdm, 1.0) ! fdm[input_prop] = 1.0 self.CheckRateValue(fdm, output_prop, incr_limit) ! fdm[input_prop] = 0.0 self.CheckRateValue(fdm, output_prop, decr_limit) ! # Because JSBSim internals use static pointers, we cannot rely on ! # Python garbage collector to decide when the FDM is destroyed ! # otherwise we can get dangling pointers. del fdm def test_regression_bug_1503(self): ! # First, the execution time of the script c1724.xml is measured. It ! # will be used as a reference to check if JSBSim hangs or not. fdm = CreateFDM(self.sandbox) start_time = time.time() *************** *** 132,142 **** # # The test is run again but this time, <rate_limit> will be read from a ! # property instead of being read from a value hard coded in the aircraft ! # definition file. It has been reported in the bug 1503 of FlightGear ! # that for such a configuration the <actuator> output is constantly ! # increasing even if the input is null. For this script the <actuator> ! # output is stored in the property fcs/left-aileron-pos-rad. The ! # function ScriptExecution will monitor that property and if it changes ! # then the test is failed. tree = et.parse(os.path.join(self.path_to_jsbsim_aircrafts, self.aircraft_name+'.xml')) --- 130,140 ---- # # The test is run again but this time, <rate_limit> will be read from a ! # property instead of being read from a value hard coded in the ! # aircraft definition file. It has been reported in the bug 1503 of ! # FlightGear that for such a configuration the <actuator> output is ! # constantly increasing even if the input is null. For this script the ! # <actuator> output is stored in the property ! # fcs/left-aileron-pos-rad. The function ScriptExecution will monitor ! # that property and if it changes then the test is failed. tree = et.parse(os.path.join(self.path_to_jsbsim_aircrafts, self.aircraft_name+'.xml')) *************** *** 167,178 **** # # The test is run again but this time we are checking that rate_limit ! # drives the actuator output value as expected. The idea is to store the ! # output value of the actuator output vs the time and check with a # linear regression that # 1. The actuator output value is evolving linearly # 2. The slope of the actuator output is equal to the rate_limit value # The test is run with the rate_limit given by a value, a property, ! # different values of the ascending and descending rates and a number of ! # combinations thereof. # The aircraft file definition is modified such that the actuator --- 165,176 ---- # # The test is run again but this time we are checking that rate_limit ! # drives the actuator output value as expected. The idea is to store ! # the output value of the actuator output vs the time and check with a # linear regression that # 1. The actuator output value is evolving linearly # 2. The slope of the actuator output is equal to the rate_limit value # The test is run with the rate_limit given by a value, a property, ! # different values of the ascending and descending rates and a number ! # of combinations thereof. # The aircraft file definition is modified such that the actuator *************** *** 215,219 **** rate_element.text = '0.1' ! output_file = self.sandbox('aircraft', self.aircraft_name, self.aircraft_name+'.xml') tree.write(output_file) --- 213,217 ---- rate_element.text = '0.1' ! output_file = os.path.join('aircraft', self.aircraft_name, self.aircraft_name+'.xml') tree.write(output_file) *************** *** 233,237 **** # Checking when the ascending and descending rates are different. ! # First with the 2 rates set by hard coded values (0.1 and 0.2 respectively) rate_element.attrib['sense'] = 'decr' --- 231,236 ---- # Checking when the ascending and descending rates are different. ! # First with the 2 rates set by hard coded values (0.1 and 0.2 ! # respectively) rate_element.attrib['sense'] = 'decr' *************** *** 244,249 **** self.CheckRateLimit(input_prop, output_prop, 0.2, -0.1) ! # Check when the descending rate is set by a property and the ascending rate is ! # set by a value. rate_element.text = 'fcs/rate-limit-value' --- 243,248 ---- self.CheckRateLimit(input_prop, output_prop, 0.2, -0.1) ! # Check when the descending rate is set by a property and the ascending ! # rate is set by a value. rate_element.text = 'fcs/rate-limit-value' *************** *** 268,273 **** self.CheckRateLimit(input_prop, output_prop, 0.15, -0.05) ! suite = unittest.TestLoader().loadTestsFromTestCase(CheckFGBug1503) ! test_result = unittest.TextTestRunner(verbosity=2).run(suite) ! if test_result.failures or test_result.errors: ! sys.exit(-1) # 'make test' will report the test failed. --- 267,269 ---- self.CheckRateLimit(input_prop, output_prop, 0.15, -0.05) ! RunTest(CheckFGBug1503) Index: CheckMomentsUpdate.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckMomentsUpdate.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** CheckMomentsUpdate.py 7 Feb 2015 12:36:23 -0000 1.3 --- CheckMomentsUpdate.py 30 Jan 2016 18:50:24 -0000 1.4 *************** *** 20,54 **** # ! import unittest, sys ! from JSBSim_utils import SandBox, CreateFDM, Table, ExecuteUntil mol2lbs = 0.00013841 * 32.174049 - class CheckMomentsUpdate(unittest.TestCase): - def setUp(self): - self.sandbox = SandBox() - - def tearDown(self): - self.sandbox.erase() def CheckCGPosition(self): ! weight = self.fdm.get_property_value('inertia/weight-lbs') ! empty_weight = self.fdm.get_property_value('inertia/empty-weight-lbs') ! contents = self.fdm.get_property_value('buoyant_forces/gas-cell/contents-mol') radiosonde_weight = weight - empty_weight - contents * mol2lbs ! CGx = self.fdm.get_property_value('inertia/cg-x-in') ! CGy = self.fdm.get_property_value('inertia/cg-y-in') ! CGz = self.fdm.get_property_value('inertia/cg-z-in') ! X = self.fdm.get_property_value('inertia/pointmass-location-X-inches') ! Y = self.fdm.get_property_value('inertia/pointmass-location-Y-inches') ! Z = self.fdm.get_property_value('inertia/pointmass-location-Z-inches') ! ! self.assertAlmostEqual(CGx, X * radiosonde_weight / weight, delta = 1E-7) ! self.assertAlmostEqual(CGy, Y * radiosonde_weight / weight, delta = 1E-7) ! self.assertAlmostEqual(CGz, Z * radiosonde_weight / weight, delta = 1E-7) def test_moments_update(self): ! script_path = self.sandbox.path_to_jsbsim_file('scripts', 'weather-balloon.xml') self.fdm = CreateFDM(self.sandbox) --- 20,49 ---- # ! from JSBSim_utils import JSBSimTestCase, CreateFDM, Table, ExecuteUntil, RunTest mol2lbs = 0.00013841 * 32.174049 + class CheckMomentsUpdate(JSBSimTestCase): def CheckCGPosition(self): ! weight = self.fdm['inertia/weight-lbs'] ! empty_weight = self.fdm['inertia/empty-weight-lbs'] ! contents = self.fdm['buoyant_forces/gas-cell/contents-mol'] radiosonde_weight = weight - empty_weight - contents * mol2lbs ! CGx = self.fdm['inertia/cg-x-in'] ! CGy = self.fdm['inertia/cg-y-in'] ! CGz = self.fdm['inertia/cg-z-in'] ! X = self.fdm['inertia/pointmass-location-X-inches'] ! Y = self.fdm['inertia/pointmass-location-Y-inches'] ! Z = self.fdm['inertia/pointmass-location-Z-inches'] ! ! self.assertAlmostEqual(CGx, X * radiosonde_weight / weight, delta=1E-7) ! self.assertAlmostEqual(CGy, Y * radiosonde_weight / weight, delta=1E-7) ! self.assertAlmostEqual(CGz, Z * radiosonde_weight / weight, delta=1E-7) def test_moments_update(self): ! script_path = self.sandbox.path_to_jsbsim_file('scripts', ! 'weather-balloon.xml') self.fdm = CreateFDM(self.sandbox) *************** *** 59,63 **** self.CheckCGPosition() ! dt = self.fdm.get_property_value('simulation/dt') ExecuteUntil(self.fdm, 1.0-2.0*dt) --- 54,58 ---- self.CheckCGPosition() ! dt = self.fdm['simulation/dt'] ExecuteUntil(self.fdm, 1.0-2.0*dt) *************** *** 65,69 **** # Moves the radio sonde to modify the CG location ! self.fdm.set_property_value('inertia/pointmass-location-X-inches', 5.0) # Check that the moment is immediately updated accordingly --- 60,64 ---- # Moves the radio sonde to modify the CG location ! self.fdm['inertia/pointmass-location-X-inches'] = 5.0 # Check that the moment is immediately updated accordingly *************** *** 71,79 **** self.CheckCGPosition() ! Fbx = self.fdm.get_property_value('forces/fbx-buoyancy-lbs') ! Fbz = self.fdm.get_property_value('forces/fbz-buoyancy-lbs') ! CGx = self.fdm.get_property_value('inertia/cg-x-in') / 12.0 # Converts from in to ft ! CGz = self.fdm.get_property_value('inertia/cg-z-in') / 12.0 ! Mby = self.fdm.get_property_value('moments/m-buoyancy-lbsft') self.assertAlmostEqual(Fbx * CGz - Fbz * CGx, Mby, delta=1E-7, --- 66,74 ---- self.CheckCGPosition() ! Fbx = self.fdm['forces/fbx-buoyancy-lbs'] ! Fbz = self.fdm['forces/fbz-buoyancy-lbs'] ! CGx = self.fdm['inertia/cg-x-in'] / 12.0 # Converts from in to ft ! CGz = self.fdm['inertia/cg-z-in'] / 12.0 ! Mby = self.fdm['moments/m-buoyancy-lbsft'] self.assertAlmostEqual(Fbx * CGz - Fbz * CGx, Mby, delta=1E-7, *************** *** 85,89 **** csv = Table() ! csv.ReadCSV(self.sandbox('output.csv')) Mby = csv.get_column('M_{Buoyant} (ft-lbs)')[-1] Fbx = csv.get_column('F_{Buoyant x} (lbs)')[-1] --- 80,84 ---- csv = Table() ! csv.ReadCSV('output.csv') Mby = csv.get_column('M_{Buoyant} (ft-lbs)')[-1] Fbx = csv.get_column('F_{Buoyant x} (lbs)')[-1] *************** *** 93,98 **** msg="Fbx*CGz-Fbz*CGx = %f and Mby = %f do not match" % (Fbx*CGz-Fbz*CGx, Mby)) ! suite = unittest.TestLoader().loadTestsFromTestCase(CheckMomentsUpdate) ! test_result = unittest.TextTestRunner(verbosity=2).run(suite) ! if test_result.failures or test_result.errors: ! sys.exit(-1) # 'make test' will report the test failed. --- 88,90 ---- msg="Fbx*CGz-Fbz*CGx = %f and Mby = %f do not match" % (Fbx*CGz-Fbz*CGx, Mby)) ! RunTest(CheckMomentsUpdate) Index: CheckOutputRate.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckOutputRate.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** CheckOutputRate.py 22 Aug 2015 18:20:01 -0000 1.4 --- CheckOutputRate.py 30 Jan 2016 18:50:24 -0000 1.5 *************** *** 20,37 **** # ! import sys, unittest, string import xml.etree.ElementTree as et ! from JSBSim_utils import CreateFDM, SandBox, append_xml, Table ! class CheckOutputRate(unittest.TestCase): def setUp(self): ! self.sandbox = SandBox() self.fdm = CreateFDM(self.sandbox) ! self.script_path = self.sandbox.path_to_jsbsim_file('scripts', 'c1722.xml') # Read the time step 'dt' from the script file ! self.tree = et.parse(self.sandbox.elude(self.script_path)) root = self.tree.getroot() use_tag = root.find("./use") --- 20,38 ---- # ! import string import xml.etree.ElementTree as et ! from JSBSim_utils import JSBSimTestCase, CreateFDM, append_xml, Table, RunTest ! class CheckOutputRate(JSBSimTestCase): def setUp(self): ! JSBSimTestCase.setUp(self) self.fdm = CreateFDM(self.sandbox) ! self.script_path = self.sandbox.path_to_jsbsim_file('scripts', ! 'c1722.xml') # Read the time step 'dt' from the script file ! self.tree = et.parse(self.script_path) root = self.tree.getroot() use_tag = root.find("./use") *************** *** 51,57 **** aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft', aircraft_name, append_xml(aircraft_name)) ! tree = et.parse(self.sandbox.elude(aircraft_path)) output_tag = tree.getroot().find("./output") ! self.output_file = self.sandbox(output_tag.attrib['name']) self.rateHz = float(output_tag.attrib['rate']) self.rate = int(1.0 / (self.rateHz * self.dt)) --- 52,58 ---- aircraft_path = self.sandbox.path_to_jsbsim_file('aircraft', aircraft_name, append_xml(aircraft_name)) ! tree = et.parse(aircraft_path) output_tag = tree.getroot().find("./output") ! self.output_file = output_tag.attrib['name'] self.rateHz = float(output_tag.attrib['rate']) self.rate = int(1.0 / (self.rateHz * self.dt)) *************** *** 59,63 **** def tearDown(self): del self.fdm ! self.sandbox.erase() def testOutputRate(self): --- 60,64 ---- def tearDown(self): del self.fdm ! JSBSimTestCase.tearDown(self) def testOutputRate(self): *************** *** 65,74 **** # Check that the output is enabled by default ! self.assertEqual(self.fdm.get_property_value("simulation/output/enabled"), ! 1.0) # Check that the rate is consistent with the values extracted from the # script and the aircraft definition ! self.assertAlmostEqual(self.fdm.get_property_value("simulation/output/log_rate_hz"), self.rateHz, delta=1E-5) --- 66,74 ---- # Check that the output is enabled by default ! self.assertEqual(self.fdm["simulation/output/enabled"], 1.0) # Check that the rate is consistent with the values extracted from the # script and the aircraft definition ! self.assertAlmostEqual(self.fdm["simulation/output/log_rate_hz"], self.rateHz, delta=1E-5) *************** *** 88,92 **** self.assertEqual(output.get_column(0)[2], self.rate * self.dt) self.assertEqual(output.get_column(0)[2], ! self.fdm.get_property_value("simulation/sim-time-sec")) def testDisablingOutput(self): --- 88,92 ---- self.assertEqual(output.get_column(0)[2], self.rate * self.dt) self.assertEqual(output.get_column(0)[2], ! self.fdm["simulation/sim-time-sec"]) def testDisablingOutput(self): *************** *** 94,100 **** # Disables the output during the initialization ! self.fdm.set_property_value("simulation/output/enabled", 0.0) self.fdm.run_ic() ! self.fdm.set_property_value("simulation/output/enabled", 1.0) for i in xrange(self.rate): --- 94,100 ---- # Disables the output during the initialization ! self.fdm["simulation/output/enabled"] = 0.0 self.fdm.run_ic() ! self.fdm["simulation/output/enabled"] = 1.0 for i in xrange(self.rate): *************** *** 108,112 **** # 1. The output after 'rate' iterations self.assertEqual(output.get_column(0)[1], ! self.fdm.get_property_value("simulation/sim-time-sec")) def testTrimRestoresOutputSettings(self): --- 108,112 ---- # 1. The output after 'rate' iterations self.assertEqual(output.get_column(0)[1], ! self.fdm["simulation/sim-time-sec"]) def testTrimRestoresOutputSettings(self): *************** *** 114,131 **** # Disables the output during the initialization ! self.fdm.set_property_value("simulation/output/enabled", 0.0) self.fdm.run_ic() # Check that the output remains disabled even after the trim is # executed ! while self.fdm.get_property_value("simulation/sim-time-sec") < self.trim_date + 2.0*self.dt: self.fdm.run() ! self.assertEqual(self.fdm.get_property_value("simulation/output/enabled"), ! 0.0) # Re-enable the output and check that the output rate is unaffected by # the previous operations ! self.fdm.set_property_value("simulation/output/enabled", 1.0) ! frame = int(self.fdm.get_property_value("simulation/frame")) for i in xrange(self.rate): --- 114,130 ---- # Disables the output during the initialization ! self.fdm["simulation/output/enabled"] = 0.0 self.fdm.run_ic() # Check that the output remains disabled even after the trim is # executed ! while self.fdm["simulation/sim-time-sec"] < self.trim_date + 2.0*self.dt: self.fdm.run() ! self.assertEqual(self.fdm["simulation/output/enabled"], 0.0) # Re-enable the output and check that the output rate is unaffected by # the previous operations ! self.fdm["simulation/output/enabled"] = 1.0 ! frame = int(self.fdm["simulation/frame"]) for i in xrange(self.rate): *************** *** 144,157 **** property.text = 'simulation/output/enabled' property.attrib['value'] = "0.0" ! self.tree.write(self.sandbox('c1722_0.xml')) self.fdm.load_script('c1722_0.xml') # Check that the output is disabled ! self.assertEqual(self.fdm.get_property_value("simulation/output/enabled"), ! 0.0) self.fdm.run_ic() ! self.fdm.set_property_value("simulation/output/enabled", 1.0) for i in xrange(self.rate): --- 143,155 ---- property.text = 'simulation/output/enabled' property.attrib['value'] = "0.0" ! self.tree.write('c1722_0.xml') self.fdm.load_script('c1722_0.xml') # Check that the output is disabled ! self.assertEqual(self.fdm["simulation/output/enabled"], 0.0) self.fdm.run_ic() ! self.fdm["simulation/output/enabled"] = 1.0 for i in xrange(self.rate): *************** *** 165,172 **** # 1. The output after 'rate' iterations self.assertEqual(output.get_column(0)[1], ! self.fdm.get_property_value("simulation/sim-time-sec")) ! suite = unittest.TestLoader().loadTestsFromTestCase(CheckOutputRate) ! test_result = unittest.TextTestRunner(verbosity=2).run(suite) ! if test_result.failures or test_result.errors: ! sys.exit(-1) # 'make test' will report the test failed. --- 163,167 ---- # 1. The output after 'rate' iterations self.assertEqual(output.get_column(0)[1], ! self.fdm["simulation/sim-time-sec"]) ! RunTest(CheckOutputRate) Index: CheckSimTimeReset.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckSimTimeReset.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** CheckSimTimeReset.py 13 Dec 2015 09:29:22 -0000 1.3 --- CheckSimTimeReset.py 30 Jan 2016 18:50:24 -0000 1.4 *************** *** 20,35 **** # ! import sys, unittest, os import xml.etree.ElementTree as et ! from JSBSim_utils import CreateFDM, SandBox, ExecuteUntil ! class TestSimTimeReset(unittest.TestCase): ! def setUp(self): ! self.sandbox = SandBox() ! ! def tearDown(self): ! self.sandbox.erase() ! def test_no_script(self): fdm = CreateFDM(self.sandbox) --- 20,29 ---- # ! import os import xml.etree.ElementTree as et ! from JSBSim_utils import JSBSimTestCase, CreateFDM, ExecuteUntil, RunTest ! class TestSimTimeReset(JSBSimTestCase): def test_no_script(self): fdm = CreateFDM(self.sandbox) *************** *** 38,54 **** fdm.load_model('c172x') ! aircraft_path = os.path.join(self.sandbox.elude(aircraft_path), 'c172x') fdm.load_ic(os.path.join(aircraft_path, 'reset01.xml'), False) fdm.run_ic() ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), 0.0) ExecuteUntil(fdm, 5.0) ! t = fdm.get_property_value('simulation/sim-time-sec') ! fdm.set_property_value('simulation/do_simple_trim', 1) ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), t) fdm.reset_to_initial_conditions(1) ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), 0.0) del fdm --- 32,48 ---- fdm.load_model('c172x') ! aircraft_path = os.path.join(aircraft_path, 'c172x') fdm.load_ic(os.path.join(aircraft_path, 'reset01.xml'), False) fdm.run_ic() ! self.assertEqual(fdm['simulation/sim-time-sec'], 0.0) ExecuteUntil(fdm, 5.0) ! t = fdm['simulation/sim-time-sec'] ! fdm['simulation/do_simple_trim'] = 1 ! self.assertEqual(fdm['simulation/sim-time-sec'], t) fdm.reset_to_initial_conditions(1) ! self.assertEqual(fdm['simulation/sim-time-sec'], 0.0) del fdm *************** *** 61,69 **** fdm.run_ic() ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), 0.0) ExecuteUntil(fdm, 5.0) fdm.reset_to_initial_conditions(1) ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), 0.0) del fdm --- 55,63 ---- fdm.run_ic() ! self.assertEqual(fdm['simulation/sim-time-sec'], 0.0) ExecuteUntil(fdm, 5.0) fdm.reset_to_initial_conditions(1) ! self.assertEqual(fdm['simulation/sim-time-sec'], 0.0) del fdm *************** *** 72,79 **** script_name = 'ball_orbit.xml' script_path = self.sandbox.path_to_jsbsim_file('scripts', script_name) ! tree = et.parse(self.sandbox.elude(script_path)) run_tag = tree.getroot().find('./run') run_tag.attrib['start'] = '1.2' ! tree.write(self.sandbox(script_name)) fdm = CreateFDM(self.sandbox) --- 66,73 ---- script_name = 'ball_orbit.xml' script_path = self.sandbox.path_to_jsbsim_file('scripts', script_name) ! tree = et.parse(script_path) run_tag = tree.getroot().find('./run') run_tag.attrib['start'] = '1.2' ! tree.write(script_name) fdm = CreateFDM(self.sandbox) *************** *** 81,89 **** fdm.run_ic() ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), 1.2) ExecuteUntil(fdm, 5.0) fdm.reset_to_initial_conditions(1) ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), 1.2) del fdm --- 75,83 ---- fdm.run_ic() ! self.assertEqual(fdm['simulation/sim-time-sec'], 1.2) ExecuteUntil(fdm, 5.0) fdm.reset_to_initial_conditions(1) ! self.assertEqual(fdm['simulation/sim-time-sec'], 1.2) del fdm *************** *** 92,100 **** script_name = 'ball_orbit.xml' script_path = self.sandbox.path_to_jsbsim_file('scripts', script_name) ! tree = et.parse(self.sandbox.elude(script_path)) run_tag = tree.getroot().find('./run') # Remove the parameter 'start' from the tag <run> del run_tag.attrib['start'] ! tree.write(self.sandbox(script_name)) fdm = CreateFDM(self.sandbox) --- 86,94 ---- script_name = 'ball_orbit.xml' script_path = self.sandbox.path_to_jsbsim_file('scripts', script_name) ! tree = et.parse(script_path) run_tag = tree.getroot().find('./run') # Remove the parameter 'start' from the tag <run> del run_tag.attrib['start'] ! tree.write(script_name) fdm = CreateFDM(self.s |
From: Bertrand <bco...@us...> - 2016-01-30 14:34:48
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv26442/tests Modified Files: CheckScripts.py JSBSim_utils.py TestInitialConditions.py Log Message: Factored the script list generator between CheckScripts.py and TestInitialConditions.py Index: CheckScripts.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/CheckScripts.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** CheckScripts.py 12 Jul 2015 15:38:09 -0000 1.4 --- CheckScripts.py 30 Jan 2016 14:34:44 -0000 1.5 *************** *** 20,55 **** # ! import os, unittest, sys ! from JSBSim_utils import SandBox, CreateFDM, CheckXMLFile ! class CheckScripts(unittest.TestCase): ! def setUp(self): ! self.sandbox = SandBox() ! self.scripts = 0 ! ! def tearDown(self): ! print "Tested %g scripts" % (self.scripts,) ! self.sandbox.erase() ! def testScripts(self): ! script_path = self.sandbox.path_to_jsbsim_file('scripts') ! for f in os.listdir(self.sandbox.elude(script_path)): ! fullpath = os.path.join(self.sandbox.elude(script_path), f) ! ! # Does f contains a JSBSim script ? ! if not CheckXMLFile(fullpath, 'runscript'): ! continue ! fdm = CreateFDM(self.sandbox) ! self.assertTrue(fdm.load_script(os.path.join(script_path, f)), ! msg="Failed to load script %s" % (fullpath,)) fdm.run_ic() - self.scripts += 1 del fdm ! suite = unittest.TestLoader().loadTestsFromTestCase(CheckScripts) ! test_result = unittest.TextTestRunner(verbosity=2).run(suite) ! if test_result.failures or test_result.errors: ! sys.exit(-1) # 'make test' will report the test failed. --- 20,35 ---- # ! from JSBSim_utils import JSBSimTestCase, CreateFDM, RunTest ! class CheckScripts(JSBSimTestCase): def testScripts(self): ! for s in self.script_list(): fdm = CreateFDM(self.sandbox) ! self.assertTrue(fdm.load_script(s), ! msg="Failed to load script %s" % (s,)) fdm.run_ic() del fdm ! RunTest(CheckScripts) Index: JSBSim_utils.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/JSBSim_utils.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** JSBSim_utils.py 10 Jan 2016 15:20:23 -0000 1.7 --- JSBSim_utils.py 30 Jan 2016 14:34:44 -0000 1.8 *************** *** 18,22 **** # this program; if not, see <http://www.gnu.org/licenses/> ! import os, sys, csv, string, tempfile, shutil import xml.etree.ElementTree as et import jsbsim --- 18,22 ---- # this program; if not, see <http://www.gnu.org/licenses/> ! import os, sys, csv, string, tempfile, shutil, unittest import xml.etree.ElementTree as et import jsbsim *************** *** 232,233 **** --- 232,261 ---- return tree, aircraft_name, path_to_jsbsim_aircrafts + + + class JSBSimTestCase(unittest.TestCase): + def setUp(self): + self.sandbox = SandBox() + + def tearDown(self): + self.sandbox.erase() + + # Generator that returns the full path to all the scripts in JSBSim + def script_list(self, blacklist=[]): + script_path = self.sandbox.path_to_jsbsim_file('scripts') + for f in os.listdir(self.sandbox.elude(script_path)): + if f in blacklist: + continue + + fullpath = os.path.join(script_path, f) + + # Does f contains a JSBSim script ? + if CheckXMLFile(self.sandbox.elude(fullpath), 'runscript'): + yield fullpath + + + def RunTest(test): + suite = unittest.TestLoader().loadTestsFromTestCase(test) + test_result = unittest.TextTestRunner(verbosity=2).run(suite) + if test_result.failures or test_result.errors: + sys.exit(-1) # 'make test' will report the test failed. Index: TestInitialConditions.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestInitialConditions.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** TestInitialConditions.py 24 Jan 2016 18:59:11 -0000 1.8 --- TestInitialConditions.py 30 Jan 2016 14:34:44 -0000 1.9 *************** *** 21,28 **** # ! import unittest, sys, os import xml.etree.ElementTree as et import pandas as pd ! from JSBSim_utils import CreateFDM, SandBox, append_xml, ExecuteUntil, CheckXMLFile # Values copied from FGJSBBase.cpp and FGXMLElement.cpp --- 21,28 ---- # ! import os import xml.etree.ElementTree as et import pandas as pd ! from JSBSim_utils import CreateFDM, append_xml, ExecuteUntil, JSBSimTestCase, RunTest # Values copied from FGJSBBase.cpp and FGXMLElement.cpp *************** *** 33,56 **** ! class TestInitialConditions(unittest.TestCase): ! def setUp(self): ! self.sandbox = SandBox() ! ! def tearDown(self): ! self.sandbox.erase() ! ! # Generator that returns the full path to all the scripts in JSBSim ! def script_list(self, blacklist=[]): ! script_path = self.sandbox.path_to_jsbsim_file('scripts') ! for f in os.listdir(self.sandbox.elude(script_path)): ! if f in blacklist: ! continue ! ! fullpath = os.path.join(self.sandbox.elude(script_path), f) ! ! # Does f contains a JSBSim script ? ! if CheckXMLFile(fullpath, 'runscript'): ! yield fullpath ! def getElementTrees(self, s): # Read the IC file name from the script --- 33,37 ---- ! class TestInitialConditions(JSBSimTestCase): def getElementTrees(self, s): # Read the IC file name from the script *************** *** 60,64 **** aircraft_name = use_tag.attrib['aircraft'] aircraft_path = os.path.join('aircraft', aircraft_name) ! path_to_jsbsim_aircrafts = self.sandbox.elude(self.sandbox.path_to_jsbsim_file(aircraft_path)) IC_file = append_xml(use_tag.attrib['initialize']) --- 41,45 ---- aircraft_name = use_tag.attrib['aircraft'] aircraft_path = os.path.join('aircraft', aircraft_name) ! path_to_jsbsim_aircrafts = os.path.relpath(self.sandbox.path_to_jsbsim_file(aircraft_path), '..') IC_file = append_xml(use_tag.attrib['initialize']) *************** *** 127,131 **** for s in self.script_list(('ZLT-NT-moored-1.xml', '737_cruise_steady_turn_simplex.xml')): ! (tree, IC_tree) = self.getElementTrees(s) IC_root = IC_tree.getroot() --- 108,113 ---- for s in self.script_list(('ZLT-NT-moored-1.xml', '737_cruise_steady_turn_simplex.xml')): ! script_path = os.path.relpath(s, '..') ! (tree, IC_tree) = self.getElementTrees(script_path) IC_root = IC_tree.getroot() *************** *** 134,138 **** continue ! self.CheckICValues(vars, tree, IC_root, s, prop_output_to_CSV) def CheckICValues(self, vars, tree, IC_root, script_path, --- 116,121 ---- continue ! self.CheckICValues(vars, tree, IC_root, script_path, ! prop_output_to_CSV) def CheckICValues(self, vars, tree, IC_root, script_path, *************** *** 249,253 **** for s in self.script_list(('ZLT-NT-moored-1.xml', '737_cruise_steady_turn_simplex.xml')): ! (tree, IC_tree) = self.getElementTrees(s) IC_root = IC_tree.getroot() --- 232,237 ---- for s in self.script_list(('ZLT-NT-moored-1.xml', '737_cruise_steady_turn_simplex.xml')): ! script_path = os.path.relpath(s, '..') ! (tree, IC_tree) = self.getElementTrees(script_path) IC_root = IC_tree.getroot() *************** *** 262,269 **** continue ! self.CheckICValues(vars, tree, position_tag, s, prop_output_to_CSV) ! suite = unittest.TestLoader().loadTestsFromTestCase(TestInitialConditions) ! test_result = unittest.TextTestRunner(verbosity=2).run(suite) ! if test_result.failures or test_result.errors: ! sys.exit(-1) # 'make test' will report the test failed. --- 246,251 ---- continue ! self.CheckICValues(vars, tree, position_tag, script_path, ! prop_output_to_CSV) ! RunTest(TestInitialConditions) |
From: Bertrand <bco...@us...> - 2016-01-24 18:59:14
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7183/tests Modified Files: TestInitialConditions.py Log Message: Added a regression test for the bug reported and fixed by Jon : geodetic coordinates initialized the body a few miles away from the requested position. Index: TestInitialConditions.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestInitialConditions.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** TestInitialConditions.py 10 Jan 2016 11:46:23 -0000 1.7 --- TestInitialConditions.py 24 Jan 2016 18:59:11 -0000 1.8 *************** *** 1,3 **** ! # TestICOutput.py # # A regression test that checks that IC are correctly read from the IC file --- 1,3 ---- ! # TestInitialConditions.py # # A regression test that checks that IC are correctly read from the IC file *************** *** 40,44 **** self.sandbox.erase() ! def test_initial_conditions(self): prop_output_to_CSV = ['velocities/vc-kts'] # A dictionary that contains the XML tags to extract from the IC file --- 40,71 ---- self.sandbox.erase() ! # Generator that returns the full path to all the scripts in JSBSim ! def script_list(self, blacklist=[]): ! script_path = self.sandbox.path_to_jsbsim_file('scripts') ! for f in os.listdir(self.sandbox.elude(script_path)): ! if f in blacklist: ! continue ! ! fullpath = os.path.join(self.sandbox.elude(script_path), f) ! ! # Does f contains a JSBSim script ? ! if CheckXMLFile(fullpath, 'runscript'): ! yield fullpath ! ! def getElementTrees(self, s): ! # Read the IC file name from the script ! tree = et.parse(s) ! use_tag = tree.getroot().find('use') ! ! aircraft_name = use_tag.attrib['aircraft'] ! aircraft_path = os.path.join('aircraft', aircraft_name) ! path_to_jsbsim_aircrafts = self.sandbox.elude(self.sandbox.path_to_jsbsim_file(aircraft_path)) ! ! IC_file = append_xml(use_tag.attrib['initialize']) ! IC_tree = et.parse(os.path.join(path_to_jsbsim_aircrafts, IC_file)) ! ! return (tree, IC_tree) ! ! def test_initial_conditions_v1(self): prop_output_to_CSV = ['velocities/vc-kts'] # A dictionary that contains the XML tags to extract from the IC file *************** *** 98,224 **** 'CSV_header': 'Terrain Elevation (ft)'}] ! script_path = self.sandbox.path_to_jsbsim_file('scripts') ! for f in os.listdir(self.sandbox.elude(script_path)): ! # TODO These scripts need some further investigation ! if f in ('ZLT-NT-moored-1.xml', ! '737_cruise_steady_turn_simplex.xml'): continue - fullpath = os.path.join(self.sandbox.elude(script_path), f) ! # Does f contains a JSBSim script ? ! if not CheckXMLFile(fullpath, 'runscript'): continue ! # Read the IC file name from the script ! tree = et.parse(fullpath) ! root = tree.getroot() ! use_tag = root.find('use') ! aircraft_name = use_tag.attrib['aircraft'] ! aircraft_path = os.path.join('aircraft', aircraft_name) ! path_to_jsbsim_aircrafts = self.sandbox.elude(self.sandbox.path_to_jsbsim_file(aircraft_path)) ! IC_file = append_xml(use_tag.attrib['initialize']) ! IC_tree = et.parse(os.path.join(path_to_jsbsim_aircrafts, IC_file)) IC_root = IC_tree.getroot() ! # Only testing version 1.0 of init files ! if 'version' in IC_root.attrib: ! if float(IC_root.attrib['version']) == 2.0: ! continue ! ! # Extract the IC values from XML ! for var in vars: ! var_tag = IC_root.find('./'+var['tag']) ! var['specified'] = var_tag is not None ! if not var['specified']: ! var['value'] = 0.0 ! continue ! ! var['value'] = float(var_tag.text) ! if 'unit' in var_tag.attrib: ! conv = var['unit'][var_tag.attrib['unit']] ! else: ! conv = var['unit'][var['default_unit']] ! var['value'] *= conv ! ! # Generate a CSV file to check that it is correctly initialized ! # with the initial values ! output_tag = et.SubElement(root, 'output') ! output_tag.attrib['name'] = 'check_csv_values.csv' ! output_tag.attrib['type'] = 'CSV' ! output_tag.attrib['rate'] = '10' ! position_tag = et.SubElement(output_tag, 'position') ! position_tag.text = 'ON' ! velocities_tag = et.SubElement(output_tag, 'velocities') ! velocities_tag.text = 'ON' ! for props in prop_output_to_CSV: ! property_tag = et.SubElement(output_tag, 'property') ! property_tag.text = props ! tree.write(self.sandbox(f)) ! ! # Initialize the script ! fdm = CreateFDM(self.sandbox) ! fdm.load_script(f) ! fdm.run_ic() ! ! # Sanity check, we just initialized JSBSim with the ICs, the time ! # must be set to 0.0 ! self.assertEqual(fdm.get_property_value('simulation/sim-time-sec'), ! 0.0) ! ! # Check that the properties (including in 'ic/') have been ! # correctly initialized (i.e. that they contain the value read from ! # the XML file). ! for var in vars: ! if not var['specified']: ! continue ! ! value = var['value'] ! prop = fdm.get_property_value(var['ic_prop']) ! if var['tag'] == 'psi': ! if abs(prop - 360.0) <= 1E-8: ! prop = 0.0 ! self.assertAlmostEqual(value, prop, delta=1E-7, ! msg="In script %s: %s should be %f but found %f" % (f, var['tag'], value, prop)) ! prop = fdm.get_property_value(var['prop']) ! if var['tag'] == 'psi': ! if abs(prop - 360.0) <= 1E-8: ! prop = 0.0 ! self.assertAlmostEqual(value, prop, delta=1E-7, ! msg="In script %s: %s should be %f but found %f" % (f, var['tag'], value, prop)) ! ! # Execute the first second of the script. This is to make sure that ! # the CSV file is open and the ICs have been written in it. ! try: ! ExecuteUntil(fdm, 1.0) ! except RuntimeError as e: ! if e.args[0] == 'Trim Failed': ! self.fail("Trim failed in script %s" % (f,)) ! else: ! raise ! ! # Copies the CSV file content in a table ! ref = pd.read_csv(self.sandbox('check_csv_values.csv')) ! ! # Sanity check: make sure that the time step 0.0 has been copied in ! # the CSV file. ! self.assertEqual(ref['Time'][0], 0.0) ! ! # Check that the value in the CSV file equals the value read from ! # the IC file. ! for var in vars: ! if not var['specified']: ! continue ! ! value = var['value'] ! csv_value = ref[var['CSV_header']][0] ! if var['tag'] == 'psi': ! if abs(csv_value - 360.0) <= 1E-8: ! csv_value = 0.0 ! self.assertAlmostEqual(value, csv_value, delta=1E-7, ! msg="In script %s: %s should be %f but found %f" % (f, var['tag'], value, csv_value)) ! del fdm suite = unittest.TestLoader().loadTestsFromTestCase(TestInitialConditions) --- 125,266 ---- 'CSV_header': 'Terrain Elevation (ft)'}] ! for s in self.script_list(('ZLT-NT-moored-1.xml', ! '737_cruise_steady_turn_simplex.xml')): ! (tree, IC_tree) = self.getElementTrees(s) ! IC_root = IC_tree.getroot() ! ! # Only testing version 1.0 of init files ! if 'version' in IC_root.attrib and float(IC_root.attrib['version']) != 1.0: continue ! self.CheckICValues(vars, tree, IC_root, s, prop_output_to_CSV) ! ! def CheckICValues(self, vars, tree, IC_root, script_path, ! prop_output_to_CSV=[]): ! # Extract the IC values from XML ! for var in vars: ! var_tag = IC_root.find(var['tag']) ! var['specified'] = var_tag is not None ! if not var['specified']: ! var['value'] = 0.0 ! continue ! ! var['value'] = float(var_tag.text) ! if 'unit' in var_tag.attrib: ! conv = var['unit'][var_tag.attrib['unit']] ! else: ! conv = var['unit'][var['default_unit']] ! var['value'] *= conv ! ! # Generate a CSV file to check that it is correctly initialized ! # with the initial values ! output_tag = et.SubElement(tree.getroot(), 'output') ! output_tag.attrib['name'] = 'check_csv_values.csv' ! output_tag.attrib['type'] = 'CSV' ! output_tag.attrib['rate'] = '10' ! position_tag = et.SubElement(output_tag, 'position') ! position_tag.text = 'ON' ! velocities_tag = et.SubElement(output_tag, 'velocities') ! velocities_tag.text = 'ON' ! for props in prop_output_to_CSV: ! property_tag = et.SubElement(output_tag, 'property') ! property_tag.text = props ! f = os.path.split(script_path)[-1] # Script name ! tree.write(self.sandbox(f)) ! ! # Initialize the script ! fdm = CreateFDM(self.sandbox) ! fdm.load_script(f) ! fdm.run_ic() ! ! # Sanity check, we just initialized JSBSim with the ICs, the time must ! # be set to 0.0 ! self.assertEqual(fdm['simulation/sim-time-sec'], 0.0) ! ! # Check that the properties (including in 'ic/') have been correctly ! # initialized (i.e. that they contain the value read from the XML ! # file). ! for var in vars: ! if not var['specified']: continue ! value = var['value'] ! prop = fdm[var['ic_prop']] ! if var['tag'] == 'psi': ! if abs(prop - 360.0) <= 1E-8: ! prop = 0.0 ! self.assertAlmostEqual(value, prop, delta=1E-7, ! msg="In script %s: %s should be %f but found %f" % (f, var['tag'], value, prop)) ! prop = fdm[var['prop']] ! if var['tag'] == 'psi': ! if abs(prop - 360.0) <= 1E-8: ! prop = 0.0 ! self.assertAlmostEqual(value, prop, delta=1E-7, ! msg="In script %s: %s should be %f but found %f" % (f, var['tag'], value, prop)) ! ! # Execute the first second of the script. This is to make sure that the ! # CSV file is open and the ICs have been written in it. ! try: ! ExecuteUntil(fdm, 1.0) ! except RuntimeError as e: ! if e.args[0] == 'Trim Failed': ! self.fail("Trim failed in script %s" % (f,)) ! else: ! raise ! ! # Copies the CSV file content in a table ! ref = pd.read_csv(self.sandbox('check_csv_values.csv')) ! ! # Sanity check: make sure that the time step 0.0 has been copied in the ! # CSV file. ! self.assertEqual(ref['Time'][0], 0.0) ! ! # Check that the value in the CSV file equals the value read from the ! # IC file. ! for var in vars: ! if not var['specified']: ! continue ! value = var['value'] ! csv_value = ref[var['CSV_header']][0] ! if var['tag'] == 'psi': ! if abs(csv_value - 360.0) <= 1E-8: ! csv_value = 0.0 ! self.assertAlmostEqual(value, csv_value, delta=1E-7, ! msg="In script %s: %s should be %f but found %f" % (f, var['tag'], value, csv_value)) ! ! del fdm ! ! def test_geod_position_from_init_file_v2(self): ! prop_output_to_CSV = ['position/geod-alt-ft'] ! vars = [{'tag': 'latitude', 'unit': convtodeg, 'default_unit': 'RAD', ! 'ic_prop': 'ic/lat-geod-deg', 'prop': 'position/lat-geod-deg', ! 'CSV_header': 'Latitude Geodetic (deg)'}, ! {'tag': 'longitude', 'unit': convtodeg, 'default_unit': 'RAD', ! 'ic_prop': 'ic/long-gc-deg', 'prop': 'position/long-gc-deg', ! 'CSV_header': 'Longitude (deg)'}, ! {'tag': 'altitudeAGL', 'unit': convtoft, 'default_unit': 'FT', ! 'ic_prop': 'ic/geod-alt-ft', 'prop': 'position/geod-alt-ft', ! 'CSV_header': '/fdm/jsbsim/position/geod-alt-ft'}, ! {'tag': 'altitudeMSL', 'unit': convtoft, 'default_unit': 'FT', ! 'ic_prop': 'ic/h-sl-ft', 'prop': 'position/h-sl-ft', ! 'CSV_header': 'Altitude ASL (ft)'}] ! for s in self.script_list(('ZLT-NT-moored-1.xml', ! '737_cruise_steady_turn_simplex.xml')): ! (tree, IC_tree) = self.getElementTrees(s) IC_root = IC_tree.getroot() ! # Only testing version 2.0 of init files ! if ('version' not in IC_root.attrib ! or float(IC_root.attrib['version']) != 2.0): ! continue ! ! position_tag = IC_root.find('position') ! lat_tag = position_tag.find('latitude') ! if lat_tag is None or 'type' not in lat_tag.attrib or lat_tag.attrib['type'][:4] != "geod": ! continue ! self.CheckICValues(vars, tree, position_tag, s, prop_output_to_CSV) suite = unittest.TestLoader().loadTestsFromTestCase(TestInitialConditions) |
From: Bertrand <bco...@us...> - 2016-01-24 18:49:32
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv6585/tests Modified Files: jsbsim.pyx Log Message: Make some sanity checks before calling 'del' on the pointer. Also the Python class FGPropagate is not supposed to own the object so it should not release it. This is not very consistent with the other classes but until someone comes with a better design, we will live with it. Index: jsbsim.pyx =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/jsbsim.pyx,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -r1.9 -r1.10 *** jsbsim.pyx 24 Jan 2016 17:13:29 -0000 1.9 --- jsbsim.pyx 24 Jan 2016 18:49:28 -0000 1.10 *************** *** 26,30 **** def __dealloc__(self): ! del self.thisptr def __call__(self, row, col): --- 26,31 ---- def __dealloc__(self): ! if self.thisptr != NULL: ! del self.thisptr def __call__(self, row, col): *************** *** 39,43 **** def __dealloc__(self): ! del self.thisptr def __call__(self, idx): --- 40,45 ---- def __dealloc__(self): ! if self.thisptr != NULL: ! del self.thisptr def __call__(self, idx): *************** *** 61,67 **** self.thisptr = NULL - def __dealloc__(self): - del self.thisptr - def get_Tl2b(self): Tl2b = FGMatrix33() --- 63,66 ---- |
From: Bertrand <bco...@us...> - 2016-01-24 18:18:41
|
Update of /cvsroot/jsbsim/JSBSim/src/initialization In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv4793/src/initialization Modified Files: FGInitialCondition.cpp Log Message: Added new properties to get the values read from the IC file. Index: FGInitialCondition.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/initialization/FGInitialCondition.cpp,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -r1.106 -r1.107 *** FGInitialCondition.cpp 22 Jan 2016 03:28:12 -0000 1.106 --- FGInitialCondition.cpp 24 Jan 2016 18:18:38 -0000 1.107 *************** *** 1440,1443 **** --- 1440,1449 ---- &FGInitialCondition::SetRRadpsIC, true); + PropertyManager->Tie("ic/lat-geod-rad", &position, + &FGLocation::GetGeodLatitudeRad); + PropertyManager->Tie("ic/lat-geod-deg", &position, + &FGLocation::GetGeodLatitudeDeg); + PropertyManager->Tie("ic/geod-alt-ft", &position, + &FGLocation::GetGeodAltitude); } |