void StaffTextBase::write(XmlWriter& xml) const { if (!xml.canWrite(this)) return; xml.stag(name()); for (ChannelActions s : _channelActions) { int channel = s.channel; for (QString name : s.midiActionNames) xml.tagE(QString("MidiAction channel=\"%1\" name=\"%2\"").arg(channel).arg(name)); } for (int voice = 0; voice < VOICES; ++voice) { if (!_channelNames[voice].isEmpty()) xml.tagE(QString("channelSwitch voice=\"%1\" name=\"%2\"").arg(voice).arg(_channelNames[voice])); } if (_setAeolusStops) { for (int i = 0; i < 4; ++i) xml.tag(QString("aeolus group=\"%1\"").arg(i), aeolusStops[i]); } if (swing()) { QString swingUnit; if (swingParameters()->swingUnit == MScore::division / 2) swingUnit = TDuration(TDuration::DurationType::V_EIGHTH).name(); else if (swingParameters()->swingUnit == MScore::division / 4) swingUnit = TDuration(TDuration::DurationType::V_16TH).name(); else swingUnit = TDuration(TDuration::DurationType::V_ZERO).name(); int swingRatio = swingParameters()->swingRatio; xml.tagE(QString("swing unit=\"%1\" ratio= \"%2\"").arg(swingUnit).arg(swingRatio)); } TextBase::writeProperties(xml); xml.etag(); }
void Controller::computeTorques(int _currentFrame) { mCurrentFrame = _currentFrame; mTorques.setZero(); if (mState == "STAND") { stand(); } else if (mState == "CROUCH") { crouch(); } else if (mState == "JUMP") { jump(); } else if (mState == "REACH") { reach(); } else if (mState == "GRAB") { grab(); } else if (mState == "RELEASE") { release(); } else if (mState == "SWING") { swing(); } else if (mState == "BENDABDOMEN") { bendAbdomen(); } else { std::cout << "Illegal state: " << mState << std::endl; } // Just to make sure no illegal torque is used. Do not remove this. for (int i = 0; i < 6; i++) { mTorques[i] = 0.0; } }
void swing(uint8_t direction_flag){ if (direction_flag == 0){; clear_dirpin(); PIDcalc(Left); direction_flag = 1; wait_period(.5); swing(direction_flag); } else{ set_dirpin(); PIDcalc(Right); direction_flag = 0; wait_period(.5); swing(direction_flag); } }
void ss_sampl_H() { // Choose sampling method. //#define SAMP_METHOD_SWING #define SAMP_METHOD_SWING_S // SWING mm #if defined(SAMP_METHOD_SWING) #define toR2 24+1 //20 #define toR3 12+2 //10 #define toR1 23 //15 #define toL1 23-2 //20 #define toL3 23 //20 #define toL2 12+3 //15 #define toC1 24+3 //20 #elif defined(SAMP_METHOD_SWING_S) #define toR2 40 #define toR3 20 #define toR1 40 #define toL1 40 #define toL3 40 #define toL2 20 #define toC1 40 #else #error Choose Sampling Method #endif led_off(PIO_LED_ALL); led_on (PIO_LED_2 | PIO_LED_6 | PIO_LED_3); // sys_delay(1000); ss_on(); // show LEDs to find the center of block int ss_diff; while( !( get_key_state()==(PORT_CANCEL) || get_key_state()==(PORT_SELECT) ) ) { ss_diff = ((int)ss_value[SS_L45]) - ((int)ss_value[SS_R45]); led_off(PIO_LED_ALL); if ( ss_diff > 10) led_on(PIO_LED_3); else if ( ss_diff > 5) led_on(PIO_LED_4 | PIO_LED_1); else if ( ss_diff < -10) led_on(PIO_LED_2); else if ( ss_diff < -5 ) led_on(PIO_LED_5 | PIO_LED_0); else led_on(PIO_LED_6); } // wait_key(); torque_on(); wait_key(); // ss_on(); led_count_down( 5, 1000 ); // debug //#define DEBUG_SAMPL disable_adj(); reset_spd_ptr(); // C1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_6 ); sys_delay(100); sampl_value( sC1 ); motor_start(); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // R2 led_off( PIO_LED_0|PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_0|PIO_LED_5|PIO_LED_2 ); #if defined(SAMP_METHOD_SWING) swing(toR2); #elif defined(SAMP_METHOD_SWING_S) swing_S(toR2); #else #error Choose Sampling Method #endif sampl_value( sR2 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // R3 led_off( PIO_LED_0|PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_2 ); #if defined(SAMP_METHOD_SWING) swing(toR3); #elif defined(SAMP_METHOD_SWING_S) swing_S(toR3); #else #error Choose Sampling Method #endif sampl_value( sR3 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // R1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_0 | PIO_LED_5); #if defined(SAMP_METHOD_SWING) swing(-toR1); #elif defined(SAMP_METHOD_SWING_S) swing_S(-toR1); #else #error Choose Sampling Method #endif sampl_value( sR1 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // L1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_1 | PIO_LED_4); #if defined(SAMP_METHOD_SWING) swing(-toL1); #elif defined(SAMP_METHOD_SWING_S) swing_S(-toL1); #else #error Choose Sampling Method #endif sampl_value( sL1 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // L3 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_3); #if defined(SAMP_METHOD_SWING) swing(-toL3); #elif defined(SAMP_METHOD_SWING_S) swing_S(-toL3); #else #error Choose Sampling Method #endif sampl_value( sL3 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // L2 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_1|PIO_LED_3|PIO_LED_4 ); #if defined(SAMP_METHOD_SWING) swing(toL2); #elif defined(SAMP_METHOD_SWING_S) swing_S(toL2); #else #error Choose Sampling Method #endif sampl_value( sL2 ); #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif // C1 led_off( PIO_LED_0 |PIO_LED_1|PIO_LED_2|PIO_LED_3|PIO_LED_4|PIO_LED_5|PIO_LED_6); led_on ( PIO_LED_6 ); #if defined(SAMP_METHOD_SWING) swing(toC1); #elif defined(SAMP_METHOD_SWING_S) swing_S(toC1); #else #error Choose Sampling Method #endif #ifdef DEBUG_SAMPL motor_stop(); wait_key(); motor_start(); #endif motor_stop(); ss_off(); torque_off(); }
//---------------------------------------------- void ttChar::update(){ float x =20; float scale = 1000; float smallMove; float smallMoveSale = 1.2; if (charNum == 0) { if (bFixedMove==true){ control_A->bSmallLeft = false; control_A->bSmallRight = false; control_A->bLeft = false; control_A->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } }else{ bReset = true; if (control_A->diff.x>1||control_A->diff.x<-1) { smallMove = control_A->diff.x*smallMoveSale; } else { smallMove = 0; } if (control_A->bLeft == true && character.getVelocity().x< 15) { character.addForce(ofVec2f(x,0), scale); control_A->bLeft = false; mirrorLeft = true; } else if(control_A->bRight == true && character.getVelocity().x> -15) { character.addForce(ofVec2f(-x,0), scale); control_A->bRight = false; mirrorLeft = false; }else if (control_A->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_A->bSmallLeft = false; mirrorLeft = true; } else if(control_A->bSmallRight == true) { character.setVelocity(smallMove, 0); control_A->bSmallRight = false; mirrorLeft = false; } } } if(charNum == 1){ if (bFixedMove == true) { control_B->bSmallLeft = false; control_B->bSmallRight = false; control_B->bLeft = false; control_B->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } } else { bReset = true; if (control_B->diff.x>1||control_B->diff.x<-1) { smallMove = control_B->diff.x*smallMoveSale; }else{ smallMove = 0; } if (control_B->bLeft == true && character.getVelocity().x>-15) { character.addForce(ofVec2f(-x,0), scale); control_B->bLeft = false; mirrorLeft = true; } else if(control_B->bRight == true && character.getVelocity().x<15) { character.addForce(ofVec2f(x,0), scale); control_B->bRight = false; mirrorLeft = false; }else if (control_B->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_B->bSmallLeft = false; mirrorLeft = true; } else if(control_B->bSmallRight == true){ character.setVelocity(smallMove, 0); control_B->bSmallRight = false; mirrorLeft = false; } } } swing(); dead(); getPos = character.getPosition(); }
//---------------------------------------------- void ttChar::update() { float x =20; float scale = 1000; float smallMove; float smallMoveSale = 1.2; if (charNum == 0) { if (bFixedMove==true) { control_A->bSmallLeft = false; control_A->bSmallRight = false; control_A->bLeft = false; control_A->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } } else { bReset = true; if (control_A->diff.x>1||control_A->diff.x<-1) { smallMove = control_A->diff.x*smallMoveSale; } else { smallMove = 0; } if (control_A->bLeft == true && character.getVelocity().x< 15) { character.addForce(ofVec2f(x,0), scale); control_A->bLeft = false; mirrorLeft = true; } else if(control_A->bRight == true && character.getVelocity().x> -15) { character.addForce(ofVec2f(-x,0), scale); control_A->bRight = false; mirrorLeft = false; } else if (control_A->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_A->bSmallLeft = false; mirrorLeft = true; } else if(control_A->bSmallRight == true) { character.setVelocity(smallMove, 0); control_A->bSmallRight = false; mirrorLeft = false; } } } if(charNum == 1) { if (bFixedMove == true) { control_B->bSmallLeft = false; control_B->bSmallRight = false; control_B->bLeft = false; control_B->bRight = false; if (bReset) { character.setVelocity(0, 0); bReset = false; } } else { bReset = true; if (control_B->diff.x>1||control_B->diff.x<-1) { smallMove = control_B->diff.x*smallMoveSale; } else { smallMove = 0; } if (control_B->bLeft == true && character.getVelocity().x>-15) { character.addForce(ofVec2f(-x,0), scale); control_B->bLeft = false; mirrorLeft = true; } else if(control_B->bRight == true && character.getVelocity().x<15) { character.addForce(ofVec2f(x,0), scale); control_B->bRight = false; mirrorLeft = false; } else if (control_B->bSmallLeft == true) { character.setVelocity(smallMove, 0); control_B->bSmallLeft = false; mirrorLeft = true; } else if(control_B->bSmallRight == true) { character.setVelocity(smallMove, 0); control_B->bSmallRight = false; mirrorLeft = false; } } } if (bSwing) { swing(); } else { getPos = character.getPosition(); bHookIt = false; } dead(); if (joints.empty()&&!rects.empty()) { alpha-=5; } if (alpha<=100) { destroyRect(); alpha = 255; bDestroyRect = false; } }