Sungwoo Kim
/
HydraulicControlBoard_Rainbow_v1_2_copy1
2011
main.cpp
- Committer:
- Lightvalve
- Date:
- 2020-04-03
- Revision:
- 64:6f1caa0993d0
- Parent:
- 63:3c6869477483
- Child:
- 65:a2d7c63419c2
File content as of revision 64:6f1caa0993d0:
#include "mbed.h" #include "FastPWM.h" #include "INIT_HW.h" #include "function_CAN.h" #include "SPI_EEP_ENC.h" #include "I2C_AS5510.h" #include "setting.h" #include "function_utilities.h" #include "stm32f4xx_flash.h" #include "FlashWriter.h" #include "Eigen/Dense.h" #include "ST_F401_84MHZ.h" using namespace std; using namespace Eigen; Timer t; ///191008//// // dac & check /////////////////////////////////////////// DigitalOut check(PC_2); DigitalOut check_2(PC_3); AnalogOut dac_1(PA_4); AnalogOut dac_2(PA_5); AnalogIn adc1(PC_4); //pressure_1 AnalogIn adc2(PB_0); //pressure_2 AnalogIn adc3(PC_1); //current // PWM /////////////////////////////////////////// float dtc_v=0.0f; float dtc_w=0.0f; // I2C /////////////////////////////////////////// I2C i2c(PC_9,PA_8); // SDA, SCL (for K22F) const int i2c_slave_addr1 = 0x56; unsigned int value; // 10bit output of reading sensor AS5510 // SPI /////////////////////////////////////////// //SPI eeprom(PB_15, PB_14, PB_13); // EEPROM //(SPI_MOSI, SPI_MISO, SPI_SCK); //DigitalOut eeprom_cs(PB_12); //FlashWriter writer(6);//2부터 7까지 되는듯 아마 sector SPI enc(PC_12,PC_11,PC_10); DigitalOut enc_cs(PD_2); DigitalOut LED(PA_15); // UART /////////////////////////////////////////// Serial pc(PA_9,PA_10); // _ UART // CAN /////////////////////////////////////////// CAN can(PB_8, PB_9, 1000000); CANMessage msg; void onMsgReceived() { CAN_RX_HANDLER(); } // Variables /////////////////////////////////////////// State pos; State vel; State Vout; State torq; State pres_A; State pres_B; State cur; State valve_pos; State INIT_Vout; State INIT_Valve_Pos; State INIT_Pos; State INIT_torq; extern int CID_RX_CMD; extern int CID_RX_REF_POSITION; extern int CID_RX_REF_VALVE_POS; extern int CID_RX_REF_PWM; extern int CID_TX_INFO; extern int CID_TX_POSITION; extern int CID_TX_TORQUE; extern int CID_TX_PRES; extern int CID_TX_VOUT; extern int CID_TX_VALVE_POSITION; MatrixXd Input = MatrixXd::Zero(1,22); //input MatrixXd h1 = MatrixXd::Zero(22,32); MatrixXd h2 = MatrixXd::Zero(32,32); MatrixXd h3 = MatrixXd::Zero(32,32); MatrixXd hout = MatrixXd::Zero(32,1); MatrixXd b1 = MatrixXd::Zero(32,1); MatrixXd b2 = MatrixXd::Zero(32,1); MatrixXd b3 = MatrixXd::Zero(32,1); MatrixXd bout = MatrixXd::Zero(1,1); MatrixXd X; ArrayXf Y; float NNoutput; float input_array[6] ={0.0f}; float position_array[10] = {0.0f}; // ============================================================================= // ============================================================================= // ============================================================================= /******************************************************************************* * REFERENCE MODE ******************************************************************************/ enum _REFERENCE_MODE { MODE_REF_NO_ACT = 0, //0 MODE_REF_DIRECT, //1 MODE_REF_COS_INC, //2 MODE_REF_LINE_INC, //3 MODE_REF_SIN_WAVE, //4 MODE_REF_SQUARE_WAVE, //5 }; /******************************************************************************* * CONTROL MODE ******************************************************************************/ enum _CONTROL_MODE { //control mode MODE_NO_ACT = 0, //0 MODE_VALVE_POSITION_CONTROL, //1 MODE_JOINT_CONTROL, //2 MODE_VALVE_OPEN_LOOP, //3 MODE_JOINT_POSITION_TORQUE_CONTROL_VALVE_POSITION, //4 MODE_VALVE_POSITION_TORQUE_CONTROL_LEARNING, //5 MODE_JOINT_POSITION_PRES_CONTROL_PWM, //6 MODE_JOINT_POSITION_PRES_CONTROL_VALVE_POSITION, //7 MODE_VALVE_POSITION_PRES_CONTROL_LEARNING, //8 MODE_TEST_CURRENT_CONTROL, //9 MODE_TEST_PWM_CONTROL, //10 MODE_CURRENT_CONTROL, //11 MODE_JOINT_POSITION_TORQUE_CONTROL_CURRENT, //12 MODE_JOINT_POSITION_PRES_CONTROL_CURRENT, //13 //utility MODE_TORQUE_SENSOR_NULLING = 20, //20 MODE_VALVE_NULLING_AND_DEADZONE_SETTING, //21 MODE_FIND_HOME, //22 MODE_VALVE_GAIN_SETTING, //23 MODE_PRESSURE_SENSOR_NULLING, //24 MODE_PRESSURE_SENSOR_CALIB, //25 MODE_ROTARY_FRICTION_TUNING, //26 MODE_DDV_POS_VS_PWM_ID = 30, //30 MODE_DDV_DEADZONE_AND_CENTER, //31 MODE_DDV_POS_VS_FLOWRATE, //32 MODE_SYSTEM_ID, //33 }; int main() { F401_init84 myinit(1); /********************************* *** Initialization *********************************/ LED = 1; pc.baud(9600); // i2c init i2c.frequency(400 * 1000); // 0.4 mHz wait_ms(2); // Power Up wait look_for_hardware_i2c(); // Hardware present init_as5510(i2c_slave_addr1); make_delay(); // // spi init //eeprom.format(8,3); //eeprom.frequency(5000000); //5M enc.format(8,0); enc.frequency(5000000); //5M make_delay(); //rom ROM_CALL_DATA(); make_delay(); // ADC init Init_ADC(); make_delay(); // Pwm init Init_PWM(); TIM4->CR1 ^= TIM_CR1_UDIS; make_delay(); // TMR3 init Init_TMR3(); TIM3->CR1 ^= TIM_CR1_UDIS; make_delay(); // TMR2 init // Init_TMR2(); // TIM2->CR1 ^= TIM_CR1_UDIS; // make_delay(); // CAN can.attach(&CAN_RX_HANDLER); CAN_ID_INIT(); make_delay(); //Timer priority NVIC_SetPriority(TIM3_IRQn, 2); //NVIC_SetPriority(TIM2_IRQn, 3); NVIC_SetPriority(TIM4_IRQn, 3); //can.reset(); can.filter(msg.id, 0xFFFFF000, CANStandard); // spi _ enc spi_enc_set_init(); make_delay(); //DAC init if (SENSING_MODE == 0) { dac_1 = TORQUE_VREF / 3.3f; dac_2 = 0.0f; } else if (SENSING_MODE == 1) { dac_1 = PRES_A_VREF / 3.3f; dac_2 = PRES_B_VREF / 3.3f; } make_delay(); for (int i=0; i<50; i++) { if(i%2==0) ID_index_array[i] = - i * 0.5f; else ID_index_array[i] = (i+1) * 0.5f; } printf("systemcoreclock = %d Hz\n", SystemCoreClock); Input << 0.052414,0.066907,0.085407,0.109023,0.139169,0.177651,0.052414,0.066907,0.085407,0.109023,0.139169,0.177651,0.052414,0.066907,0.085407,0.109023,0.139169,0.177651,0.052414,0.066907,0.085407,0.109023; h1 << -0.02454003319144249,0.13071660697460175,0.08675816655158997,0.1402530074119568,-0.24982963502407074,0.12202739715576172,-0.13030944764614105,-0.11353740841150284,-0.2542628347873688,-0.04588286578655243,-0.14282149076461792,-0.2201535552740097,-0.18691661953926086,0.30389177799224854,-0.1729012429714203,-0.12240276485681534,-0.11355798691511154,0.2349482625722885,-0.24878336489200592,0.07184267044067383,-0.3221011161804199,0.08763179183006287,-0.27257153391838074,-0.06490874290466309,-0.06682667881250381,0.1505383551120758,-0.14478006958961487,-0.07367490231990814,0.23569869995117188,-0.1539779156446457,-0.1400003880262375,0.051764924079179764 ,-0.19842876493930817,0.18337926268577576,0.24467620253562927,-0.29177823662757874,-0.08481606096029282,0.09983056783676147,0.17972804605960846,-0.07474377751350403,-0.1711931675672531,0.12607872486114502,-0.21832025051116943,-0.1755477339029312,-0.010855759494006634,0.2378554791212082,0.03758585453033447,-0.13797838985919952,-0.15582887828350067,0.08006728440523148,0.280606746673584,0.28338202834129333,-0.06711727380752563,-0.09894979000091553,-0.07788881659507751,0.22705963253974915,-0.0012174372095614672,0.240607351064682,0.1039358377456665,0.18501906096935272,-0.03155122324824333,0.08036407828330994,-0.20284514129161835,0.06699042022228241 ,0.14068114757537842,0.13828633725643158,-0.0034593045711517334,0.1392701119184494,0.01057615876197815,-0.007689331658184528,0.07328304648399353,-0.14162643253803253,-0.04415355995297432,0.09164466708898544,0.24845272302627563,-0.05588914453983307,-0.054479751735925674,0.24456734955310822,-0.2598671317100525,-0.15801946818828583,0.2817283868789673,-0.19191598892211914,0.15788163244724274,0.28144943714141846,0.14735294878482819,-0.12544888257980347,0.11103320121765137,-0.20203278958797455,0.0017974432557821274,0.1191059947013855,-0.12710560858249664,0.1702873408794403,-0.09684925526380539,0.2480504810810089,-0.28676652908325195,-0.17398564517498016 ,0.04844924807548523,-0.06973694264888763,-0.1682211458683014,-0.3513043522834778,-0.22794683277606964,0.08840374648571014,0.026485737413167953,-0.3492684066295624,0.1813228577375412,0.06481858342885971,0.11471711844205856,0.1854662299156189,-0.12381665408611298,0.35136616230010986,-0.10501053929328918,-0.016016438603401184,0.03148011490702629,-0.17074286937713623,-0.1689852625131607,0.1171770691871643,-0.23076696693897247,-0.07204706966876984,-0.12052477896213531,-0.23881052434444427,-0.004284285008907318,0.11600598692893982,0.10962119698524475,-0.012203623540699482,0.33345603942871094,0.1084047257900238,0.015447823330760002,0.1315833479166031 ,0.12315890938043594,0.16742177307605743,0.0689031183719635,-0.29923000931739807,-0.10478553920984268,0.0034702986013144255,-0.06286507844924927,-0.3965417146682739,-0.24317654967308044,0.2535353899002075,-0.18702425062656403,0.2042631357908249,0.14613179862499237,0.2476590871810913,-0.20543844997882843,0.15613335371017456,-0.024847690016031265,-0.12820857763290405,0.13289833068847656,-0.033144671469926834,0.09313736855983734,0.19325080513954163,-0.20106908679008484,-0.061102136969566345,-0.028910696506500244,-0.2806609869003296,0.033241331577301025,-0.26521533727645874,0.33587634563446045,-0.13370811939239502,0.21700626611709595,0.008141759783029556 ,0.3156174421310425,0.033245913684368134,0.24999621510505676,0.14565978944301605,0.02309553697705269,-0.05169738829135895,-0.15119729936122894,-0.10350330173969269,-0.3457512855529785,0.03809545189142227,0.25342249870300293,-0.19578632712364197,-0.05333413928747177,0.09492939710617065,0.17943906784057617,-0.21144242584705353,-0.1867227405309677,-0.23938390612602234,-0.2632395327091217,0.06656297296285629,0.0961865782737732,-0.00792744755744934,0.10312435030937195,0.27112916111946106,-0.12544961273670197,0.17053177952766418,-0.23970040678977966,0.16830605268478394,0.18481910228729248,-0.0010759234428405762,0.049939122051000595,-0.059725455939769745 ,0.021065108478069305,-0.17225059866905212,0.1334478259086609,0.09036531299352646,0.22687482833862305,0.03710803762078285,-0.1765347123146057,0.0036233423743396997,-0.17170532047748566,-0.11777474731206894,-0.054618652909994125,-0.17656885087490082,0.052830975502729416,0.10441931337118149,-0.14971962571144104,-0.24781031906604767,-0.023929525166749954,-0.04490154981613159,0.2847473621368408,0.014796234667301178,-0.14429597556591034,-0.14511936902999878,-0.21516084671020508,-0.20089882612228394,-0.10562898963689804,-0.12727710604667664,-0.09228193759918213,-0.08893769234418869,-0.12074583023786545,-0.028564512729644775,0.008117200806736946,0.08297917991876602 ,0.19532811641693115,-0.05014912784099579,0.13636812567710876,0.048916492611169815,0.26100409030914307,-0.17881926894187927,0.012918300926685333,0.06905974447727203,0.16022373735904694,0.06287040561437607,-0.1698886901140213,-0.3164767324924469,0.06106283515691757,0.05603136122226715,0.04491907358169556,0.16258767247200012,0.06191227212548256,-0.2078513652086258,-0.26503077149391174,0.019191648811101913,-0.06990422308444977,0.018576622009277344,-0.10467308759689331,-0.023303329944610596,0.11910765618085861,0.014545410871505737,-0.2797531187534332,-0.014093500562012196,-0.09087783098220825,0.003536820411682129,-0.08422576636075974,0.20006318390369415 ,0.03522654250264168,-0.15291047096252441,0.11232474446296692,0.08317171782255173,0.01103570032864809,-0.23718038201332092,-0.043577663600444794,-0.10673496872186661,-0.08802048116922379,0.06057487800717354,-0.2207462638616562,0.21330848336219788,0.06867198646068573,0.31874582171440125,0.19785529375076294,0.11854913830757141,0.0048002502880990505,0.07107115536928177,0.1471722573041916,-0.021459000185132027,-0.25434109568595886,-0.01829427480697632,-0.2427632212638855,0.06919881701469421,-0.2938772141933441,-0.06733335554599762,-0.07296852767467499,0.21985474228858948,0.27857765555381775,-0.09769320487976074,-0.2202656865119934,0.06659334897994995 ,-0.18176554143428802,0.05808980390429497,-0.2002866566181183,0.2209930419921875,0.22003944218158722,-0.12194468080997467,0.16832226514816284,-0.32419517636299133,-0.31987497210502625,0.020202845335006714,-0.2701215445995331,0.15670055150985718,0.04660305753350258,0.2134874314069748,-0.21944394707679749,-0.25474902987480164,0.27780312299728394,0.28777045011520386,0.10909196734428406,-0.06471110135316849,-0.1670646369457245,0.13422733545303345,-0.09569443762302399,-0.2635143995285034,-0.14163701236248016,0.04615262150764465,0.11132439970970154,0.23280498385429382,0.23840151727199554,0.24882283806800842,0.0529453419148922,0.13884255290031433 ,-0.10154614597558975,-0.21454781293869019,-0.05455450713634491,0.2060181051492691,-0.24331730604171753,-0.18322165310382843,0.08804970234632492,-0.09168499708175659,-0.3127654492855072,-0.20708662271499634,-0.26258623600006104,-0.2734098434448242,-0.1649116575717926,0.33747056126594543,0.014040976762771606,0.23592090606689453,-0.13581429421901703,-0.1899891048669815,0.19671878218650818,-0.23027168214321136,0.14086498320102692,-0.20761027932167053,0.19642561674118042,0.00928562879562378,-0.07803404331207275,0.08413159847259521,0.06599533557891846,-0.2540142834186554,0.209262415766716,0.0242612361907959,-0.008453809656202793,0.13509076833724976 ,0.19965791702270508,0.15909932553768158,-0.2523933947086334,-0.024008844047784805,-0.3288625478744507,-0.3593894839286804,-0.10659854859113693,-0.09668480604887009,-0.25964510440826416,0.24553023278713226,0.2584691643714905,-0.13047806918621063,-0.045685749500989914,-0.027066625654697418,-0.24520277976989746,0.2635043263435364,0.06614753603935242,-0.14302769303321838,-0.22128811478614807,-0.2489294409751892,0.2430250197649002,0.1864563524723053,-0.19150227308273315,0.26879218220710754,-0.3449307382106781,0.1727219521999359,0.2771519124507904,0.08954040706157684,0.2631568908691406,0.12126106023788452,0.12375504523515701,-0.054388467222452164 ,0.19592446088790894,-0.34142163395881653,0.15802547335624695,0.18388450145721436,0.031184343621134758,-0.08831250667572021,-0.20661622285842896,0.06958860903978348,-0.161506786942482,0.25045934319496155,-0.10389973968267441,0.21004287898540497,-0.2358747273683548,-0.1947477161884308,0.05316495895385742,-0.0015946561470627785,-0.15815018117427826,0.1855827420949936,0.01572786457836628,-0.2823503911495209,-0.19912849366664886,0.022287487983703613,0.01019778847694397,-0.002432197332382202,0.1125744953751564,0.024761438369750977,0.28052565455436707,0.06848252564668655,0.07588296383619308,-0.2828674018383026,-0.1949537843465805,0.0682394951581955 ,-0.06400725990533829,-0.039301756769418716,0.05148342251777649,0.15645751357078552,-0.015306415967643261,-0.027875764295458794,0.19478058815002441,-0.1143186166882515,-0.11950938403606415,0.21234765648841858,0.2555554211139679,-0.05989915132522583,0.014815526083111763,0.12010202556848526,0.08785843849182129,0.0018573424313217402,-0.014310447499155998,0.08359912782907486,-0.05963675677776337,0.08984222263097763,-0.17661209404468536,-0.01255887746810913,0.09742525219917297,-0.2715410590171814,0.019773131236433983,-0.12170138955116272,0.21204951405525208,-0.0392717681825161,0.22050541639328003,0.1981203556060791,-0.12718753516674042,0.18615314364433289 ,0.207803875207901,-0.10612393915653229,0.2099064588546753,0.048610176891088486,-0.18356028199195862,0.05922550708055496,0.09807947278022766,0.05448151379823685,0.00759892538189888,0.008583632297813892,-0.02326703630387783,0.03895118832588196,0.142264261841774,-0.17807096242904663,0.03243169188499451,0.29156458377838135,0.16580337285995483,-0.04512497037649155,0.24243946373462677,0.19388025999069214,0.2613176107406616,0.21572408080101013,0.021654754877090454,0.19459950923919678,-0.12517954409122467,0.1592874825000763,0.1632046103477478,-0.2606440782546997,-0.08548226952552795,-0.08548004925251007,-0.13906358182430267,-0.16921734809875488 ,-0.15630532801151276,0.13156533241271973,-0.11297933757305145,0.12861967086791992,-0.19767631590366364,0.1394348293542862,-0.23108699917793274,0.0800437331199646,-0.21714667975902557,0.08518000692129135,-0.25191619992256165,0.23131662607192993,0.03946883976459503,-0.09874357283115387,0.2303425371646881,-0.19213639199733734,0.1962396651506424,-0.10008331388235092,-0.19810836017131805,-0.2060118019580841,0.14884798228740692,0.05755701661109924,-0.10641518235206604,0.0359015166759491,0.1892276555299759,-0.10104718804359436,-0.10194158554077148,0.0636373832821846,-0.0030684147495776415,0.22902312874794006,0.13050015270709991,0.13367223739624023 ,0.17304399609565735,-0.11803605407476425,0.1952093541622162,-0.058706384152173996,0.07460742443799973,-0.08487367630004883,0.2371104210615158,-0.27557069063186646,0.20663458108901978,0.1713942438364029,-0.27339255809783936,-0.041794922202825546,0.0006373148644343019,0.022903289645910263,-0.03237643837928772,0.1001778319478035,0.1372859627008438,0.2195289433002472,0.1444065421819687,-0.16924221813678741,0.17550763487815857,0.24889472126960754,-0.005206882953643799,-0.09046423435211182,-0.19790777564048767,-0.23666583001613617,-0.04738515615463257,0.19731944799423218,0.18761177361011505,-0.12751927971839905,-0.307704359292984,-0.1543550342321396 ,0.32603657245635986,-0.3041064739227295,0.25856587290763855,-0.2557964324951172,-0.3466465473175049,-0.3196622133255005,0.12455102801322937,-0.11209218949079514,0.001982415560632944,0.06973601132631302,0.14987079799175262,-0.20265568792819977,0.21144899725914001,-0.10064118355512619,0.09263011813163757,0.2236812561750412,0.11661216616630554,0.06638764590024948,-0.09710270911455154,-0.1529141068458557,0.2093910574913025,-0.21584033966064453,0.008751243352890015,0.06805345416069031,-0.2336517572402954,0.01942119002342224,0.08388552069664001,0.07689709961414337,-0.1510092169046402,0.2813257873058319,-0.2768191695213318,-0.037080224603414536 ,-0.003318269969895482,0.08421637862920761,-0.016360998153686523,-0.12425577640533447,-0.35029125213623047,0.16315333545207977,0.1867244839668274,0.04439976066350937,-0.1956385225057602,0.12546296417713165,0.14696259796619415,0.031027860939502716,0.13122601807117462,0.28269803524017334,0.09633612632751465,-0.15478374063968658,0.22323313355445862,-0.0710759162902832,-0.27780935168266296,0.053979892283678055,-0.015637023374438286,-0.1954222172498703,-0.0505031943321228,0.24318388104438782,-0.2976081073284149,-0.10191759467124939,-0.07833482325077057,-0.288814902305603,0.040884505957365036,0.138712078332901,0.20733070373535156,-0.29824215173721313 ,-0.18242500722408295,-0.3011151850223541,-0.18937499821186066,0.21996764838695526,0.08294257521629333,0.19795776903629303,-0.2721400856971741,-0.2665696442127228,-0.1749664843082428,-0.11208948493003845,-0.12227600067853928,0.13757038116455078,0.15364645421504974,-0.1376083493232727,0.14986392855644226,0.27994680404663086,0.11594970524311066,-0.0993688553571701,0.08206108957529068,-0.30797436833381653,0.1478293389081955,0.029855877161026,0.037324488162994385,-0.16034488379955292,-0.22942794859409332,-0.07402129471302032,0.01556810736656189,0.07635907083749771,0.1468832641839981,0.2229032814502716,0.2030598223209381,0.011082095094025135 ,-0.031403448432683945,-0.179839089512825,-0.061174169182777405,0.08824600279331207,-0.05152688920497894,0.09737619012594223,-0.019338518381118774,-0.149160236120224,-0.17775475978851318,0.20135465264320374,-0.26330751180648804,-0.20573703944683075,-0.18354615569114685,0.2306104153394699,-0.12902851402759552,-0.32519760727882385,-0.18613660335540771,-0.04431162402033806,0.07692430913448334,0.2852676808834076,0.18445321917533875,-0.1602698266506195,0.1428212821483612,0.24115940928459167,-0.15170736610889435,0.2710312306880951,-0.08893628418445587,0.08192634582519531,0.1068575456738472,-0.2417295277118683,0.018182098865509033,0.011811523698270321 ,0.1185283288359642,-0.1314961016178131,-0.2746659219264984,0.018920723348855972,0.11404602974653244,0.14093975722789764,-0.1613728106021881,0.010870097205042839,0.05537481606006622,-0.1315172165632248,-0.18558558821678162,-0.12937135994434357,-0.20973187685012817,0.1692427098751068,-0.045904770493507385,0.1710028052330017,0.01777065359055996,0.29331231117248535,-0.12049029022455215,0.04678349569439888,-0.25235429406166077,-0.033619701862335205,-0.042226120829582214,-0.27914759516716003,0.006846277974545956,0.08922392129898071,0.171451598405838,0.050000399351119995,-0.04939000681042671,-0.2795959711074829,0.26425138115882874,-0.2566368877887726; h2 << -0.13349971175193787,-0.10295046865940094,-0.04925942420959473,0.005893866065889597,-0.12596699595451355,0.2987118661403656,0.07975713163614273,0.06396704912185669,-0.30411389470100403,-0.10008957982063293,0.014623122289776802,-0.0538821816444397,0.048359375447034836,0.24325567483901978,0.10184130072593689,-0.24775750935077667,0.07803884148597717,-0.21483641862869263,0.17120853066444397,0.00830860622227192,-0.29617825150489807,-0.22132611274719238,-0.23983746767044067,-0.28275105357170105,-0.3873054087162018,0.30998873710632324,-0.4226490557193756,-0.11779281497001648,0.23828622698783875,0.11771553754806519,-0.37041905522346497,-0.30605563521385193 ,-0.16083313524723053,0.002147972583770752,-0.04321768879890442,0.20690490305423737,0.022892558947205544,0.008302271366119385,-0.20543429255485535,-0.08731026947498322,0.24677053093910217,0.048597872257232666,0.20651067793369293,0.16381694376468658,0.28672969341278076,-0.3506166338920593,0.06659439951181412,0.04734180495142937,0.03125026077032089,-0.2737269401550293,-0.21843840181827545,0.3144419193267822,0.10113385319709778,0.14034439623355865,-0.16832955181598663,0.33271604776382446,0.19579239189624786,0.14696596562862396,0.06076221913099289,0.24354417622089386,-0.28620439767837524,-0.0511949360370636,0.2096933126449585,0.040742650628089905 ,-0.1579037755727768,0.28447648882865906,-0.1789936125278473,0.20799604058265686,0.025723248720169067,0.17740526795387268,-0.1666354387998581,-0.06060470640659332,-0.017253071069717407,-0.2790656089782715,-0.16800916194915771,-0.2990717589855194,0.07126197218894958,-0.08032660186290741,-0.1799015998840332,-0.1891922950744629,0.2556300461292267,0.2080206573009491,-0.24888339638710022,0.27691522240638733,-0.21319638192653656,-0.14012537896633148,-0.30466505885124207,-0.013728171586990356,-0.1629670113325119,0.2530798614025116,0.0633285641670227,0.0011726915836334229,-0.14820529520511627,0.2823629677295685,0.10884168744087219,-0.2637729346752167 ,-0.12927524745464325,-0.01806354522705078,-0.23058539628982544,-0.030255556106567383,-0.6437712907791138,-0.17983144521713257,0.12746267020702362,0.08151327818632126,-0.06944303214550018,0.09271347522735596,-0.0808296874165535,-0.24855418503284454,-0.11665885150432587,0.12946322560310364,-0.0930287167429924,-0.3423658609390259,0.10996055603027344,0.24023392796516418,0.2942558825016022,-0.17709596455097198,-0.1255558878183365,-0.2134709507226944,-0.06394433975219727,-0.24457648396492004,0.10029968619346619,-0.2400282919406891,0.11666780710220337,-0.14067168533802032,-0.22396358847618103,0.2546447217464447,-0.002586635062471032,0.04970479756593704 ,-0.18258020281791687,0.2506926953792572,-0.0804666131734848,0.05040470138192177,0.02259594015777111,-0.23578980565071106,-0.09264150261878967,0.0013416205765679479,0.043158918619155884,-0.2690317630767822,0.04383622854948044,-0.25736406445503235,-0.21347089111804962,-0.19318343698978424,-0.21244710683822632,-0.13572444021701813,-0.1285906583070755,0.15626338124275208,-0.050212472677230835,0.0982573851943016,0.11135826259851456,0.06453899294137955,0.19172045588493347,-0.22890380024909973,-0.12237071990966797,0.09743352234363556,0.10070990025997162,0.28772199153900146,0.2695164978504181,-0.16498444974422455,0.014173826202750206,-0.2047310173511505 ,-0.19158349931240082,-0.004258692264556885,0.032371193170547485,-0.3141036927700043,-0.026762403547763824,-0.29336631298065186,0.08645252138376236,-0.16367173194885254,-0.03548547625541687,0.08825305104255676,-0.16509909927845,0.22309480607509613,-0.22282296419143677,0.2915789783000946,-0.24179422855377197,-0.19140881299972534,0.21163100004196167,0.24713221192359924,0.28102827072143555,0.25016462802886963,0.020191945135593414,0.19882827997207642,-0.1307595670223236,-0.059169698506593704,0.2300402969121933,-0.261514276266098,0.22954094409942627,-0.12279488891363144,0.05800282955169678,-0.26823562383651733,0.16349054872989655,0.1337476223707199 ,-0.21433322131633759,-0.1279313862323761,-0.11171227693557739,0.27164509892463684,-0.26441383361816406,0.2845393121242523,0.07359254360198975,-0.20844537019729614,-0.26620519161224365,0.17144301533699036,-0.061109013855457306,-0.19284695386886597,0.29584869742393494,-0.02723398245871067,-0.11244286596775055,0.0967603325843811,-0.16153597831726074,0.18742787837982178,-0.13470113277435303,0.12359786033630371,0.0469309501349926,0.02421507239341736,-0.07988794147968292,-0.15143592655658722,-0.18177983164787292,0.1452380120754242,0.2337561547756195,-0.17263798415660858,-0.11822041869163513,0.19546762108802795,-0.16657039523124695,-0.033323969691991806 ,0.29264822602272034,0.11346611380577087,0.04012581706047058,-0.0461408905684948,0.225418359041214,-0.05009126663208008,0.013211707584559917,0.004197537899017334,0.2864855229854584,0.01006925106048584,-0.010690944269299507,0.11204484105110168,-0.16305525600910187,-0.09700464457273483,0.08624142408370972,-0.3024343252182007,-0.29751643538475037,0.2706601917743683,0.19159749150276184,-0.1787676364183426,0.07430826127529144,0.05496254935860634,-0.07979777455329895,0.16874255239963531,-0.37327951192855835,0.09258365631103516,0.44089770317077637,-0.042961325496435165,-0.14135785400867462,0.07403197884559631,0.09825335443019867,0.07322394847869873 ,0.28564146161079407,0.2890130579471588,-0.021617114543914795,0.08250059932470322,0.3030112683773041,0.07065775990486145,-0.236245796084404,-0.2608001232147217,0.29470762610435486,-0.06864601373672485,0.2483109086751938,-0.20344071090221405,0.2957691252231598,-0.13390012085437775,0.19158922135829926,0.3726794719696045,0.02077532187104225,0.06025278568267822,0.05459544435143471,0.41055813431739807,0.32145416736602783,0.030043581500649452,0.28743305802345276,0.19736182689666748,0.1656898558139801,-0.28868207335472107,-0.039911627769470215,-0.006442106794565916,0.2501918375492096,-0.14010676741600037,-0.10169651359319687,-0.15317825973033905 ,0.2615049183368683,0.08643358945846558,-0.29237738251686096,-0.2458128184080124,0.20376496016979218,-0.0771239846944809,0.1555452048778534,-0.15540927648544312,0.18755429983139038,-0.07031691074371338,-0.06268419325351715,-0.041090548038482666,0.042330075055360794,0.27333545684814453,-0.008807391859591007,0.1133832335472107,-0.040624819695949554,-0.2859399914741516,-0.26647016406059265,-0.2497035712003708,0.09534543007612228,0.09418291598558426,-0.2307620644569397,0.055859606713056564,-0.07496815174818039,-0.19647599756717682,0.02131301537156105,0.09323979169130325,0.2113950550556183,0.0796298086643219,-0.06491973996162415,-0.3819006681442261 ,0.19981321692466736,0.1956864297389984,-0.033508092164993286,-0.22838544845581055,-0.12505969405174255,0.026693344116210938,0.07720576971769333,0.14285165071487427,-0.17670965194702148,0.17403557896614075,-0.22244372963905334,0.1680217683315277,-0.1060299277305603,0.1071399599313736,-0.11092887073755264,-0.05349590629339218,0.03990337252616882,0.0716913640499115,0.22807641327381134,-0.13356927037239075,0.1965365707874298,0.1245347261428833,0.07470300793647766,0.1796993613243103,-0.004812136758118868,0.10351252555847168,-0.057905394583940506,-0.18869787454605103,0.13817378878593445,0.17853263020515442,-0.027914874255657196,-0.02365732006728649 ,-0.2546439468860626,-0.09556084871292114,0.12328919768333435,0.03998832777142525,-0.30052247643470764,0.24699172377586365,-0.32009536027908325,-0.11670328676700592,0.17735600471496582,0.009893029928207397,0.26776403188705444,0.19816415011882782,-0.05558810010552406,-0.19641350209712982,0.3241870105266571,-0.0002136280236300081,-0.015536589547991753,0.10842388868331909,0.2418537586927414,0.25024867057800293,-0.0643463209271431,-0.06727208197116852,0.09996896982192993,0.08140590041875839,-0.12102364748716354,0.09566594660282135,0.026901600882411003,0.24559487402439117,-0.288028746843338,-0.2434448003768921,0.1651056408882141,0.23462900519371033 ,-0.08816954493522644,0.2728963792324066,-0.07170480489730835,0.08861888200044632,-0.08407828211784363,0.20119628310203552,-0.021976735442876816,0.020944571122527122,-0.15294449031352997,-0.038666754961013794,-0.1334909051656723,0.2502269148826599,0.20107106864452362,-0.2309870719909668,0.26465773582458496,0.09385055303573608,-0.0016800533048808575,0.21900424361228943,0.22734272480010986,0.15115073323249817,-0.3155216872692108,0.03708222880959511,-0.19714993238449097,0.18521378934383392,0.10345728695392609,0.21989409625530243,-0.008119909092783928,-0.27566710114479065,0.18573936820030212,0.15478622913360596,0.03387163206934929,-0.09682217240333557 ,0.14700931310653687,0.1833711564540863,-0.0858893096446991,0.03548716753721237,-0.03290480375289917,0.2733006179332733,-0.00011049837485188618,-0.1723647564649582,0.000652611255645752,-0.22920364141464233,0.03385178744792938,-0.11219978332519531,0.23820827901363373,0.33258119225502014,0.05578869208693504,-0.21240083873271942,-0.07963520288467407,0.14483880996704102,-0.18910400569438934,-0.1327388882637024,-0.024066906422376633,0.2018621563911438,-0.2228696048259735,0.2577541768550873,-0.16621330380439758,0.06491447985172272,-0.09694764763116837,0.19547560811042786,-0.011228948831558228,0.26896968483924866,-0.360990971326828,-0.2201414704322815 ,-0.23982827365398407,0.03880670666694641,-0.013682037591934204,-0.11685100197792053,-0.020662933588027954,0.30190005898475647,-0.14934301376342773,-0.15993990004062653,0.1152651309967041,-0.11991468071937561,-0.15497799217700958,0.11116543412208557,-0.2045515924692154,0.2403949797153473,-0.21275603771209717,0.05732181668281555,-0.2770107090473175,0.088544100522995,0.19012078642845154,-0.07119561731815338,-0.18914666771888733,-0.10413256287574768,-0.16050675511360168,0.11598068475723267,-0.03151249885559082,-0.1937510371208191,0.18474078178405762,0.19502457976341248,0.22045472264289856,-0.29474368691444397,0.09864541888237,0.06054645776748657 ,-0.1617974042892456,0.1317739188671112,0.03260180354118347,-0.19948318600654602,-0.0928228572010994,-0.1987132430076599,-0.1755896806716919,0.11372503638267517,0.05445769429206848,0.07657262682914734,-0.18663887679576874,-0.23218511044979095,0.2056141495704651,0.03608625754714012,0.33959874510765076,-0.3019200563430786,-0.25386664271354675,-0.18997573852539062,-0.06610497832298279,-0.1891406625509262,-0.10423542559146881,-0.11639183014631271,-0.3044300675392151,0.2589237689971924,-0.06821785122156143,0.17655706405639648,0.1661142259836197,-0.24122722446918488,-0.0006675124168395996,-0.2239055633544922,-0.0723206177353859,0.2102394998073578 ,0.036086976528167725,-0.062024205923080444,0.10704237222671509,-0.1612134575843811,-0.1631729155778885,0.1497061848640442,0.03271482139825821,0.27597710490226746,-0.23304778337478638,-0.035415440797805786,0.1086379662156105,0.07746559381484985,0.13613636791706085,0.09150157123804092,0.25167548656463623,-0.24342824518680573,-0.027234435081481934,0.19620582461357117,0.44021302461624146,-0.23242811858654022,-0.05763920396566391,-0.09912444651126862,-0.19671492278575897,-0.33463647961616516,-0.40228715538978577,-0.000608850852586329,0.06298207491636276,0.39882805943489075,-0.2531542181968689,0.24004116654396057,-0.30925723910331726,-0.26930177211761475 ,0.1379433274269104,-0.16078773140907288,0.11784148216247559,0.20431241393089294,0.29410573840141296,0.19759181141853333,0.09952005743980408,0.1544932872056961,0.040603965520858765,-0.2119520902633667,0.18040086328983307,-0.38904741406440735,-0.046765703707933426,0.13744039833545685,-0.3137235641479492,0.05679671838879585,0.1565159410238266,0.2297056019306183,0.032699450850486755,0.20715069770812988,-0.016263214871287346,-0.3025153875350952,0.26029130816459656,0.42276427149772644,0.2875830829143524,-0.12763257324695587,-0.20330224931240082,-0.07699788361787796,-0.08671019971370697,-0.019541800022125244,0.4000849425792694,0.17512208223342896 ,0.09298902750015259,0.2841971218585968,-0.0814327746629715,-0.010091223753988743,-0.12308911234140396,0.11057800054550171,-0.1737426221370697,0.20642486214637756,-0.2925014793872833,0.022429823875427246,-0.06304851174354553,-0.07166500389575958,-0.26361000537872314,0.050878144800662994,0.189671128988266,0.30893731117248535,0.1296386420726776,0.027322769165039062,0.29731038212776184,0.14744597673416138,0.2998683750629425,0.08306887000799179,0.06231796741485596,0.3401893973350525,-0.004573390819132328,0.18759925663471222,-0.16945621371269226,0.01625938154757023,0.14345040917396545,-0.11986468732357025,-0.21137407422065735,0.1280972957611084 ,-0.14775772392749786,0.29651907086372375,0.02990397810935974,-0.06818585097789764,0.1993788629770279,-0.22813674807548523,0.16850803792476654,0.24565419554710388,-0.2325194776058197,-0.2458522766828537,-0.017307782545685768,-0.12818260490894318,-0.17801909148693085,-0.2504909038543701,0.1731644719839096,0.18156693875789642,0.23218704760074615,0.11064860224723816,-0.15070302784442902,0.10314767062664032,0.3309069275856018,-0.28518369793891907,-0.07374785840511322,0.05567348375916481,-0.01467915065586567,-0.3420534133911133,-0.21914657950401306,0.23488031327724457,-0.2205982804298401,0.28094157576560974,-0.15506510436534882,0.07852166146039963 ,0.2703488767147064,-0.16041381657123566,0.12738299369812012,-0.045484237372875214,0.06815514713525772,0.1861400008201599,-0.15391220152378082,0.28177282214164734,0.1474648416042328,-0.23766008019447327,0.025048013776540756,0.06622862070798874,0.09594401717185974,-0.1663329154253006,-0.10072105377912521,-0.044219132512807846,-0.2531753182411194,0.08700510859489441,-0.26066508889198303,0.07304855436086655,-0.13394378125667572,0.22174499928951263,-0.18301571905612946,-0.16244065761566162,-0.004656728822737932,0.2568950057029724,0.15513287484645844,-0.2911604344844818,0.08541131019592285,0.08213254809379578,-0.258662611246109,0.04998021572828293 ,-0.06283275783061981,-0.26753589510917664,-0.10381917655467987,-0.13344663381576538,0.2644997537136078,0.2204643189907074,0.2924788296222687,-0.17931663990020752,-0.09078609943389893,-0.17306232452392578,0.02247890830039978,-0.26996222138404846,0.22075030207633972,-0.3029964864253998,0.21873190999031067,-0.0030784308910369873,0.18228653073310852,0.09971508383750916,-0.242676243185997,-0.1424383968114853,0.19031599164009094,0.3004438579082489,-0.23650792241096497,-0.2683113217353821,0.29957786202430725,0.08561205863952637,-0.1366746425628662,-0.15950153768062592,-0.07675467431545258,-0.2218506634235382,-0.2795913517475128,0.1869203746318817 ,0.2003176510334015,-0.27792131900787354,0.055196613073349,-0.27959588170051575,0.18430876731872559,-0.05316638946533203,0.16156336665153503,-0.18850930035114288,0.09482413530349731,0.021483391523361206,0.009039878845214844,0.1586727499961853,0.11457142233848572,0.2876913249492645,-0.24802550673484802,0.14089101552963257,-0.06842575967311859,-0.10107968747615814,0.06239110231399536,-0.2528536915779114,-0.27538973093032837,0.15457189083099365,-0.15549622476100922,0.20245882868766785,0.08544808626174927,0.22650876641273499,-0.05268847942352295,0.20387354493141174,0.24724552035331726,0.21444126963615417,0.05186706781387329,-0.11084021627902985 ,-0.19810965657234192,0.2745245397090912,0.1767616868019104,0.19752147793769836,0.0650932788848877,0.29138168692588806,-0.29061684012413025,0.010446667671203613,0.025284886360168457,-0.10202452540397644,-0.10358673334121704,0.14746251702308655,0.15136101841926575,0.04500553011894226,-0.2497977316379547,-0.29277902841567993,0.02556520700454712,-0.09509801864624023,0.16731274127960205,-0.25266408920288086,-0.3004688322544098,-0.19769597053527832,-0.14847496151924133,0.3053832948207855,0.07563886046409607,-0.10258816182613373,-0.060128673911094666,0.0016401112079620361,-0.29647189378738403,-0.18869297206401825,0.05497395992279053,0.16092956066131592 ,-0.011267274618148804,-0.25281068682670593,-0.10565309226512909,-0.10787995159626007,0.23997481167316437,0.011940985918045044,0.10584557056427002,-0.22430141270160675,-0.06814777851104736,-0.24531681835651398,-0.07618588954210281,0.12015970051288605,0.0185067281126976,0.002306112553924322,0.17718534171581268,0.3006735146045685,0.1760181039571762,0.04417389631271362,0.20160885155200958,0.16602091491222382,0.2585296034812927,-0.027029002085328102,-0.2520882785320282,0.29521048069000244,0.25318053364753723,0.05056742578744888,0.22924767434597015,-0.03404907137155533,-0.18211489915847778,-0.15127526223659515,0.18461528420448303,0.2534249424934387 ,-0.10580866038799286,-0.17215237021446228,-0.01352420449256897,-0.13443149626255035,-0.10265451669692993,-0.2169143706560135,0.30098411440849304,-0.2986297905445099,0.07908004522323608,-0.30061498284339905,0.10424068570137024,-0.018799901008605957,-0.18665757775306702,0.005998075008392334,-0.2969498336315155,0.18525955080986023,0.2379322350025177,0.15184926986694336,0.215760737657547,-0.19088758528232574,0.08620095252990723,0.019999295473098755,-0.0752219706773758,0.11181813478469849,0.1881926953792572,0.2210972011089325,0.13236162066459656,-0.06690356135368347,-0.18345263600349426,-0.14861416816711426,0.08577704429626465,-0.09683996438980103 ,0.03951254487037659,0.23604217171669006,0.012746036052703857,-0.12561996281147003,-0.1283164620399475,0.25823846459388733,0.10610169172286987,0.22718152403831482,0.1749366819858551,0.007794857025146484,0.11289489269256592,0.2725127637386322,-0.13616766035556793,-0.03546282649040222,-0.1685536652803421,-0.24492129683494568,0.15760570764541626,0.017505377531051636,-0.273531436920166,-0.005667984485626221,0.18370777368545532,-0.023328542709350586,0.2379932701587677,-0.048420339822769165,0.10376441478729248,-0.295401930809021,-0.20498433709144592,0.22346952557563782,-0.26649031043052673,-0.08466874063014984,0.23347875475883484,-0.03380200266838074 ,0.3014208972454071,-0.11652402579784393,0.24921879172325134,0.16919833421707153,-0.33012309670448303,-0.19414515793323517,-0.031346261501312256,-0.11968852579593658,0.23963233828544617,0.21321198344230652,-0.04236738383769989,-0.04909612983465195,-0.15507397055625916,0.041283149272203445,-0.0798816904425621,-0.16132454574108124,-0.22342979907989502,0.2487291395664215,-0.275277704000473,-0.1761859953403473,-0.1089298352599144,0.14958830177783966,-0.09928475320339203,-0.18516667187213898,-0.11554347723722458,0.2378307580947876,0.042566750198602676,-0.09927814453840256,-0.03476092219352722,0.2736774981021881,0.01615159772336483,-0.08927445858716965 ,-0.17075178027153015,0.009595632553100586,0.2466227114200592,0.033388618379831314,-0.34659287333488464,-0.2819134294986725,-0.07840541750192642,-0.15331926941871643,-0.2516406178474426,0.012286126613616943,0.20758569240570068,-0.2048848569393158,-0.12051127851009369,0.10427423566579819,0.0999673530459404,0.028271911665797234,-0.24087269604206085,-0.048499464988708496,-0.20961162447929382,0.10103815048933029,-0.2312844693660736,-0.22412340342998505,-0.031352698802948,0.27904242277145386,-0.11300363391637802,-0.16207841038703918,-0.33752813935279846,0.3786945641040802,-0.07090267539024353,-0.23986908793449402,-0.30680611729621887,-0.0811222642660141 ,-0.01348048448562622,0.08233943581581116,0.18838337063789368,0.21852442622184753,-0.04740855097770691,0.19177213311195374,-0.0060100555419921875,0.20933791995048523,0.06356173753738403,0.063028484582901,0.09440034627914429,0.29559019207954407,-0.2545689642429352,-0.09652335941791534,-0.2841038703918457,-0.03553757071495056,0.02329021692276001,-0.08720272779464722,-0.0750999003648758,-0.10468094050884247,-0.03761094808578491,-0.030853450298309326,0.2112145721912384,0.2599640190601349,-0.2969062626361847,-0.13667742908000946,0.24173608422279358,0.09566575288772583,0.021116197109222412,-0.005982398986816406,-0.26417285203933716,0.1879688799381256 ,-0.1763739138841629,-0.17203155159950256,0.0620841383934021,-0.04815051332116127,-0.08886270225048065,-0.19284456968307495,0.09443464875221252,0.1472807228565216,-0.21029016375541687,0.2210421860218048,-0.26095423102378845,0.23557153344154358,-0.07677116990089417,-0.16641905903816223,-0.16725768148899078,-0.2004043012857437,0.08218716084957123,-0.29308468103408813,-0.057871971279382706,-0.07429885864257812,0.2029605507850647,-0.19719278812408447,-0.22302524745464325,0.2192145586013794,-0.13908077776432037,0.2019682675600052,-0.028201768174767494,0.08898906409740448,0.17976179718971252,-0.22928372025489807,0.3000858724117279,0.08501409739255905 ,-0.09888127446174622,-0.22750279307365417,-0.22503364086151123,-0.0014225258491933346,-0.012498408555984497,-0.24329537153244019,-0.09442851692438126,0.08175003528594971,-0.016126900911331177,0.06972584128379822,0.05360379442572594,0.22432491183280945,-0.031845152378082275,-0.2877633273601532,0.18349257111549377,0.19327174127101898,-0.09216172993183136,0.04617339372634888,-0.09483018517494202,-0.07904840260744095,-0.035641368478536606,-0.2887636721134186,-0.06047184765338898,-0.3070217967033386,4.397468364913948e-05,-0.19100867211818695,0.28239238262176514,-0.2758784890174866,-0.16326025128364563,0.11664235591888428,-0.03823475539684296,0.11660117655992508; h3 << -0.2551194727420807,-0.09101890027523041,-0.026477575302124023,-0.24469062685966492,-0.10447631776332855,-1.3142824172973633e-05,0.23563924431800842,0.21467849612236023,-0.17011712491512299,0.034586966037750244,-0.08393588662147522,0.28293344378471375,0.045914679765701294,0.1892293095588684,-0.2476848065853119,0.13452908396720886,0.033751994371414185,0.2061004936695099,-0.022569477558135986,-0.10083381831645966,-0.11890523135662079,0.024368882179260254,-0.22618433833122253,0.044178664684295654,0.25393906235694885,-0.1258748173713684,0.2930828630924225,-0.22120264172554016,0.08456003665924072,0.2922307550907135,-0.21407078206539154,-0.1853330433368683 ,0.05588451027870178,0.19731858372688293,-0.055143773555755615,0.030042022466659546,-0.13887283205986023,-0.1361943781375885,-0.2855546772480011,0.011247634887695312,0.1085631251335144,0.021339505910873413,0.17599248886108398,0.09762296080589294,-0.05771490931510925,-0.14660483598709106,-0.21469902992248535,0.03876742720603943,-0.21865856647491455,-0.12651903927326202,0.22753819823265076,-0.23926785588264465,-0.14443452656269073,0.06739777326583862,0.14157342910766602,0.049514561891555786,-0.1251431256532669,-0.25851932168006897,0.0932874083518982,0.2900666892528534,-0.023782014846801758,0.050485759973526,0.09447437524795532,0.0058679282665252686 ,-0.2800689935684204,-0.038760632276535034,0.13974270224571228,0.01585569977760315,0.11945047974586487,-0.19458696246147156,0.11322265863418579,0.25643888115882874,-0.061097174882888794,-0.07816044986248016,-0.07445238530635834,-0.22145158052444458,-0.1081896424293518,-0.09452249109745026,0.16234496235847473,0.1413259506225586,-0.2648085951805115,-0.054869145154953,-0.05491623282432556,0.17325228452682495,0.23639705777168274,0.0748760998249054,-0.1324603259563446,0.15828460454940796,-0.22871175408363342,-0.027338534593582153,-0.06307074427604675,0.13438841700553894,0.13834497332572937,0.1633671224117279,0.259930282831192,-0.21565306186676025 ,0.2906629145145416,0.20458483695983887,-0.2048129439353943,0.18967533111572266,0.031110908836126328,0.012224288657307625,-0.061309605836868286,-0.17915479838848114,-0.07229355722665787,-0.044261813163757324,-0.09506386518478394,0.24970653653144836,0.084104023873806,0.14075174927711487,0.22106656432151794,-0.23978039622306824,-0.28915077447891235,0.030949801206588745,-0.324018657207489,0.14200536906719208,0.16460198163986206,0.03645682334899902,-0.16484108567237854,-0.2748301029205322,0.2685009241104126,-0.11024686694145203,-0.14180462062358856,-0.06628534197807312,-0.12027380615472794,-0.25852420926094055,0.05653107166290283,0.0037463903427124023 ,0.07563930749893188,-0.0864691436290741,-0.2677825689315796,0.10359114408493042,-0.08386197686195374,-0.01570148952305317,-0.09772239625453949,0.2470131814479828,-0.11951703578233719,-0.2740214169025421,0.2979947626590729,-0.24627932906150818,-0.33795294165611267,-0.04848279431462288,0.06802645325660706,-0.048776447772979736,0.20131775736808777,0.013118326663970947,-0.025344420224428177,0.16618464887142181,-0.14039944112300873,0.3214682638645172,0.14059734344482422,0.20571765303611755,-0.09259504824876785,0.12758469581604004,0.2975369393825531,-0.2769588828086853,0.27723395824432373,-0.09959287941455841,-0.07189898192882538,0.007399916648864746 ,0.10931676626205444,0.2396949827671051,0.12925085425376892,-0.01787710189819336,-0.10811276733875275,0.07592436671257019,-0.061815500259399414,0.04091137647628784,0.02548360824584961,-0.15699732303619385,0.08972057700157166,-0.21529507637023926,-0.003787398338317871,-0.1505761295557022,0.2971965968608856,0.25175121426582336,-0.2889891266822815,-0.13035915791988373,0.16576141119003296,0.06524023413658142,0.09726372361183167,-0.25527554750442505,0.023232191801071167,0.27409639954566956,-0.14640875160694122,-0.18302330374717712,0.09057381749153137,0.02826198935508728,-0.27729424834251404,-0.29547566175460815,-0.25800079107284546,0.24402263760566711 ,-0.21155381202697754,0.22487755119800568,-0.13003289699554443,0.02903335727751255,0.0982653871178627,0.1536569446325302,-0.07957221567630768,0.2444917857646942,0.05783398076891899,-0.28369563817977905,-0.03127405047416687,-0.25618287920951843,0.04224606975913048,-0.11560255289077759,0.25543639063835144,-0.1192857176065445,-0.18917083740234375,0.011466026306152344,0.09430564939975739,0.15590092539787292,0.18224665522575378,-0.09396838396787643,-0.2636158764362335,-0.27819615602493286,-0.2612522840499878,-0.2910519242286682,-0.2693059742450714,-0.2712043225765228,0.22474904358386993,-0.09532724320888519,0.3048698306083679,0.15567372739315033 ,-0.01093912124633789,-0.23583689332008362,0.28153905272483826,0.2877257764339447,0.08201509714126587,-0.2514142394065857,0.036741942167282104,-0.0059101879596710205,-0.26075154542922974,-0.27182313799858093,0.09319102764129639,-0.08139897882938385,0.1846132129430771,-0.007431956008076668,0.0685860812664032,-0.29903873801231384,0.1317853033542633,0.20550194382667542,-0.12478919327259064,-0.28424710035324097,0.23210765421390533,0.13067273795604706,0.0343703031539917,0.12564969062805176,0.04770389571785927,0.23886635899543762,-0.2778390347957611,0.13853725790977478,0.3018551468849182,0.17161712050437927,-0.017215043306350708,-0.05991865694522858 ,-0.20420776307582855,0.1970202624797821,0.23591408133506775,-0.282694011926651,0.09019026160240173,0.20012763142585754,0.028453975915908813,0.23323127627372742,0.15246456861495972,-0.1270071268081665,0.20025727152824402,0.13077861070632935,-0.2238168716430664,-0.20709244906902313,-0.0045506954193115234,-0.16448761522769928,0.28163614869117737,0.1971360743045807,0.30405697226524353,-0.28959211707115173,-0.2255709171295166,0.15360668301582336,0.24163606762886047,0.19554737210273743,-0.1804599016904831,0.07604315876960754,-0.1459394246339798,-0.14081311225891113,-0.29656586050987244,0.19529584050178528,-0.05168652534484863,-0.03415781259536743 ,0.27550336718559265,-0.14170598983764648,-0.21542268991470337,-0.2159879207611084,0.06500789523124695,-0.21155211329460144,-0.01575431227684021,0.0617731511592865,0.13126209378242493,-0.04922589659690857,-0.23877641558647156,-0.06292802095413208,0.01433342695236206,0.14592674374580383,-0.23886999487876892,0.08878573775291443,0.1853090226650238,-0.05102238059043884,-0.13667166233062744,-0.24401302635669708,0.25155118107795715,-0.20339438319206238,0.03535670042037964,0.048473477363586426,-0.13871997594833374,-0.15382859110832214,-0.13837768137454987,0.26085415482521057,0.2491457164287567,0.157204270362854,0.14108964800834656,0.12518465518951416 ,-0.023678362369537354,0.21583256125450134,-0.0008795078611001372,0.1337454915046692,0.1972961574792862,0.06894860416650772,0.0393199622631073,0.196751207113266,0.021013112738728523,0.2390732765197754,0.17463752627372742,-0.06168833374977112,-0.15600533783435822,-0.13375309109687805,0.080221027135849,-0.2471318244934082,0.026521950960159302,0.28880444169044495,0.18180696666240692,-0.14862056076526642,0.010060903616249561,0.008893917314708233,0.054391685873270035,0.27783286571502686,0.1417618691921234,-0.25962090492248535,0.04291031137108803,0.16766448318958282,0.22548967599868774,-0.2912617325782776,-0.24803094565868378,-0.16964496672153473 ,0.2680447995662689,0.04988827928900719,-0.2604551613330841,-0.06360144913196564,-0.07355550676584244,0.1419062316417694,0.1912839114665985,-0.17794576287269592,0.21344752609729767,-0.32452166080474854,-0.2607074975967407,0.2547462284564972,0.2808741331100464,0.08698759973049164,0.23152390122413635,-0.07731422781944275,0.21101722121238708,-0.15284278988838196,0.23690250515937805,0.11099313944578171,0.045659054070711136,0.25897544622421265,-0.2734209895133972,0.09973400086164474,-0.2234855592250824,0.18312275409698486,-0.20327457785606384,0.24314641952514648,0.2581717371940613,-0.1739533692598343,-0.27099403738975525,-0.27753785252571106 ,0.10771462321281433,0.1270637810230255,-0.029593871906399727,0.048757344484329224,0.14432331919670105,0.150037944316864,-0.2502448558807373,-0.05063694715499878,-0.24201413989067078,-0.11501708626747131,0.24353471398353577,0.11519002914428711,-0.20123691856861115,0.04388739541172981,-0.0055807530879974365,0.05870962142944336,-0.0561012327671051,-0.1419317126274109,-0.22982393205165863,-0.012807505205273628,-0.18990859389305115,-0.2882382273674011,0.26737427711486816,-0.18213631212711334,-0.17948952317237854,-0.03866580128669739,0.050366636365652084,0.23561419546604156,0.10195441544055939,0.024399906396865845,-0.264041006565094,0.067328080534935 ,0.07240793108940125,0.013581753708422184,0.2886071503162384,0.33517664670944214,0.06038776785135269,0.1265794038772583,0.23807910084724426,-0.09019742906093597,0.13383500277996063,-0.2274075150489807,0.13386529684066772,0.030263751745224,-0.15911448001861572,0.10485177487134933,0.13272255659103394,-0.0684008002281189,-0.13351139426231384,0.2471931278705597,0.10377484560012817,0.2869516909122467,0.07341593503952026,0.11802513897418976,-0.07614786922931671,0.3203943371772766,0.15393073856830597,-0.1976800560951233,-0.19668111205101013,0.26847177743911743,-0.2050236016511917,-0.29330405592918396,0.040703099220991135,0.06578359752893448 ,-0.27890223264694214,0.028393682092428207,0.27142634987831116,0.2020181119441986,-0.017035065218806267,-0.24077828228473663,-0.2505151033401489,-0.2674597501754761,-0.2380676418542862,0.08589410781860352,0.020896315574645996,0.04456409811973572,0.08395307511091232,-0.02637488767504692,-0.02410009503364563,0.10129088163375854,0.22686699032783508,-0.30486053228378296,0.07207807153463364,0.168308824300766,0.11956266313791275,-0.21200691163539886,-0.1238783523440361,0.1856202334165573,-0.1537778228521347,-0.025903940200805664,-0.07543710619211197,0.2098950445652008,0.25567781925201416,0.06508117914199829,0.02118399739265442,0.14526255428791046 ,0.3047083914279938,0.11099091172218323,-0.11378012597560883,-0.22131715714931488,0.17421483993530273,0.15522044897079468,-0.09724730253219604,-0.25786101818084717,-0.24032863974571228,0.12881293892860413,-0.2581462860107422,0.038040339946746826,0.16599057614803314,-0.03181708604097366,0.062144935131073,-0.28920799493789673,0.03473195433616638,-0.0016761720180511475,0.1232852041721344,-0.33812928199768066,0.17322932183742523,0.21282772719860077,0.23908089101314545,-0.2546650171279907,-0.11406802386045456,-0.031148135662078857,-0.15092508494853973,-0.08215931057929993,0.10083970427513123,0.017086774110794067,-0.15847967565059662,-0.43811115622520447 ,-0.06136500835418701,-0.11579577624797821,-0.23311558365821838,-0.020844489336013794,0.161813884973526,0.25480687618255615,0.11958792805671692,-0.0384809672832489,-0.10647237300872803,-0.09010881185531616,0.22322741150856018,-0.1071339100599289,0.028004037216305733,-0.20909930765628815,0.040097206830978394,0.08616101741790771,-0.15468145906925201,-0.21275553107261658,-0.23739154636859894,-0.23840199410915375,0.09806761145591736,0.30803728103637695,0.14114680886268616,0.09007054567337036,-0.03398526832461357,0.12031787633895874,-0.184563547372818,0.0523558147251606,-0.1914299577474594,-0.24735762178897858,-0.0892629474401474,-0.11765947937965393 ,0.1169951856136322,0.06741076707839966,0.014288008213043213,-0.1894388198852539,0.2306886613368988,0.08970087766647339,0.29362860321998596,0.2666439712047577,-0.1488228738307953,0.22382596135139465,-0.1313140094280243,0.02602824568748474,0.029441386461257935,-0.1546926349401474,0.10762849450111389,0.06951633095741272,0.0639207661151886,0.27696695923805237,-0.2749756872653961,0.2684275209903717,-0.240950807929039,-0.08405844867229462,0.26762983202934265,0.09600964188575745,-0.20394444465637207,0.012219250202178955,-0.09225042164325714,-0.12637756764888763,-0.21354423463344574,-0.29393887519836426,-0.056166648864746094,0.002250969409942627 ,-0.16101892292499542,0.0358797162771225,0.43079784512519836,0.2605867087841034,0.033972837030887604,-0.26316049695014954,0.1589156985282898,-0.17396175861358643,0.29257088899612427,-0.14439350366592407,0.1600557565689087,-0.04377517104148865,-0.11310844868421555,-0.056318942457437515,-0.2592318058013916,0.1978430449962616,0.18047624826431274,0.2863751947879791,-0.16123604774475098,-0.009939590469002724,-0.08062873780727386,0.0892474502325058,0.2678377628326416,0.4043545126914978,-0.11606839299201965,-0.28873488306999207,0.048900723457336426,0.2837308943271637,0.11584324389696121,0.18439257144927979,0.17250561714172363,0.39480021595954895 ,0.261911004781723,-0.2764647305011749,-0.4822510778903961,-0.0038792183622717857,0.06886842846870422,0.09860533475875854,-0.06670857965946198,-0.030254334211349487,-0.2904336750507355,0.1197996437549591,0.01667046546936035,-0.2924177646636963,0.1934618502855301,-0.08827721327543259,-0.20773646235466003,-0.10781967639923096,-0.15712574124336243,0.16112294793128967,0.15956245362758636,0.168865367770195,0.14229415357112885,0.1682685911655426,-0.3314894437789917,-0.04511234164237976,0.19475895166397095,0.0025720298290252686,-0.02036861702799797,-0.24640622735023499,0.16197645664215088,0.21125611662864685,-0.05115009471774101,-0.5753244161605835 ,0.14277681708335876,-0.17837506532669067,-0.023754309862852097,-0.19470283389091492,-0.12246686965227127,0.055870335549116135,0.1624150574207306,-0.27022814750671387,-0.09540649503469467,-0.29762372374534607,-0.2852642238140106,0.18551066517829895,0.24858085811138153,0.14418518543243408,-0.03100520372390747,-0.2484396994113922,0.06366744637489319,-0.2764144539833069,0.12580512464046478,0.1863812357187271,-0.3750770390033722,0.30558088421821594,0.22592295706272125,-0.2764151692390442,-0.08330509811639786,-0.19159743189811707,0.25842007994651794,-0.3267556130886078,-0.15882858633995056,-0.10488687455654144,-0.20926116406917572,-0.11732711642980576 ,0.29069945216178894,-0.22613553702831268,0.019009560346603394,-0.28878214955329895,0.13782989978790283,-0.20606419444084167,0.045349299907684326,-0.17138783633708954,-0.13634654879570007,0.028545528650283813,-0.16238126158714294,-0.15074089169502258,-0.10786417126655579,-0.25459790229797363,0.09875330328941345,0.08164769411087036,0.2294725477695465,0.10683679580688477,-0.2498348206281662,-0.09913146495819092,0.18476957082748413,0.2576355040073395,0.16651621460914612,-0.16394875943660736,0.2908710241317749,0.023651927709579468,-0.1729920208454132,0.2343282699584961,0.114747054874897,0.19045329093933105,0.02994692325592041,-0.18855193257331848 ,0.1991647183895111,0.12534403800964355,-0.04112154245376587,0.23123982548713684,-0.17588619887828827,-0.302817702293396,-0.1610087752342224,-0.031804412603378296,0.10274738073348999,-0.25018924474716187,0.15975651144981384,-0.057292819023132324,0.1464652419090271,0.08016204833984375,0.2151305377483368,0.2952744662761688,-0.21319252252578735,0.04970458149909973,0.10210192203521729,0.3050673305988312,0.21167120337486267,-0.15151944756507874,0.13887640833854675,0.25299301743507385,-0.11117732524871826,-0.07015113532543182,-0.287551611661911,-0.025779157876968384,-0.07337476313114166,-0.24420931935310364,0.015819430351257324,-0.10595546662807465 ,0.12202468514442444,0.0985947847366333,-0.2749728858470917,-0.27987486124038696,0.13006313145160675,0.17691220343112946,-0.06113804876804352,-0.11568751931190491,0.24261273443698883,-0.33250051736831665,-0.06917986273765564,-0.11160935461521149,-0.17044304311275482,-0.09174656867980957,-0.06735922396183014,0.05864924192428589,-0.25733181834220886,-0.17565661668777466,-0.07543282955884933,-0.18338191509246826,-0.36578381061553955,0.2753944993019104,0.14209599792957306,-0.1868741661310196,0.3329981863498688,0.1795230209827423,0.22248393297195435,-0.06621203571557999,-0.07096906751394272,0.2425754964351654,-0.21537242829799652,-0.2323274463415146 ,-0.3055141270160675,-0.25945645570755005,-0.03330126777291298,-0.08714571595191956,-0.23958928883075714,-0.035590264946222305,0.09419310092926025,0.21086838841438293,0.1225021556019783,0.05183860659599304,-0.25001513957977295,-0.004238337278366089,0.11344874650239944,0.11694838851690292,-0.023131370544433594,0.036719828844070435,0.16260939836502075,0.05286213755607605,-0.28451016545295715,-0.09079128503799438,0.11287535727024078,-0.041498955339193344,0.10957061499357224,0.02120070531964302,0.15043161809444427,-0.02825927734375,-0.11904071271419525,-0.2225356101989746,0.04479367658495903,0.1865309774875641,0.25861886143684387,-0.4281558096408844 ,0.1782623827457428,0.07742311805486679,-0.19943349063396454,0.009202931076288223,0.20097565650939941,0.2655416429042816,-0.2435605823993683,0.1475539207458496,0.26848459243774414,0.07351516932249069,-0.27482104301452637,-0.22968843579292297,-0.0032657950650900602,0.09409500658512115,-0.2527656555175781,-0.3049176335334778,0.032145023345947266,-0.25376296043395996,-0.024714192375540733,-0.1558963507413864,0.03983606398105621,0.1586221307516098,0.09342251718044281,0.06909164786338806,-0.18494604527950287,0.10029953718185425,0.17456218600273132,0.2811775207519531,-0.27735406160354614,0.1616479754447937,-0.17598764598369598,0.048629067838191986 ,-0.17396044731140137,-0.14763697981834412,-0.05150431767106056,0.11563663184642792,0.0912056639790535,-0.1369282454252243,-0.13985206186771393,-0.1761629432439804,-0.27742800116539,-0.27648791670799255,0.26132693886756897,-0.1146831065416336,0.278407484292984,0.29760831594467163,-0.19851773977279663,-0.10762731730937958,0.14198419451713562,0.10370296239852905,0.052602145820856094,-0.16641484200954437,-0.09225992113351822,-0.04645194485783577,0.15044128894805908,-0.21732264757156372,0.28437143564224243,-0.2665709853172302,0.2882380783557892,0.22249183058738708,-0.052759040147066116,-0.1200934648513794,-0.03501330688595772,-0.097571462392807 ,-0.12546227872371674,-0.15951892733573914,-0.0388270765542984,0.18754015862941742,-0.16775591671466827,-0.24655738472938538,-0.28310835361480713,-0.020981580018997192,0.009854764677584171,-0.17701463401317596,-0.19499319791793823,0.046816736459732056,-0.03591006621718407,-0.0839812159538269,-0.0649729073047638,0.2468220293521881,0.060016900300979614,-0.16779978573322296,0.026406895369291306,0.0926237553358078,-0.1881830245256424,0.11423873901367188,-0.300096333026886,0.2325722873210907,-0.05620579421520233,0.020356476306915283,-0.21710273623466492,0.23115618526935577,0.2465677708387375,-7.510185241699219e-06,0.10082539170980453,-0.022696541622281075 ,0.07555973529815674,-0.0029259920120239258,-0.08789914846420288,0.06678077578544617,-0.11083845794200897,0.11010000109672546,-0.14982634782791138,0.12075316905975342,-0.2766430675983429,0.013024389743804932,0.18159812688827515,-0.20200279355049133,0.2637675702571869,-0.1856893002986908,0.2882818281650543,0.05304515361785889,-0.15297894179821014,0.07341468334197998,0.05268138647079468,0.1067940890789032,-0.2661813795566559,-0.2009473443031311,0.1843600869178772,0.2517976462841034,-0.07343396544456482,-0.051110416650772095,-0.23432010412216187,0.16746872663497925,-0.2205146849155426,-0.017525076866149902,0.20926335453987122,-0.2141496241092682 ,0.06582912802696228,0.2796666920185089,-0.2556927502155304,0.0023079216480255127,0.2043982446193695,0.13894453644752502,0.06556430459022522,0.29767414927482605,0.24966773390769958,-0.16670267283916473,-0.1203770637512207,-0.06570860743522644,-0.015925198793411255,0.17675906419754028,-0.014884740114212036,-0.05300724506378174,0.26490333676338196,0.15243005752563477,-0.07319167256355286,0.2353842556476593,0.23596063256263733,0.1602974534034729,-0.04174882173538208,-0.11559568345546722,-0.06235519051551819,0.21069613099098206,-0.19532959163188934,-0.2486409693956375,0.032513976097106934,-0.2712400257587433,-0.19435247778892517,-0.23200613260269165 ,-0.1299392580986023,-0.06208275258541107,-0.21278081834316254,0.04117914289236069,-0.25799769163131714,0.0023174630478024483,-0.19175797700881958,0.02903696894645691,-0.3028421998023987,0.016345679759979248,-0.24767392873764038,0.2033931314945221,-0.36241284012794495,0.1515057384967804,0.13206014037132263,0.15829482674598694,-0.21012049913406372,0.2088232934474945,-0.016727611422538757,-0.24573293328285217,0.20467910170555115,0.11925628036260605,-0.3039346933364868,-0.11097411066293716,0.34144315123558044,-0.007939159870147705,-0.20167969167232513,0.059701401740312576,0.20017050206661224,0.18135693669319153,-0.008151531219482422,0.029283329844474792 ,0.07638216018676758,0.07996532320976257,-0.30373215675354004,-0.2700393795967102,0.11718190461397171,0.05212600901722908,0.2795381247997284,-0.25668495893478394,-0.100021593272686,0.1293344497680664,-0.026776641607284546,0.02524423599243164,0.07603725790977478,0.29519766569137573,-0.029521822929382324,-0.19500072300434113,0.06506577134132385,-0.011876672506332397,0.0938519686460495,0.2426283210515976,0.10203439742326736,0.03793451562523842,-0.15799765288829803,-0.17324526607990265,0.25468015670776367,0.1901901364326477,-0.22690120339393616,-0.09443645179271698,-0.0595262236893177,0.22636333107948303,-0.2613427937030792,0.21909776329994202; hout << 0.3285340666770935 ,0.2858171761035919 ,-0.36366742849349976 ,-0.2632009983062744 ,-0.25631460547447205 ,0.33468252420425415 ,0.002162247896194458 ,0.1081397533416748 ,-0.19566167891025543 ,-0.007266071625053883 ,0.1744336485862732 ,-0.19491273164749146 ,-0.16939763724803925 ,0.1573415994644165 ,0.2356991171836853 ,-0.1462659239768982 ,0.09851181507110596 ,-0.21499931812286377 ,-0.013007339090108871 ,-0.26934152841567993 ,-0.10125408321619034 ,0.16949352622032166 ,-0.2570975124835968 ,-0.21437735855579376 ,0.2278641164302826 ,0.2520971894264221 ,-0.38587644696235657 ,-0.3990364372730255 ,0.24998146295547485 ,-0.3257754445075989 ,-0.41329723596572876 ,-0.26551106572151184; b1 << 0.6920363306999207 ,0.9509658217430115 ,-1.7145336866378784 ,0.4119643270969391 ,1.0741286277770996 ,0.8546265363693237 ,-0.07467586547136307 ,0.93145751953125 ,0.5193935036659241 ,-0.8871728777885437 ,0.593039333820343 ,1.6031073331832886 ,-0.33494266867637634 ,-0.8010779023170471 ,-1.087764859199524 ,1.1554406881332397 ,0.6632958650588989 ,-0.224932461977005 ,0.26702749729156494 ,0.5859951972961426 ,-0.31409698724746704 ,-1.1118980646133423 ,-1.6770726442337036 ,-1.2263047695159912 ,2.018333911895752 ,-2.0880801677703857 ,-1.0489267110824585 ,0.7445360422134399 ,0.4031659960746765 ,-1.0887231826782227 ,1.5438745021820068 ,-0.4563482999801636; b2 << -0.10466054826974869 ,-0.7642630338668823 ,-1.4564176797866821 ,-0.528777003288269 ,-0.7297643423080444 ,0.2625555098056793 ,0.389851450920105 ,-0.33048292994499207 ,-1.20063054561615 ,-1.912178635597229 ,0.31253743171691895 ,0.6883504390716553 ,-0.04988760128617287 ,2.26581072807312 ,0.13501279056072235 ,1.132785677909851 ,-1.8237234354019165 ,-1.5844906568527222 ,0.26375624537467957 ,-0.23789723217487335 ,0.17283980548381805 ,0.3692796230316162 ,0.09335066378116608 ,-1.0231001377105713 ,1.2738454341888428 ,1.44853675365448 ,0.9071134924888611 ,8.9274239144288e-05 ,-0.6323830485343933 ,-0.4208582937717438 ,-1.1864360570907593 ,-1.3916414976119995; b3 << -1.963319182395935 ,-0.4028509557247162 ,0.3184174597263336 ,0.1579766422510147 ,0.1897633820772171 ,0.866980791091919 ,-0.45353031158447266 ,-0.6562485098838806 ,0.5865635275840759 ,0.5033581852912903 ,-0.14371006190776825 ,0.050810977816581726 ,-0.5131177306175232 ,0.5688209533691406 ,-1.1428403854370117 ,-0.3598397970199585 ,-1.3594286441802979 ,-1.0192245244979858 ,-0.2365882694721222 ,0.5294732451438904 ,1.530857801437378 ,1.2039998769760132 ,-1.0573883056640625 ,-0.7962622046470642 ,0.7248114347457886 ,-0.36519983410835266 ,-0.07752024382352829 ,0.767806887626648 ,0.2635451555252075 ,-2.3236680030822754 ,0.06150589883327484 ,1.0375205278396606; bout << -0.3124803602695465; /************************************ *** Program is operating! *************************************/ while(1) { // if(timer_while==1000 && OPERATING_MODE==5) { // //i2c // read_field(i2c_slave_addr1); // if(DIR_VALVE_ENC < 0) value = 1023 - value; // // if(LED==1) { // // LED=0; // // } else // // LED = 1; // timer_while = 0; // } // timer_while ++; t.reset(); t.start(); //X = (((Input*h1+b1.transpose())*h2+b2.transpose())*h3+b3.transpose())*hout+bout.transpose(); // Input << // input_array[0],input_array[1],input_array[2],input_array[3],input_array[4]; X = Input*h1+b1.transpose(); for(int i=0; i<32; i++){ if(X(i)<0) X(i) = 0; } X = X*h2+b2.transpose(); for(int i=0; i<32; i++){ if(X(i)<0) X(i) = 0; } X = X*h3+b3.transpose(); for(int i=0; i<32; i++){ if(X(i)<0) X(i) = 0; } X = X*hout+bout.transpose(); NNoutput=1.0f/(1.0f+exp(-X(0,0))); t.stop(); printf("NNoutput : %f\n", NNoutput); printf("time : %f\n", t.read()); wait(1); //CAN_TX_PWM((int16_t) (t.read() * 1000000.0f)); //1500 // PWM_out = NNoutput * 24000.0f - 12000.0f; // // // if (PWM_out>0.0f) { // dtc_v=0.0f; // dtc_w=PWM_out; // } else { // dtc_v=-PWM_out; // dtc_w=0.0f; // } // // //pwm // TIM4->CCR2 = (PWM_ARR)*(1.0f-dtc_v); // TIM4->CCR1 = (PWM_ARR)*(1.0f-dtc_w); } } float DDV_JOINT_POS_FF(float REF_JOINT_VEL) { int i = 0; float Ref_Valve_Pos_FF = 0.0f; for(i=0; i<VALVE_POS_NUM; i++) { if(REF_JOINT_VEL >= min(JOINT_VEL[i],JOINT_VEL[i+1]) && REF_JOINT_VEL <= max(JOINT_VEL[i],JOINT_VEL[i+1])) { if(i==0) { if(JOINT_VEL[i+1] == JOINT_VEL[i]) { Ref_Valve_Pos_FF = (float) VALVE_CENTER; } else { Ref_Valve_Pos_FF = ((float) 10/(JOINT_VEL[i+1] - JOINT_VEL[i]) * (REF_JOINT_VEL - JOINT_VEL[i])) + (float) VALVE_CENTER; } } else { if(JOINT_VEL[i+1] == JOINT_VEL[i-1]) { Ref_Valve_Pos_FF = (float) VALVE_CENTER; } else { Ref_Valve_Pos_FF = ((float) 10*(ID_index_array[i+1] - ID_index_array[i-1])/(JOINT_VEL[i+1] - JOINT_VEL[i-1]) * (REF_JOINT_VEL - JOINT_VEL[i-1])) + (float) VALVE_CENTER + (float) (10*ID_index_array[i-1]); } } break; } } if(REF_JOINT_VEL > max(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { Ref_Valve_Pos_FF = (float) VALVE_MAX_POS; } else if(REF_JOINT_VEL < min(JOINT_VEL[VALVE_POS_NUM-1], JOINT_VEL[VALVE_POS_NUM-2])) { Ref_Valve_Pos_FF = (float) VALVE_MIN_POS; } Ref_Valve_Pos_FF = (float) VELOCITY_COMP_GAIN * 0.01f * (float) (Ref_Valve_Pos_FF - (float) VALVE_CENTER); return Ref_Valve_Pos_FF; } void VALVE_POS_CONTROL(float REF_VALVE_POS) { int i = 0; if(REF_VALVE_POS > VALVE_MAX_POS) { REF_VALVE_POS = VALVE_MAX_POS; } else if(REF_VALVE_POS < VALVE_MIN_POS) { REF_VALVE_POS = VALVE_MIN_POS; } valve_pos_err = REF_VALVE_POS - value; valve_pos_err_diff = valve_pos_err - valve_pos_err_old; valve_pos_err_old = valve_pos_err; valve_pos_err_sum += valve_pos_err; if (valve_pos_err_sum > 1000) valve_pos_err_sum = 1000; if (valve_pos_err_sum<-1000) valve_pos_err_sum = -1000; VALVE_PWM_RAW_FB = P_GAIN_VALVE_POSITION * valve_pos_err + I_GAIN_VALVE_POSITION * valve_pos_err_sum + D_GAIN_VALVE_POSITION * valve_pos_err_diff; for(i=0; i<24; i++) { if(REF_VALVE_POS >= min(VALVE_POS_VS_PWM[i],VALVE_POS_VS_PWM[i+1]) && REF_VALVE_POS <= max(VALVE_POS_VS_PWM[i],VALVE_POS_VS_PWM[i+1])) { if(i==0) { VALVE_PWM_RAW_FF = (float) 1000.0f / (float) (VALVE_POS_VS_PWM[i+1] - VALVE_POS_VS_PWM[i]) * ((float) REF_VALVE_POS - VALVE_POS_VS_PWM[i]); } else { VALVE_PWM_RAW_FF = (float) 1000.0f* (float) (ID_index_array[i+1] - ID_index_array[i-1])/(VALVE_POS_VS_PWM[i+1] - VALVE_POS_VS_PWM[i-1]) * ((float) REF_VALVE_POS - VALVE_POS_VS_PWM[i-1]) + 1000.0f * (float) ID_index_array[i-1]; } break; } } Vout.ref = VALVE_PWM_RAW_FF + VALVE_PWM_RAW_FB; } #define LT_MAX_IDX 57 float LT_PWM_duty[LT_MAX_IDX] = {-100.0f, -80.0f, -60.0f, -50.0f, -40.0f, -35.0f, -30.0f, -25.0f, -20.0f, -19.0f, -18.0f, -17.0f, -16.0f, -15.0f, -14.0f, -13.0f, -12.0f, -11.0f, -10.0f, -9.0f, -8.0f, -7.0f, -6.0f, -5.0f, -4.0f, -3.0f, -2.0f, -1.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f, 60.0f, 80.0f, 100.0f }; // duty float LT_Voltage_Output[LT_MAX_IDX] = {-321.4f, -291.3f, -261.5f, -246.8f, -231.7f, -223.9f, -216.1f, -207.9f, -198.8f, -196.9f, -195.0f, -192.5f, -188.8f, -184.5f, -180.2f, -175.9f, -171.5f, -166.3f, -161.0f, -156.0f, -149.5f, -139.0f, -126.0f, -107.0f, -87.5f, -64.0f, -38.5f, -9.4f, 0.0f, 12.0f, 43.5f, 69.0f, 94.0f, 114.0f, 132.0f, 146.0f, 155.5f, 162.3f, 168.2f, 173.1f, 178.2f, 182.8f, 187.4f, 191.8f, 196.0f, 199.7f, 201.9f, 203.8f, 205.6f, 214.6f, 222.5f, 230.4f, 238.2f, 253.3f, 268.0f, 297.6f, 327.7f }; // mV float PWM_duty_byLT(float Ref_V) { float PWM_duty = 0.0f; if(Ref_V<LT_Voltage_Output[0]) { PWM_duty = (Ref_V-LT_Voltage_Output[0])/1.5f+LT_PWM_duty[0]; } else if (Ref_V>=LT_Voltage_Output[LT_MAX_IDX-1]) { PWM_duty = (Ref_V-LT_Voltage_Output[LT_MAX_IDX-1])/1.5f+LT_PWM_duty[LT_MAX_IDX-1]; } else { int idx = 0; for(idx=0; idx<LT_MAX_IDX-1; idx++) { float ini_x = LT_Voltage_Output[idx]; float fin_x = LT_Voltage_Output[idx+1]; float ini_y = LT_PWM_duty[idx]; float fin_y = LT_PWM_duty[idx+1]; if(Ref_V>=ini_x && Ref_V<fin_x) { PWM_duty = (fin_y-ini_y)/(fin_x-ini_x)*(Ref_V-ini_x) + ini_y; break; } } } return PWM_duty; } /******************************************************************************* TIMER INTERRUPT *******************************************************************************/ float FREQ_TMR4 = (float)FREQ_20k; float DT_TMR4 = (float)DT_20k; long CNT_TMR4 = 0; int TMR4_FREQ_10k = (int)FREQ_10k; extern "C" void TIM4_IRQHandler(void) { if (TIM4->SR & TIM_SR_UIF ) { /******************************************************* *** Sensor Read & Data Handling ********************************************************/ //Encoder if (CNT_TMR4 % (int) ((int) FREQ_TMR4/TMR4_FREQ_10k) == 0) { ENC_UPDATE(); } // for(int i=0; i<10; i++){ // position_array[i] = position_array[i+1]; // } // position_array[10] = (pos.ref/(float)(ENC_PULSE_PER_POSITION)+10.0f)/90.0f; // // for(int i=0; i<5; i++){ // input_array[i] = position_array[2*i+2] - (pos.ref/(float)(ENC_PULSE_PER_POSITION)+10.0f)/90.0f; // } ADC1->CR2 |= 0x40000000; if (SENSING_MODE == 0) { // Torque Sensing (0~210)bar ============================================= float pres_A_new = (((float) ADC1->DR) - 2047.5f); double alpha_update_ft = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 100.0f)); // f_cutoff : 200Hz pres_A.sen = (1.0f - alpha_update_ft) * pres_A.sen + alpha_update_ft * pres_A_new; torq.sen = pres_A.sen / TORQUE_SENSOR_PULSE_PER_TORQUE; } else if (SENSING_MODE == 1) { // Pressure Sensing (0~210)bar ============================================= float pres_A_new = (((float)ADC1->DR) - PRES_A_NULL); float pres_B_new = (((float)ADC2->DR) - PRES_B_NULL); double alpha_update_pres = 1.0f / (1.0f + FREQ_TMR4 / (2.0f * 3.14f * 200.0f)); // f_cutoff : 500Hz pres_A.sen = (1.0f - alpha_update_pres) * pres_A.sen + alpha_update_pres * pres_A_new; pres_B.sen = (1.0f - alpha_update_pres) * pres_B.sen + alpha_update_pres * pres_B_new; CUR_PRES_A_BAR = pres_A.sen / PRES_SENSOR_A_PULSE_PER_BAR; CUR_PRES_B_BAR = pres_B.sen / PRES_SENSOR_B_PULSE_PER_BAR; if ((OPERATING_MODE & 0x01) == 0) { // Rotary Actuator torq.sen = (PISTON_AREA_A * CUR_PRES_A_BAR - PISTON_AREA_B * CUR_PRES_B_BAR) * 0.0001f; // mm^3*bar >> Nm } else if ((OPERATING_MODE & 0x01) == 1) { // Linear Actuator torq.sen = (PISTON_AREA_A * CUR_PRES_A_BAR - PISTON_AREA_B * CUR_PRES_B_BAR) * 0.1f; // mm^2*bar >> N } } // //Pressure sensor A // ADC1->CR2 |= 0x40000000; // adc _ 12bit // //while((ADC1->SR & 0b10)); // float alpha_update_pres_A = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); // float pres_A_new = ((float)ADC1->DR); // pres_A.sen = pres_A.sen*(1.0f-alpha_update_pres_A)+pres_A_new*(alpha_update_pres_A); // torq.sen = - (pres_A.sen-2048.0f); //pulse -2047~2047 //SW just changed the sign to correct the direction of loadcell on LIGHT. Correct later. // // // //Pressure sensor B // float alpha_update_pres_B = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*100.0f)); // float pres_B_new = ((float)ADC2->DR); // pres_B.sen = pres_B.sen*(1.0f-alpha_update_pres_B)+pres_B_new*(alpha_update_pres_B); // //torq.sen = pres_A.sen * (float) PISTON_AREA_A - pres_B.sen * (float) PISTON_AREA_B; //Current //ADC3->CR2 |= 0x40000000; // adc _ 12bit //int raw_cur = ADC3->DR; //while((ADC3->SR & 0b10)); float alpha_update_cur = 1.0f/(1.0f + FREQ_TMR4/(2.0f*3.14f*500.0f)); // f_cutoff : 500Hz float cur_new = ((float)ADC3->DR-2048.0f)*20.0f/4096.0f; // unit : mA cur.sen=cur.sen*(1.0f-alpha_update_cur)+cur_new*(alpha_update_cur); //cur.sen = raw_cur; CNT_TMR4++; } TIM4->SR = 0x0; // reset the status register } int j =0; float FREQ_TMR3 = (float)FREQ_5k; float DT_TMR3 = (float)DT_5k; int cnt_trans = 0; double VALVE_POS_RAW_FORCE_FB_LOGGING = 0.0f; int can_rest =0; extern "C" void TIM3_IRQHandler(void) { if (TIM3->SR & TIM_SR_UIF ) { if (((OPERATING_MODE&0b110)>>1) == 0) { K_v = 0.4f; // Moog (LPM >> mA) , 100bar mV_PER_mA = 500.0f; // 5000mV/10mA mV_PER_pulse = 0.5f; // 5000mV/10000pulse mA_PER_pulse = 0.001f; // 10mA/10000pulse } else if (((OPERATING_MODE&0b110)>>1) == 1) { K_v = 0.5f; // KNR (LPM >> mA) , 100bar mV_PER_mA = 166.6666f; // 5000mV/30mA mV_PER_pulse = 0.5f; // 5000mV/10000pulse mA_PER_pulse = 0.003f; // 30mA/10000pulse } if(MODE_POS_FT_TRANS == 1) { alpha_trans = (float)(1.0f - cos(3.141592f * (float)cnt_trans * DT_TMR3 /3.0f))/2.0f; cnt_trans++; torq.err_sum = 0; if((float)cnt_trans * DT_TMR3 > 3.0f) MODE_POS_FT_TRANS = 2; } else if(MODE_POS_FT_TRANS == 3) { alpha_trans = (float)(1.0f + cos(3.141592f * (float)cnt_trans * DT_TMR3 /3.0f))/2.0f; cnt_trans++; torq.err_sum = 0; if((float) cnt_trans * DT_TMR3 > 3.0f ) MODE_POS_FT_TRANS = 0; } else if(MODE_POS_FT_TRANS == 2) { alpha_trans = 1.0f; cnt_trans = 0; } else { alpha_trans = 0.0f; cnt_trans = 0; } int UTILITY_MODE = 0; int CONTROL_MODE = 0; if (CONTROL_UTILITY_MODE >= 20 || CONTROL_UTILITY_MODE == 0) { UTILITY_MODE = CONTROL_UTILITY_MODE; CONTROL_MODE = MODE_NO_ACT; } else { CONTROL_MODE = CONTROL_UTILITY_MODE; UTILITY_MODE = MODE_NO_ACT; } // UTILITY MODE ------------------------------------------------------------ switch (UTILITY_MODE) { case MODE_NO_ACT: { break; } case MODE_TORQUE_SENSOR_NULLING: { // DAC Voltage reference set if (TMR3_COUNT_TORQUE_NULL < TMR_FREQ_5k * 2) { CUR_TORQUE_sum += torq.sen; if (TMR3_COUNT_TORQUE_NULL % 10 == 0) { CUR_TORQUE_mean = CUR_TORQUE_sum / 10.0f; CUR_TORQUE_sum = 0; TORQUE_VREF += 0.0003f * (0.0f - CUR_TORQUE_mean); if (TORQUE_VREF > 3.3f) TORQUE_VREF = 3.3f; if (TORQUE_VREF < 0.0f) TORQUE_VREF = 0.0f; //spi_eeprom_write(RID_TORQUE_SENSOR_VREF, (int16_t) (TORQUE_VREF * 1000.0)); dac_1 = TORQUE_VREF / 3.3f; } } else { CONTROL_UTILITY_MODE = MODE_NO_ACT; TMR3_COUNT_TORQUE_NULL = 0; CUR_TORQUE_sum = 0; CUR_TORQUE_mean = 0; ROM_RESET_DATA(); dac_1 = TORQUE_VREF / 3.3f; } TMR3_COUNT_TORQUE_NULL++; break; } // case MODE_VALVE_NULLING_AND_DEADZONE_SETTING: { // if (TMR3_COUNT_DEADZONE == 0) { // if (pos_plus_end == pos_minus_end) need_enc_init = true; // else temp_time = 0; // } // if (need_enc_init) { // if (TMR3_COUNT_DEADZONE < (int) (0.5f * (float) TMR_FREQ_5k)) { // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; // pos_plus_end = pos.sen; // } else if (TMR3_COUNT_DEADZONE < TMR_FREQ_5k) { // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; // pos_minus_end = pos.sen; // } else if (TMR3_COUNT_DEADZONE == TMR_FREQ_5k) need_enc_init = false; // temp_time = TMR_FREQ_5k; // } // // if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + TMR_FREQ_5k)) { // V_out = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen); // VALVE_CENTER = VALVE_DEADZONE_PLUS = VALVE_DEADZONE_MINUS = 0; // // } else if (temp_time <= TMR3_COUNT_DEADZONE && TMR3_COUNT_DEADZONE < (temp_time + (int) (1.9f * (float) TMR_FREQ_5k))) { // V_out = 0; // CUR_VELOCITY_sum += CUR_VELOCITY; // } else if (TMR3_COUNT_DEADZONE == (temp_time + 2 * TMR_FREQ_5k)) { // if (CUR_VELOCITY_sum == 0) DZ_dir = 1; // else if (CUR_VELOCITY_sum > 0) DZ_dir = 1; // else if (CUR_VELOCITY_sum < 0) DZ_dir = -1; // else DZ_temp_cnt2 = DZ_end; // CUR_VELOCITY_sum = 0; // } else if (TMR3_COUNT_DEADZONE > (temp_time + 2 * TMR_FREQ_5k)) { // if (TMR3_COUNT_DEADZONE > (temp_time + 10 * TMR_FREQ_5k)) DZ_temp_cnt2 = DZ_end; // // // Position of Dead Zone // // (CUR_VELOCITY < 0) (CUR_VELOCITY == 0) (CUR_VELOCITY > 0) // // | / | / |/ // // | ______/ ___|___/ ______/| // // |/ / | / | // // /| / | / | // // 0V 0V 0V // // if (DZ_temp_cnt2 < DZ_end) { // if (TMR3_COUNT_DEADZONE % 20 != 0) { // CUR_VELOCITY_sum += CUR_VELOCITY; // } else { // V_out -= DZ_dir; // if (CUR_VELOCITY_sum * DZ_dir < 0) DZ_temp_cnt++; // CUR_VELOCITY_sum = 0; // } // if (DZ_temp_cnt == 5) { // if (DZ_dir >= 0) VALVE_DEADZONE_MINUS = (int16_t) V_out; // else VALVE_DEADZONE_PLUS = (int16_t) V_out; // DZ_dir = -DZ_dir; // DZ_temp_cnt = 0; // DZ_temp_cnt2++; // } // } else { // TMR3_COUNT_DEADZONE = -1; // VALVE_CENTER = VALVE_DEADZONE_PLUS / 2 + VALVE_DEADZONE_MINUS / 2; // if (VALVE_DEADZONE_PLUS < VALVE_DEADZONE_MINUS) { // VALVE_DEADZONE_PLUS = VALVE_CENTER; // VALVE_DEADZONE_MINUS = VALVE_CENTER; // } // V_out = 0; // // ROM_RESET_DATA(); // // //spi_eeprom_write(RID_VALVE_DEADZONE_PLUS, VALVE_DEADZONE_PLUS); // //spi_eeprom_write(RID_VALVE_DEADZONE_MINUS, VALVE_DEADZONE_MINUS); // // CONTROL_MODE = MODE_NO_ACT; // DZ_temp_cnt2 = 0; // } // } // TMR3_COUNT_DEADZONE++; // break; // } case MODE_FIND_HOME: { if (FINDHOME_STAGE == FINDHOME_INIT) { cnt_findhome = 0; cnt_vel_findhome = 0; //REFERENCE_MODE = MODE_REF_NO_ACT; // Stop taking reference data from PODO pos.ref = pos.sen; vel.ref = 0.0f; FINDHOME_STAGE = FINDHOME_GOTOLIMIT; } else if (FINDHOME_STAGE == FINDHOME_GOTOLIMIT) { int cnt_check_enc = (TMR_FREQ_5k/500); if(cnt_findhome%cnt_check_enc == 0) { FINDHOME_POSITION = pos.sen; FINDHOME_VELOCITY = FINDHOME_POSITION - FINDHOME_POSITION_OLD; FINDHOME_POSITION_OLD = FINDHOME_POSITION; } cnt_findhome++; if (abs(FINDHOME_VELOCITY) <= 1) { cnt_vel_findhome = cnt_vel_findhome + 1; } else { cnt_vel_findhome = 0; } if ((cnt_vel_findhome < 3*TMR_FREQ_5k) && cnt_findhome < 10*TMR_FREQ_5k) { // wait for 3sec //REFERENCE_MODE = MODE_REF_NO_ACT; if (HOMEPOS_OFFSET > 0) pos.ref = pos.ref + 2.0f; else pos.ref = pos.ref - 2.0f; // pos.err = pos.ref_home_pos - pos.sen; // float VALVE_POS_RAW_POS_FB = 0.0f; // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * pos.err/(float) ENC_PULSE_PER_POSITION * 0.01f; // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; // VALVE_POS_CONTROL(valve_pos.ref); CONTROL_MODE = MODE_JOINT_CONTROL; alpha_trans = 0.0f; } else { ENC_SET(HOMEPOS_OFFSET); INIT_REF_POS = HOMEPOS_OFFSET; REF_POSITION = 0; REF_VELOCITY = 0; FINDHOME_POSITION = 0; FINDHOME_POSITION_OLD = 0; FINDHOME_VELOCITY = 0; cnt_findhome = 0; cnt_vel_findhome = 0; FINDHOME_STAGE = FINDHOME_ZEROPOSE; } } else if (FINDHOME_STAGE == FINDHOME_ZEROPOSE) { int T_move = 2*TMR_FREQ_5k; pos.ref = (0.0f - (float)INIT_REF_POS)*0.5f*(1.0f - cos(3.14159f * (float)cnt_findhome / (float)T_move)) + (float)INIT_REF_POS; vel.ref = 0.0f; // input for position control CONTROL_MODE = MODE_JOINT_CONTROL; alpha_trans = 0.0f; // pos.err = pos.ref - (float)pos.sen; // float VALVE_POS_RAW_POS_FB = 0.0f; // VALVE_POS_RAW_POS_FB = (float) P_GAIN_JOINT_POSITION * 0.01f * pos.err/(float) ENC_PULSE_PER_POSITION; // valve_pos.ref = VALVE_POS_RAW_POS_FB + (float) VALVE_CENTER; // VALVE_POS_CONTROL(valve_pos.ref); cnt_findhome++; if (cnt_findhome >= T_move) { //REFERENCE_MODE = MODE_REF_DIRECT; cnt_findhome = 0; pos.ref = 0.0f; vel.ref = 0.0f; pos.ref_home_pos = 0.0f; vel.ref_home_pos = 0.0f; FINDHOME_STAGE = FINDHOME_INIT; CONTROL_UTILITY_MODE = MODE_JOINT_CONTROL; } } break; } // case MODE_VALVE_GAIN_SETTING: { // if (TMR3_COUNT_FLOWRATE == 0) { // if (pos_plus_end == pos_minus_end) need_enc_init = true; // else { // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; // temp_time = (int) (0.5f * (float) TMR_FREQ_5k); // } // } // if (need_enc_init) { // if (TMR3_COUNT_FLOWRATE < (int) (0.5f * (float) TMR_FREQ_5k)) { // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; // pos_plus_end = pos.sen; // } else if (TMR3_COUNT_FLOWRATE < TMR_FREQ_5k) { // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; // pos_minus_end = pos.sen; // } else if (TMR3_COUNT_FLOWRATE == TMR_FREQ_5k) { // need_enc_init = false; // check_vel_pos_init = (int) (0.9f * (float) (pos_plus_end - pos_minus_end)); // check_vel_pos_fin = (int) (0.95f * (float) (pos_plus_end - pos_minus_end)); // check_vel_pos_interv = check_vel_pos_fin - check_vel_pos_init; // } // temp_time = TMR_FREQ_5k; // } // TMR3_COUNT_FLOWRATE++; // if (TMR3_COUNT_FLOWRATE > temp_time) { // if (flag_flowrate % 2 == 0) { // (+) // VALVE_VOLTAGE = 1000.0f * (float) (flag_flowrate / 2 + 1); // V_out = VALVE_VOLTAGE; // if (pos.sen > (pos_minus_end + check_vel_pos_init) && pos.sen < (pos_minus_end + check_vel_pos_fin)) { // fl_temp_cnt++; // } else if (pos.sen >= (pos_minus_end + check_vel_pos_fin) && CUR_VELOCITY == 0) { // VALVE_GAIN_LPM_PER_V[flag_flowrate] = 0.95873f * 0.5757f * (float) TMR_FREQ_5k / 10000.0 * (float) check_vel_pos_interv / (float) fl_temp_cnt / VALVE_VOLTAGE; // 0.9587=6*pi/65536*10000 0.5757=0.02525*0.02*0.0095*2*60*1000 // // VALVE_GAIN_LPM_PER_V[flag_flowrate] = (float) TMR_FREQ_10k * (float) check_vel_pos_interv / (float) fl_temp_cnt / VALVE_VOLTAGE; // PULSE/sec // fl_temp_cnt2++; // } // } else if (flag_flowrate % 2 == 1) { // (-) // VALVE_VOLTAGE = -1. * (float) (flag_flowrate / 2 + 1); // V_out = VALVE_VOLTAGE; // if (pos.sen < (pos_plus_end - check_vel_pos_init) && pos.sen > (pos_plus_end - check_vel_pos_fin)) { // fl_temp_cnt++; // } else if (pos.sen <= (pos_plus_end - check_vel_pos_fin) && CUR_VELOCITY == 0) { // VALVE_GAIN_LPM_PER_V[flag_flowrate] = 0.95873f * 0.5757f * (float) TMR_FREQ_5k / 10000.0f * (float) check_vel_pos_interv / (float) fl_temp_cnt / (-VALVE_VOLTAGE); // // VALVE_GAIN_LPM_PER_V[flag_flowrate] = (float) TMR_FREQ_10k * (float) check_vel_pos_interv / (float) fl_temp_cnt / (-VALVE_VOLTAGE); // PULSE/sec // fl_temp_cnt2++; // } // } // if (fl_temp_cnt2 == 100) { // // ROM_RESET_DATA(); // // //spi_eeprom_write(RID_VALVE_GAIN_PLUS_1 + flag_flowrate, (int16_t) (VALVE_GAIN_LPM_PER_V[flag_flowrate] * 100.0f)); // cur_vel_sum = 0; // fl_temp_cnt = 0; // fl_temp_cnt2 = 0; // flag_flowrate++; // } // if (flag_flowrate == 10) { // V_out = 0; // flag_flowrate = 0; // TMR3_COUNT_FLOWRATE = 0; // valve_gain_repeat_cnt++; // if (valve_gain_repeat_cnt >= 1) { // CONTROL_MODE = MODE_NO_ACT; // valve_gain_repeat_cnt = 0; // } // // } // break; // } // // } case MODE_PRESSURE_SENSOR_NULLING: { // DAC Voltage reference set if (TMR3_COUNT_PRES_NULL < TMR_FREQ_5k * 2) { CUR_PRES_A_sum += pres_A.sen; CUR_PRES_B_sum += pres_B.sen; if (TMR3_COUNT_PRES_NULL % 10 == 0) { CUR_PRES_A_mean = CUR_PRES_A_sum / 10.0f; CUR_PRES_B_mean = CUR_PRES_B_sum / 10.0f; CUR_PRES_A_sum = 0; CUR_PRES_B_sum = 0; float VREF_NullingGain = 0.0003f; PRES_A_VREF = PRES_A_VREF + VREF_NullingGain * CUR_PRES_A_mean; PRES_B_VREF = PRES_B_VREF + VREF_NullingGain * CUR_PRES_B_mean; if (PRES_A_VREF > 3.3f) PRES_A_VREF = 3.3f; if (PRES_A_VREF < 0.0f) PRES_A_VREF = 0.0f; if (PRES_B_VREF > 3.3f) PRES_B_VREF = 3.3f; if (PRES_B_VREF < 0.0f) PRES_B_VREF = 0.0f; dac_1 = PRES_A_VREF / 3.3f; dac_2 = PRES_B_VREF / 3.3f; } } else { CONTROL_UTILITY_MODE = MODE_NO_ACT; TMR3_COUNT_PRES_NULL = 0; CUR_PRES_A_sum = 0; CUR_PRES_B_sum = 0; CUR_PRES_A_mean = 0; CUR_PRES_B_mean = 0; ROM_RESET_DATA(); dac_1 = PRES_A_VREF / 3.3f; dac_2 = PRES_B_VREF / 3.3f; //pc.printf("nulling end"); } TMR3_COUNT_PRES_NULL++; break; } // case MODE_PRESSURE_SENSOR_CALIB: { // if (TMR3_COUNT_PRES_CALIB < 2 * TMR_FREQ_5k) { // V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; // if (TMR3_COUNT_PRES_CALIB >= TMR_FREQ_5k) { // CUR_PRES_A_sum += CUR_PRES_A; // } // } else if (TMR3_COUNT_PRES_CALIB < 4 * TMR_FREQ_5k) { // V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; // if (TMR3_COUNT_PRES_CALIB >= 3 * TMR_FREQ_5k) { // CUR_PRES_B_sum += CUR_PRES_B; // } // } else { // CONTROL_MODE = MODE_NO_ACT; // TMR3_COUNT_PRES_CALIB = 0; // V_out = 0; // PRES_SENSOR_A_PULSE_PER_BAR = CUR_PRES_A_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_A_NULL; // PRES_SENSOR_A_PULSE_PER_BAR = PRES_SENSOR_A_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); // PRES_SENSOR_B_PULSE_PER_BAR = CUR_PRES_B_sum / ((float) TMR_FREQ_5k - 1.0f) - PRES_B_NULL; // PRES_SENSOR_B_PULSE_PER_BAR = PRES_SENSOR_B_PULSE_PER_BAR / ((float) PRES_SUPPLY - 1.0f); // CUR_PRES_A_sum = 0; // CUR_PRES_B_sum = 0; // CUR_PRES_A_mean = 0; // CUR_PRES_B_mean = 0; // // ROM_RESET_DATA(); // // //spi_eeprom_write(RID_PRES_SENSOR_A_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_A_PULSE_PER_BAR * 100.0f)); // //spi_eeprom_write(RID_PRES_SENSOR_B_PULSE_PER_BAR, (int16_t) (PRES_SENSOR_B_PULSE_PER_BAR * 100.0f)); // } // TMR3_COUNT_PRES_CALIB++; // break; // } // case MODE_ROTARY_FRICTION_TUNING: { // if (TMR3_COUNT_ROTARY_FRIC_TUNE % (5 * TMR_FREQ_5k) == 0) freq_fric_tune = 4.0f + 3.0f * sin(2 * 3.14159f * 0.5f * TMR3_COUNT_ROTARY_FRIC_TUNE * 0.0001f * 0.05f); // V_out = PWM_out * sin(2 * 3.14159f * freq_fric_tune * TMR3_COUNT_ROTARY_FRIC_TUNE * 0.0001f); // if (V_out > 0) V_out = VALVE_VOLTAGE_LIMIT * 1000.0f; // else V_out = -VALVE_VOLTAGE_LIMIT * 1000.0f; // TMR3_COUNT_ROTARY_FRIC_TUNE++; // if (TMR3_COUNT_ROTARY_FRIC_TUNE > TUNING_TIME * TMR_FREQ_5k) { // TMR3_COUNT_ROTARY_FRIC_TUNE = 0; // V_out = 0.0f; // CONTROL_MODE = MODE_NO_ACT; // } // break; // } case MODE_DDV_POS_VS_PWM_ID: { CONTROL_MODE = MODE_VALVE_OPEN_LOOP; VALVE_ID_timer = VALVE_ID_timer + 1; if(VALVE_ID_timer < TMR_FREQ_5k*1) { Vout.ref = 3000.0f * sin(2.0f*3.14f*VALVE_ID_timer/TMR_FREQ_5k * 100.0f); } else if(VALVE_ID_timer < TMR_FREQ_5k*2) { Vout.ref = 1000.0f*(ID_index_array[ID_index]); } else if(VALVE_ID_timer == TMR_FREQ_5k*2) { VALVE_POS_TMP = 0; data_num = 0; } else if(VALVE_ID_timer < TMR_FREQ_5k*3) { data_num = data_num + 1; VALVE_POS_TMP = VALVE_POS_TMP + value; } else if(VALVE_ID_timer == TMR_FREQ_5k*3) { Vout.ref = 0.0f; } else { VALVE_POS_AVG[ID_index] = VALVE_POS_TMP / data_num; VALVE_ID_timer = 0; ID_index= ID_index +1; } if(ID_index>=25) { int i; VALVE_POS_AVG_OLD = VALVE_POS_AVG[0]; for(i=0; i<25; i++) { VALVE_POS_VS_PWM[i] = (int16_t) (VALVE_POS_AVG[i]); if(VALVE_POS_AVG[i] > VALVE_POS_AVG_OLD) { VALVE_MAX_POS = VALVE_POS_AVG[i]; VALVE_POS_AVG_OLD = VALVE_MAX_POS; } else if(VALVE_POS_AVG[i] < VALVE_POS_AVG_OLD) { VALVE_MIN_POS = VALVE_POS_AVG[i]; VALVE_POS_AVG_OLD = VALVE_MIN_POS; } } ROM_RESET_DATA(); ID_index = 0; CONTROL_UTILITY_MODE = MODE_NO_ACT; } break; } case MODE_DDV_DEADZONE_AND_CENTER: { CONTROL_MODE = MODE_VALVE_OPEN_LOOP; VALVE_DZ_timer = VALVE_DZ_timer + 1; if(first_check == 0) { if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; pos_plus_end = pos.sen; } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; pos_minus_end = pos.sen; } else if(VALVE_DZ_timer < (int) (3.0f * (float) TMR_FREQ_5k)) { Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; } else if(VALVE_DZ_timer < (int) (4.0f * (float) TMR_FREQ_5k)) { Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; data_num = data_num + 1; VALVE_POS_TMP = VALVE_POS_TMP + value; } else if(VALVE_DZ_timer == (int) (4.0f * (float) TMR_FREQ_5k)) { Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; DDV_POS_AVG = VALVE_POS_TMP / data_num; START_POS = pos.sen; VALVE_POS_TMP = 0; data_num = 0; } else if(VALVE_DZ_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = DDV_POS_AVG; VALVE_POS_CONTROL(valve_pos.ref); } else if(VALVE_DZ_timer < (int) (6.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = DDV_POS_AVG; VALVE_POS_CONTROL(valve_pos.ref); } else if(VALVE_DZ_timer == (int) (6.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = DDV_POS_AVG; VALVE_POS_CONTROL(valve_pos.ref); FINAL_POS = pos.sen; if((FINAL_POS - START_POS)>200) { DZ_case = 1; } else if((FINAL_POS - START_POS)<-200) { DZ_case = -1; } else { DZ_case = 0; } CAN_TX_PRES((int16_t) (DZ_case), (int16_t) (6)); first_check = 1; DZ_DIRECTION = 1; VALVE_DZ_timer = 0; Ref_Valve_Pos_Old = DDV_POS_AVG; DZ_NUM = 1; DZ_index = 1; } } else { if((DZ_case == -1 && DZ_NUM == 1) | (DZ_case == 1 && DZ_NUM == 1)) { if(VALVE_DZ_timer < (int) (1.0 * (float) TMR_FREQ_5k)) { Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; //CONTROL_MODE = MODE_JOINT_CONTROL; } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { START_POS = pos.sen; } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = Ref_Valve_Pos_Old - DZ_case * DZ_DIRECTION * 64 / DZ_index; if(valve_pos.ref <= VALVE_MIN_POS) { valve_pos.ref = VALVE_MIN_POS; } else if(valve_pos.ref >= VALVE_MAX_POS) { valve_pos.ref = VALVE_MAX_POS; } VALVE_POS_CONTROL(valve_pos.ref); } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { Ref_Valve_Pos_Old = valve_pos.ref; FINAL_POS = pos.sen; if((FINAL_POS - START_POS)>100) { DZ_DIRECTION = 1 * DZ_case; } else if((FINAL_POS - START_POS)<-100) { DZ_DIRECTION = -1 * DZ_case; } else { DZ_DIRECTION = 1 * DZ_case; } VALVE_DZ_timer = 0; DZ_index= DZ_index *2; if(DZ_index >= 128) { FIRST_DZ = valve_pos.ref; DZ_NUM = 2; Ref_Valve_Pos_Old = FIRST_DZ; DZ_index = 1; DZ_DIRECTION = 1; } } } else if((DZ_case == -1 && DZ_NUM == 2) | (DZ_case == 1 && DZ_NUM == 2)) { if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; //CONTROL_MODE = MODE_JOINT_CONTROL; } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { START_POS = pos.sen; } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = Ref_Valve_Pos_Old - DZ_case * DZ_DIRECTION * 64 / DZ_index; if(valve_pos.ref <= VALVE_MIN_POS) { valve_pos.ref = VALVE_MIN_POS; } else if(valve_pos.ref >= VALVE_MAX_POS) { valve_pos.ref = VALVE_MAX_POS; } VALVE_POS_CONTROL(valve_pos.ref); } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { Vout.ref = 0.0f; } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { Ref_Valve_Pos_Old = valve_pos.ref; FINAL_POS = pos.sen; if((FINAL_POS - START_POS)>100) { DZ_DIRECTION = 1 * DZ_case; } else if((FINAL_POS - START_POS)<-100) { DZ_DIRECTION = -1 * DZ_case; } else { DZ_DIRECTION = -1 * DZ_case; } VALVE_DZ_timer = 0; DZ_index= DZ_index * 2; if(DZ_index >= 128) { SECOND_DZ = valve_pos.ref; VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); first_check = 0; VALVE_DEADZONE_MINUS = (float) FIRST_DZ; VALVE_DEADZONE_PLUS = (float) SECOND_DZ; ROM_RESET_DATA(); CONTROL_UTILITY_MODE = MODE_NO_ACT; DZ_index = 1; } } } else if(DZ_case == 0 && DZ_NUM ==1) { if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; //CONTROL_MODE = MODE_JOINT_CONTROL; } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { START_POS = pos.sen; } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = Ref_Valve_Pos_Old - DZ_DIRECTION * 64 / DZ_index; if(valve_pos.ref <= VALVE_MIN_POS) { valve_pos.ref = VALVE_MIN_POS; } else if(valve_pos.ref >= VALVE_MAX_POS) { valve_pos.ref = VALVE_MAX_POS; } VALVE_POS_CONTROL(valve_pos.ref); } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { Ref_Valve_Pos_Old = valve_pos.ref; FINAL_POS = pos.sen; if((FINAL_POS - START_POS)>100) { DZ_DIRECTION = 1; } else if((FINAL_POS - START_POS)<-100) { DZ_DIRECTION = -1; } else { DZ_DIRECTION = 1; } VALVE_DZ_timer = 0; DZ_index= DZ_index *2; if(DZ_index >= 128) { FIRST_DZ = valve_pos.ref; DZ_NUM = 2; Ref_Valve_Pos_Old = FIRST_DZ; DZ_index = 1; DZ_DIRECTION = 1; } } } else { if(VALVE_DZ_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { Vout.ref = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; //pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; //CONTROL_MODE = MODE_JOINT_CONTROL; } else if(VALVE_DZ_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { START_POS = pos.sen; } else if(VALVE_DZ_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = Ref_Valve_Pos_Old + DZ_DIRECTION * 64 / DZ_index; if(valve_pos.ref <= VALVE_MIN_POS) { valve_pos.ref = VALVE_MIN_POS; } else if(valve_pos.ref > VALVE_MAX_POS) { valve_pos.ref = VALVE_MAX_POS - 1; } VALVE_POS_CONTROL(valve_pos.ref); } else if(VALVE_DZ_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { Vout.ref = 0.0f; } else if(VALVE_DZ_timer > (int) (2.0f * (float) TMR_FREQ_5k)) { Ref_Valve_Pos_Old = valve_pos.ref; FINAL_POS = pos.sen; if((FINAL_POS - START_POS)>100) { DZ_DIRECTION = 1; } else if((FINAL_POS - START_POS)<-100) { DZ_DIRECTION = -1; } else { DZ_DIRECTION = 1; } VALVE_DZ_timer = 0; DZ_index= DZ_index *2; if(DZ_index >= 128) { SECOND_DZ = valve_pos.ref; VALVE_CENTER = (int) (0.5f * (float) (FIRST_DZ) + 0.5f * (float) (SECOND_DZ)); first_check = 0; VALVE_DEADZONE_MINUS = (float) FIRST_DZ; VALVE_DEADZONE_PLUS = (float) SECOND_DZ; ROM_RESET_DATA(); CONTROL_UTILITY_MODE = MODE_NO_ACT; DZ_index = 1; } } } } break; } case MODE_DDV_POS_VS_FLOWRATE: { CONTROL_MODE = MODE_VALVE_OPEN_LOOP; VALVE_FR_timer = VALVE_FR_timer + 1; if(first_check == 0) { if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; //CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { Vout.ref = VALVE_VOLTAGE_LIMIT * 1000.0f; pos_plus_end = pos.sen; // CAN_TX_PRES((int16_t) (V_out), (int16_t) (7)); } else if(VALVE_FR_timer < (int) (2.0f * (float) TMR_FREQ_5k)) { Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; } else if(VALVE_FR_timer == (int) (2.0f * (float) TMR_FREQ_5k)) { // CAN_TX_PRES((int16_t) (V_out), (int16_t) (8)); Vout.ref = -VALVE_VOLTAGE_LIMIT * 1000.0f; pos_minus_end = pos.sen; first_check = 1; VALVE_FR_timer = 0; valve_pos.ref = (float) VALVE_CENTER; ID_index = 0; max_check = 0; min_check = 0; } } else { if(VALVE_FR_timer < (int) (1.0f * (float) TMR_FREQ_5k)) { //V_out = (float) P_GAIN_JOINT_POSITION * (0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen)/(float) ENC_PULSE_PER_POSITION; pos.ref = 0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end; CONTROL_MODE = MODE_JOINT_CONTROL; } else if(VALVE_FR_timer == (int) (1.0f * (float) TMR_FREQ_5k)) { data_num = 0; valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; VALVE_POS_CONTROL(valve_pos.ref); START_POS = pos.sen; } else if(VALVE_FR_timer < (int) (5.0f * (float) TMR_FREQ_5k)) { valve_pos.ref = 10.0f*((float) ID_index_array[ID_index]) + (float) VALVE_CENTER; VALVE_POS_CONTROL(valve_pos.ref); data_num = data_num + 1; if(abs(0.5f * (float) pos_plus_end + 0.5f * (float) pos_minus_end - (float) pos.sen) > 20000.0f) { FINAL_POS = pos.sen; one_period_end = 1; } } else if(VALVE_FR_timer == (int) (5.0f * (float) TMR_FREQ_5k)) { FINAL_POS = pos.sen; one_period_end = 1; V_out = 0.0f; } if(one_period_end == 1) { if(valve_pos.ref > VALVE_MAX_POS) { max_check = 1; } else if(valve_pos.ref < VALVE_MIN_POS) { min_check = 1; } JOINT_VEL[ID_index] = (FINAL_POS - START_POS) / data_num * TMR_FREQ_5k; // pulse/sec VALVE_FR_timer = 0; one_period_end = 0; ID_index= ID_index +1; V_out = 0.0f; } if(max_check == 1 && min_check == 1) { VALVE_POS_NUM = ID_index; ROM_RESET_DATA(); ID_index = 0; first_check = 0; VALVE_FR_timer = 0; CONTROL_UTILITY_MODE = MODE_NO_ACT; // CAN_TX_PRES((int16_t) (VALVE_FR_timer), (int16_t) (6)); } } break; } case MODE_SYSTEM_ID: { freq_sysid_Iref = (double) cnt_sysid * DT_TMR3 * 3.; valve_pos.ref = 2500.0f * sin(2.0f * 3.14159f * freq_sysid_Iref * (double) cnt_sysid * DT_TMR3); CONTROL_MODE = MODE_VALVE_OPEN_LOOP; cnt_sysid++; if (freq_sysid_Iref >= 300) { cnt_sysid = 0; CONTROL_UTILITY_MODE = MODE_NO_ACT; } break; } default: break; } // CONTROL MODE ------------------------------------------------------------ switch (CONTROL_MODE) { case MODE_NO_ACT: { V_out = 0.0f; break; } case MODE_VALVE_POSITION_CONTROL: { if (((OPERATING_MODE&0b110)>>1) == 0) { //Moog Valve I_REF = valve_pos.ref; } else if (((OPERATING_MODE&0b110)>>1) == 1) { //KNR Valve V_out = valve_pos.ref; } else { //SW Valve VALVE_POS_CONTROL(valve_pos.ref); V_out = Vout.ref; } break; } case MODE_JOINT_CONTROL: { double torq_ref = 0.0f; pos.err = (pos.ref - pos.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm] vel.err = (vel.ref - vel.sen)/(float)(ENC_PULSE_PER_POSITION); //[mm/s] pos.err_sum += pos.err/(float) TMR_FREQ_5k; //[mm] torq_ref = torq.ref + (K_SPRING * pos.err * 0.01f + D_DAMPER * vel.err * 0.0001f) / ENC_PULSE_PER_POSITION; //[N] // torque feedback torq.err = (torq_ref)/(float)(TORQUE_SENSOR_PULSE_PER_TORQUE) - torq.sen; //[N] torq.err_sum += torq.err/(float) TMR_FREQ_5k; //[N] if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { double I_REF_POS = 0.0f; double I_REF_FORCE_FB = 0.0f; // I_REF by Force Feedback double I_REF_VC = 0.0f; // I_REF for velocity compensation double temp_vel_pos = 0.0f; double temp_vel_torq = 0.0f; double wn_Pos = 2.0f * PI * 5.0f; // f_cut : 5Hz Position Control if ((OPERATING_MODE && 0x01) == 0) { // Rotary Mode temp_vel_pos = (0.01f * (double) P_GAIN_JOINT_POSITION * wn_Pos * pos.err + 0.01f * (double) I_GAIN_JOINT_POSITION * wn_Pos * pos.err_sum + 0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / ENC_PULSE_PER_POSITION) * PI / 180.0f; // rad/s // L when P-gain = 100, f_cut = 10Hz L feedforward velocity } else if ((OPERATING_MODE && 0x01) == 1) { temp_vel_pos = (0.01f * (double) P_GAIN_JOINT_POSITION * wn_Pos * pos.err + 0.01f * (double) I_GAIN_JOINT_POSITION * wn_Pos * pos.err_sum + 0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / ENC_PULSE_PER_POSITION); // mm/s // L when P-gain = 100, f_cut = 10Hz L feedforward velocity } if (temp_vel_pos > 0.0f) I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_A * 0.00006f / (K_v * sqrt(2.0f * alpha3 / (alpha3 + 1.0f)))); else I_REF_POS = temp_vel_pos * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); // velocity compensation for torque control if ((OPERATING_MODE && 0x01) == 0) { // Rotary Mode I_REF_FORCE_FB = 0.001f * ((double) P_GAIN_JOINT_TORQUE * torq.err + (double) I_GAIN_JOINT_TORQUE * torq.err_sum); // temp_vel_torq = (0.01 * (double) VELOCITY_COMP_GAIN * (double) CUR_VELOCITY / (double) ENC_PULSE_PER_POSITION) * PI / 180.0; // rad/s temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION) * PI / 180.0f; // rad/s // L feedforward velocity } else if ((OPERATING_MODE && 0x01) == 1) { I_REF_FORCE_FB = 0.001f * 0.01f*((double) P_GAIN_JOINT_TORQUE * torq.err + (double) I_GAIN_JOINT_TORQUE * torq.err_sum); // Linear Actuators are more sensitive. // temp_vel_torq = (0.01 * (double) VELOCITY_COMP_GAIN * (double) CUR_VELOCITY / (double) ENC_PULSE_PER_POSITION); // mm/s temp_vel_torq = (0.01f * (double) VELOCITY_COMP_GAIN * vel.ref / (double) ENC_PULSE_PER_POSITION); // mm/s // L feedforward velocity } if (temp_vel_torq > 0.0f) I_REF_VC = temp_vel_torq * ((double) PISTON_AREA_A * 0.00006f / (K_v * sqrt(2.0f * alpha3 / (alpha3 + 1.0f)))); else I_REF_VC = temp_vel_torq * ((double) PISTON_AREA_B * 0.00006f / (K_v * sqrt(2.0f / (alpha3 + 1.0f)))); // L velocity(rad/s or mm/s) >> I_ref(mA) // Ref_Joint_FT_dot = (Ref_Joint_FT_Nm - Ref_Joint_FT_Nm_old) / TMR_DT_5k; // Ref_Joint_FT_Nm_old = Ref_Joint_FT_Nm; I_REF = (1.0f - alpha_trans) * I_REF_POS + alpha_trans * (I_REF_VC + I_REF_FORCE_FB); } else { float VALVE_POS_RAW_FORCE_FB = 0.0f; VALVE_POS_RAW_FORCE_FB = alpha_trans*(((float) P_GAIN_JOINT_TORQUE * torq.err + (float) I_GAIN_JOINT_TORQUE * torq.err_sum) * 0.01f + DDV_JOINT_POS_FF(vel.sen))+ (1.0f-alpha_trans) * (P_GAIN_JOINT_POSITION * 0.01f * pos.err + DDV_JOINT_POS_FF(vel.ref)); if (VALVE_POS_RAW_FORCE_FB >= 0) { valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_PLUS; } else { valve_pos.ref = VALVE_POS_RAW_FORCE_FB + VALVE_DEADZONE_MINUS; } if(I_GAIN_JOINT_TORQUE != 0) { double Ka = 1.0f / (double) I_GAIN_JOINT_TORQUE * 100.0f; if(valve_pos.ref>VALVE_MAX_POS) { double valve_pos_rem = valve_pos.ref - VALVE_MAX_POS; valve_pos_rem = valve_pos_rem * Ka; valve_pos.ref = VALVE_MAX_POS; torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; } else if(valve_pos.ref < VALVE_MIN_POS) { double valve_pos_rem = valve_pos.ref - VALVE_MIN_POS; valve_pos_rem = valve_pos_rem * Ka; valve_pos.ref = VALVE_MIN_POS; torq.err_sum = torq.err_sum - valve_pos_rem/(float) TMR_FREQ_5k; } } VALVE_POS_CONTROL(valve_pos.ref); Vout.ref = (float) P_GAIN_JOINT_POSITION * 0.01f * ((float) pos.err); V_out = (float) Vout.ref; } break; } case MODE_VALVE_OPEN_LOOP: { V_out = (float) Vout.ref; break; } default: break; } if (((OPERATING_MODE&0b110)>>1) == 0 || ((OPERATING_MODE&0b110)>>1) == 1) { //Moog Valve or KNR Valve //////////////////////////////////////////////////////////////////////////// //////////////////////////// CURRENT CONTROL ////////////////////////////// //////////////////////////////////////////////////////////////////////////// if (CURRENT_CONTROL_MODE) { double alpha_update_Iref = 1.0f / (1.0f + TMR_FREQ_5k / (2.0f * 3.14f * 300.0f)); // f_cutoff : 500Hz I_REF_fil = (1.0f - alpha_update_Iref) * I_REF_fil + alpha_update_Iref*I_REF; I_ERR = I_REF_fil - cur.sen; I_ERR_INT = I_ERR_INT + (I_ERR) * DT_TMR3; // Moog Valve Current Control Gain double R_model = 539.0f; // ohm double L_model = 1.2f; double w0 = 2.0f * 3.14f * 150.0f; double KP_I = 0.1f * L_model*w0; double KI_I = 0.1f * R_model*w0; // KNR Valve Current Control Gain if (((OPERATING_MODE & 0b110)>>1) == 1) { // KNR Valve R_model = 163.0f; // ohm L_model = 1.0f; w0 = 2.0f * 3.14f * 80.0f; KP_I = 1.0f * L_model*w0; KI_I = 0.08f * R_model*w0; } double FF_gain = 1.0f; VALVE_PWM_RAW = KP_I * I_ERR + KI_I * I_ERR_INT; // VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model*I_REF); // Unit : mV I_REF_fil_diff = I_REF_fil - I_REF_fil_old; I_REF_fil_old = I_REF_fil; VALVE_PWM_RAW = VALVE_PWM_RAW + FF_gain * (R_model * I_REF_fil + L_model * I_REF_fil_diff * TMR_FREQ_5k); // Unit : mV double V_MAX = 12000.; // Maximum Voltage : 12V = 12000mV double Ka = 3.0f / KP_I; if (VALVE_PWM_RAW > V_MAX) { V_rem = VALVE_PWM_RAW - V_MAX; V_rem = Ka*V_rem; VALVE_PWM_RAW = V_MAX; I_ERR_INT = I_ERR_INT - V_rem * DT_TMR3; } else if (VALVE_PWM_RAW < -V_MAX) { V_rem = VALVE_PWM_RAW - (-V_MAX); V_rem = Ka*V_rem; VALVE_PWM_RAW = -V_MAX; I_ERR_INT = I_ERR_INT - V_rem * DT_TMR3; } Cur_Valve_Open_pulse = cur.sen / mA_PER_pulse; } else { VALVE_PWM_RAW = I_REF * mV_PER_mA; Cur_Valve_Open_pulse = I_REF / mA_PER_pulse; } //////////////////////////////////////////////////////////////////////////// ///////////////// Dead Zone Cancellation & Linearization ////////////////// //////////////////////////////////////////////////////////////////////////// // Dead Zone Cancellation (Mechanical Valve dead-zone) if (FLAG_VALVE_DEADZONE) { if (VALVE_PWM_RAW > 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_PLUS * mV_PER_pulse; // unit: mV else if (VALVE_PWM_RAW < 0) VALVE_PWM_RAW = VALVE_PWM_RAW + VALVE_DEADZONE_MINUS * mV_PER_pulse; // unit: mV VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW + (double)VALVE_CENTER * mV_PER_pulse; // unit: mV } else { VALVE_PWM_VALVE_DZ = VALVE_PWM_RAW; } // Output Voltage Linearization double CUR_PWM_nonlin = VALVE_PWM_VALVE_DZ; // Unit : mV double CUR_PWM_lin = PWM_duty_byLT(CUR_PWM_nonlin); // Dead Zone Cancellation (Electrical dead-zone) if (CUR_PWM_lin > 0) V_out = (int) CUR_PWM_lin + 140; else if (CUR_PWM_lin < 0) V_out = (int) CUR_PWM_lin - 140; else V_out = CUR_PWM_lin; } /******************************************************* *** PWM ********************************************************/ if (V_out >= VALVE_VOLTAGE_LIMIT*1000.0f) { V_out = VALVE_VOLTAGE_LIMIT*1000.0f; } else if(V_out<=-VALVE_VOLTAGE_LIMIT*1000.0f) { V_out = -VALVE_VOLTAGE_LIMIT*1000.0f; } PWM_out= V_out/(SUPPLY_VOLTAGE*1000.0f); // Full duty : 12000.0mV // Saturation of output voltage to 12.0V if(PWM_out > 1.0f) PWM_out=1.0f; else if (PWM_out < -1.0f) PWM_out=-1.0f; if (PWM_out>0.0f) { dtc_v=0.0f; dtc_w=PWM_out; } else { dtc_v=-PWM_out; dtc_w=0.0f; } //pwm TIM4->CCR2 = (PWM_ARR)*(1.0f-dtc_v); TIM4->CCR1 = (PWM_ARR)*(1.0f-dtc_w); if (TMR2_COUNT_CAN_TX % (int) ((int) TMR_FREQ_5k/CAN_FREQ) == 0) { // Position, Velocity, and Torque (ID:1200) if (flag_data_request[0] == HIGH) { if ((OPERATING_MODE & 0b01) == 0) { // Rotary Actuator if (SENSING_MODE == 0) { CAN_TX_POSITION_FT((int16_t) (pos.sen), (int16_t) (vel.sen/10.0f), (int16_t) (pres_A.sen*10.0f)); } else if (SENSING_MODE == 1) { CAN_TX_POSITION_PRESSURE((int16_t) (pos.sen), (int16_t) (vel.sen/10.0f), (int16_t) ((pres_A.sen)*5.0f), (int16_t) ((pres_B.sen)*5.0f)); } } else if ((OPERATING_MODE & 0b01) == 1) { // Linear Actuator if (SENSING_MODE == 0) { CAN_TX_POSITION_FT((int16_t) (pos.sen/4.0f), (int16_t) (vel.sen/100.0f), (int16_t) (pres_A.sen)); } else if (SENSING_MODE == 1) { CAN_TX_POSITION_PRESSURE((int16_t) (pos.sen/4.0f), (int16_t) (vel.sen/100.0f), (int16_t) ((pres_A.sen)*5.0f), (int16_t) ((pres_B.sen)*5.0f)); } } } if (flag_data_request[1] == HIGH) { //valve position double t_value = 0; // if(value>=(float) VALVE_CENTER) { // t_value = 10000.0f*((double)value - (double)VALVE_CENTER)/((double)VALVE_MAX_POS - (double)VALVE_CENTER); // } else { // t_value = -10000.0f*((double)value - (double)VALVE_CENTER)/((double)VALVE_MIN_POS - (double)VALVE_CENTER); // } if(OPERATING_MODE==5) { t_value = (double) value; } else if(CURRENT_CONTROL_MODE==1) { t_value = cur.sen; } else { t_value = V_out; } CAN_TX_TORQUE((int16_t) (t_value), (int16_t) (V_out)); //1300 } if (flag_data_request[2] == HIGH) { //pressure A and B CAN_TX_PRES((int16_t) (pres_A.sen), (int16_t) (pres_B.sen)); // CUR_PRES_X : 0(0bar)~4096(210bar) //1400 } //If it doesn't rest, below can can not work. for (can_rest = 0; can_rest < 10000; can_rest++) { ; } if (flag_data_request[3] == HIGH) { //PWM CAN_TX_PWM((int16_t) cur.sen); //1500 } //for (i = 0; i < 10000; i++) { // ; // } if (flag_data_request[4] == HIGH) { //valve position CAN_TX_VALVE_POSITION((int16_t) (CAN_FREQ), (int16_t) (D_DAMPER), (int16_t) OPERATING_MODE); //1600 } // Others : Reference position, Reference FT, PWM, Current (ID:1300) // if (flag_data_request[1] == HIGH) { // CAN_TX_SOMETHING((int) (FORCE_VREF), (int16_t) (1), (int16_t) (2), (int16_t) (3)); // } //if (flag_delay_test == 1){ //CAN_TX_PRES((int16_t) (0),(int16_t) torq_ref); //} TMR2_COUNT_CAN_TX = 0; } TMR2_COUNT_CAN_TX++; } TIM3->SR = 0x0; // reset the status register }