void Block::removeAllBlocks(){ while (getBlocks()->size()) { getBlocks()->back()->removeFromParent(); getBlocks()->popBack(); } }
/* \fn Timer32_1_ISR * \param void * \return void * \brief Fonction d'interruption activé par le timer à chaque front montant, permet par la * suite d'utiliser les deux caméras successivement. */ void Timer32_1_ISR(void) { int maxBlocks=1, k, j=0; static int masterCam = 1, h=0; // Lis les informations de l'objet if (masterCam == 1){ k = getBlocks(maxBlocks, masterCam); masterCam=2; } else if (masterCam == 2){ k = getBlocks(maxBlocks, masterCam); masterCam=1; } j = asservissement(); if (j==1){ balayage(); } // Affiche ces informations sur l'écran printCoor(); if(h==25){ printRS232(); h=0; } h++; }
int BlockMgr::findBlockedOverlaps(RecordKeyVector &keyList, RecordKeyVector &hitList, RecordKeyVector &resultList) { bool deleteKeyBlocks = false; if (keyList.empty()) { //get all the blocks for the query record, put them in it's list. getBlocks(keyList, deleteKeyBlocks); } _overlapBases.clear(); int keyBlocksSumLength = getTotalBlockLength(keyList); //Loop through every database record the query intersected with for (RecordKeyVector::const_iterator_type hitListIter = hitList.begin(); hitListIter != hitList.end(); hitListIter = hitList.next()) { RecordKeyVector hitBlocks(*hitListIter); bool deleteHitBlocks = false; getBlocks(hitBlocks, deleteHitBlocks); //get all blocks for the hit record. int hitBlockSumLength = getTotalBlockLength(hitBlocks); //get total length of the bocks for the hitRecord. int totalHitOverlap = 0; bool hitHasOverlap = false; //loop through every block of the database record. for (RecordKeyVector::const_iterator_type hitBlockIter = hitBlocks.begin(); hitBlockIter != hitBlocks.end(); hitBlockIter = hitBlocks.next()) { //loop through every block of the query record. for (RecordKeyVector::const_iterator_type keyListIter = keyList.begin(); keyListIter != keyList.end(); keyListIter = keyList.next()) { const Record *keyBlock = *keyListIter; const Record *hitBlock = *hitBlockIter; int maxStart = max(keyBlock->getStartPos(), hitBlock->getStartPos()); int minEnd = min(keyBlock->getEndPos(), hitBlock->getEndPos()); int overlap = minEnd - maxStart; if (overlap > 0) { hitHasOverlap = true; totalHitOverlap += overlap; } } } if (hitHasOverlap) { if ((float) totalHitOverlap / (float)keyBlocksSumLength >= _overlapFraction) { if (_hasReciprocal && ((float)totalHitOverlap / (float)hitBlockSumLength >= _overlapFraction)) { _overlapBases.push_back(totalHitOverlap); resultList.push_back(*hitListIter); } else if (!_hasReciprocal) { _overlapBases.push_back(totalHitOverlap); resultList.push_back(*hitListIter); } } } if (deleteHitBlocks) { deleteBlocks(hitBlocks); } } if (deleteKeyBlocks) { deleteBlocks(keyList); } resultList.setKey(keyList.getKey()); return (int)resultList.size(); }
void AppTSGoal::simulate(tgSimulation *simulation) { for (int i=0; i<nEpisodes; i++) { fprintf(stderr,"Episode %d\n", i); try { simulation->run(nSteps); } catch (std::runtime_error e) { // Nothing to do here, score will be set to -1 } // Don't change the terrain before the last episode to avoid leaks if (i != nEpisodes - 1) { if (all_terrain) { // Next run has Hills if (i % nTypes == 0) { const tgHillyGround::Config hillGroundConfig = getHillyConfig(); tgBulletGround* ground = new tgHillyGround(hillGroundConfig); simulation->reset(ground); } // Flat else if (i % nTypes == 1) { const tgBoxGround::Config groundConfig = getBoxConfig(); tgBulletGround* ground = new tgBoxGround(groundConfig); simulation->reset(ground); } // Flat with blocks else if (i % nTypes == 2) { simulation->reset(); tgModel* obstacle = getBlocks(); simulation->addObstacle(obstacle); } } else if(add_blocks) { simulation->reset(); tgModel* obstacle = getBlocks(); simulation->addObstacle(obstacle); } // Avoid resetting twice on the last run else { simulation->reset(); } } } }
int main() { getLeader(); getBlocks(); makeFlowGraph(); findGen(); findKill(); return 0; }
QDomElement ExerciseWindow::getBlocks(const FCWidget *fc, QDomDocument &doc, QString Name) { int n = fc->layout()->count(); int i = 0; QDomElement domElement = doc.createElement(Name); while (i < n) { QDomElement block; QDomAttr attr = doc.createAttribute("text"); QString tag = fc->layout()->itemAt(i)->widget()->metaObject()->className(); if (tag != "FCLine" && tag != "FCLeftLine" && tag != "RightLine") { block = doc.createElement(tag); FCWidget *widget = (FCWidget*)fc->layout()->itemAt(i)->widget(); attr.setValue(widget->getText()); block.setAttributeNode(attr); domElement.appendChild(block); if (tag == "FCDivarWidget") { FCDivarWidget *divar = (FCDivarWidget*)widget; QDomElement left = getBlocks(divar->getRightLine(), doc, "Left"); QDomElement right = getBlocks(divar->getLeftLine(), doc, "Right"); block.appendChild(left); block.appendChild(right); } else if (tag == "FCPrefixCycleWidget") { FCPrefixCycleWidget *cycle = (FCPrefixCycleWidget*)widget; QDomElement body = getBlocks(cycle->getCycleBody(), doc, "Body"); block.appendChild(body); } else if (tag == "FCPostfixCycleWidget") { FCPostfixCycleWidget *cycle = (FCPostfixCycleWidget*)widget; QDomElement body = getBlocks(cycle->getCycleBody(), doc, "Body"); block.appendChild(body); } else if (tag == "FCParameterCycleWidget") { FCParameterCycleWidget *cycle = (FCParameterCycleWidget*)widget; QDomElement body = getBlocks(cycle->getCycleBody(), doc, "Body"); block.appendChild(body); } } i++; } return domElement; }
rxcpp::observable<model::Transaction> StorageImpl::getAccountTransactions( std::string account_id) { std::shared_lock<std::shared_timed_mutex> write(rw_lock_); auto last_id = block_store_->last_id(); return getBlocks(1, last_id) .flat_map([](auto block) { return rxcpp::observable<>::iterate(block.transactions); }) .filter([account_id](auto tx) { return tx.creator_account_id == account_id; }); }
int HexReader::readBlockMeshDict(QTextStream *in) { fileContents = readFileContents(in); //Read vertices getVertices(); getBlocks(); getBCs(); getEdges(); return 0; }
int_list *gen(analysis_block *ablock){ if(ablock != NULL) { block* b = getBlockWithLabel(getBlocks(),ablock->label); if(b != NULL) { switch(b->bType) { case B_SKIP: return NULL; break; case B_BOOL_EXP: case B_ASSIGN: return free_variables(b); break; } } } return NULL; }
void VideoCommunication::transmit(){ std::string windowName = "Broadcating Video Stream"; cv::namedWindow( windowName, CV_WINDOW_FREERATIO); videoSource.grab(); videoSource.retrieve(sendFrame); int blocks_sent = 0; //unsigned long t1; do{ //t1 = clock(); getBlocks(sendFrame); blocks_sent = sendBlocks(); //printf("Blocks sent: %d\n", blocks_sent); cv::imshow( windowName, sendFrame ); // visualize frame to be set if( cv::waitKey(33) >= 0 ) break; sendFrame.release(); videoSource.grab(); //printf("%lf\n",(double)(clock() - t1)/CLOCKS_PER_SEC); }while (videoSource.retrieve(sendFrame)); }
int_list *kill(analysis_block *ablock) { if(ablock != NULL) { block* b = getBlockWithLabel(getBlocks(),ablock->label); if(b != NULL) { switch(b->bType) { case B_SKIP: case B_BOOL_EXP: return NULL; break; case B_ASSIGN: return mk_int_list(b->assignedVar,NULL); break; } } } return NULL; }
void ExerciseWindow::toCode() { QDomDocument doc("flowchart"); QDomElement domElement = getBlocks(wdg, doc); doc.appendChild(domElement); //qDebug()<<doc.toString(); QTextStream text; QString line_text; text.setString(&line_text); //text.setDevice(doc.toString()); QString name = windowTitle(); int n = name.indexOf(".xml"); if (n > 0) { name = QString::fromStdString((name.toStdString()).substr(0, name.length() - 4)); } text << "void " << name << "()"; XMLtoCode(text, domElement, 5); ui->textBrowser_2->setPlainText(text.readAll()); }
int main(int argc, char** argv, char** enp) { BLOCK_LIST_T blockList; BLOCK_T* pBlock; char plainText[] = "This is plaintext and this is not a jokes"; int result = 0; int i = 0; blockList.head = NULL; blockList.tail = NULL; result = getBlocks(plainText, strlen(plainText), &blockList); if (result > 0) { printf("Error getting blocks: %d\n", result); } /* Print the blocks */ pBlock = blockList.head; while (pBlock != NULL) { printf("Block: [%s]\n", pBlock->pBlockText); pBlock = pBlock->pNext; } result = deleteBlocks(&blockList); if (result > 0) { printf("Error deleting list: %d\n", result); } return 0; }
int BlockMgr::findBlockedOverlaps(RecordKeyVector &hitList, bool useOverlappingSubBlocks) { RecordKeyVector keyList(hitList.getKey()); bool deleteKeyBlocks = true; getBlocks(keyList, deleteKeyBlocks); _overlapBases.clear(); int keyBlocksSumLength = getTotalBlockLength(keyList); //Loop through every database record the query intersected with RecordKeyVector::iterator_type hitListIter = hitList.begin(); for (; hitListIter != hitList.end();) { RecordKeyVector hitBlocks(*hitListIter); bool deleteHitBlocks = false; getBlocks(hitBlocks, deleteHitBlocks); //get all blocks for the hit record. int hitBlockSumLength = getTotalBlockLength(hitBlocks); //get total length of the bocks for the hitRecord. int totalHitOverlap = 0; bool hitHasOverlap = false; //loop through every block of the database record. RecordKeyVector::iterator_type hitBlockIter = hitBlocks.begin(); for (; hitBlockIter != hitBlocks.end(); hitBlockIter = hitBlocks.next()) { //loop through every block of the query record. RecordKeyVector::iterator_type keyListIter = keyList.begin(); for (; keyListIter != keyList.end(); keyListIter = keyList.next()) { const Record *keyBlock = *keyListIter; const Record *hitBlock = *hitBlockIter; int maxStart = max(keyBlock->getStartPos(), hitBlock->getStartPos()); int minEnd = min(keyBlock->getEndPos(), hitBlock->getEndPos()); int overlap = minEnd - maxStart; if (overlap > 0) { hitHasOverlap = true; totalHitOverlap += overlap; if (useOverlappingSubBlocks == true) { (*hitListIter)->block_starts.push_back(maxStart); (*hitListIter)->block_ends.push_back(minEnd); } } } } if (hitHasOverlap && useOverlappingSubBlocks == false) { bool enoughKeyOverlap = (float) totalHitOverlap / (float) keyBlocksSumLength >= _overlapFraction; bool enoughHitOverlap = (float) totalHitOverlap / (float) hitBlockSumLength >= _overlapFraction; if (enoughKeyOverlap) { if (_hasReciprocal && enoughHitOverlap) { //(*hitListIter)->setValid(true); _overlapBases.push_back(totalHitOverlap); hitListIter = hitList.next(); } else if (_hasReciprocal && !enoughHitOverlap) { hitList.erase(); //(*hitListIter)->setValid(false); } else if (!_hasReciprocal) { //(*hitListIter)->setValid(true); _overlapBases.push_back(totalHitOverlap); hitListIter = hitList.next(); } } else { hitList.erase(); //(*hitListIter)->setValid(false); } } else if (!hitHasOverlap && useOverlappingSubBlocks == false) { hitList.erase(); //(*hitListIter)->setValid(false); } else { hitListIter = hitList.next(); } if (deleteHitBlocks) { deleteBlocks(hitBlocks); } } // end for loop through main hits if (deleteKeyBlocks) { deleteBlocks(keyList); } return (int)hitList.size(); }
Block& BufferManager::getIndexOneBlock(string indexName, int offset) { return getBlocks(offset); }
int MumuFile::getSize() { return getBlocks().size(); }
bool AppGoalOnline::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation /// @todo add position and angle to configuration /// @todo Generalize angle code FlemonsSpineModelGoal* myModel = new FlemonsSpineModelGoal(nSegments, 0.0); // Fifth create the controllers, attach to model if (add_controller) { const int segmentSpan = 3; const int numMuscles = 8; const int numParams = 2; const int segNumber = 0; // For learning results const double controlTime = .01; const double lowPhase = -1 * M_PI; const double highPhase = M_PI; const double lowAmplitude = 0.0; const double highAmplitude = 300.0; const double kt = 0.0; const double kp = 1000.0; const double kv = 200.0; const bool def = true; // Overridden by def being true const double cl = 10.0; const double lf = 0.0; const double hf = 30.0; // Feedback parameters const double ffMin = -0.5; const double ffMax = 10.0; const double afMin = 0.0; const double afMax = 200.0; const double pfMin = -0.5; const double pfMax = 6.28; const double tensionFeedback = 1000.0; // How often to check/change the controller during online learning const double feedbackTime = 3.0; SpineOnlineControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax, tensionFeedback, feedbackTime ); /// @todo fix memory leak that occurs here SpineOnlineControl* const myControl = new SpineOnlineControl(control_config, suffix, "bmirletz/TetrahedralComplex_Online/"); myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
bool AppMultiTerrain_OC::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation // TODO properly add this to the header info and learning apparatus double goalAngle = -M_PI / 2.0; /// @todo add position and angle to configuration OctahedralComplex* myModel = new OctahedralComplex(nSegments, goalAngle); // Fifth create the controllers, attach to model if (add_controller) { const int segmentSpan = 3; const int numMuscles = 4; const int numParams = 2; const int segNumber = 0; // For learning results const double controlTime = .01; const double lowPhase = -1 * M_PI; const double highPhase = M_PI; const double lowAmplitude = 0.0; const double highAmplitude = 300.0; const double kt = 0.0; const double kp = 1000.0; const double kv = 210.0; const bool def = true; // Overridden by def being true const double cl = 10.0; const double lf = 0.0; const double hf = 30.0; // Feedback parameters const double ffMin = -0.5; const double ffMax = 10.0; const double afMin = 0.0; const double afMax = 200.0; const double pfMin = -0.5; const double pfMax = 6.28; const double tensionFeedback = 1000.0; #if (1) JSONGoalControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax, tensionFeedback ); /// @todo fix memory leak that occurs here OctahedralGoalControl* const myControl = new OctahedralGoalControl(control_config, suffix, "bmirletz/OctaCL_6/"); #else SpineFeedbackControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax); SpineFeedbackControl* const myControl = new SpineFeedbackControl(control_config, suffix, "bmirletz/OctaCL_6/"); #endif myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
bool AppGoalTension::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation #if (0) startAngle = ((rand() / (double)RAND_MAX) - 0.5) * 3.1415; #endif FlemonsSpineModelGoal* myModel = new FlemonsSpineModelGoal(nSegments, goalAngle, startAngle); // Fifth create the controllers, attach to model if (add_controller) { Json::Value root; // will contains the root value after parsing. Json::Reader reader; std::string resourcePath = "bmirletz/TC_Tension/"; std::string controlFilePath = FileHelpers::getResourcePath(resourcePath); std::string controlFilename = controlFilePath + suffix; bool parsingSuccessful = reader.parse( FileHelpers::getFileString(controlFilename.c_str()), root ); if ( !parsingSuccessful ) { // report to the user the failure and their locations in the document. std::cout << "Failed to parse configuration\n" << reader.getFormattedErrorMessages(); throw std::invalid_argument("Bad filename for JSON"); } // Get the value of the member of root named 'encoding', return 'UTF-8' if there is no // such member. Json::Value impedenceVals = root.get("impedenceVals", "UTF-8"); impedenceVals = impedenceVals.get("params", "UTF-8"); // Keep drilling if necessary if (impedenceVals[0].isArray()) { impedenceVals = impedenceVals[0]; } const double impedanceMax = 2000.0; const int segmentSpan = 3; const int numMuscles = 8; const int numParams = 2; const int segNumber = 5; // For learning results const double controlTime = .01; const double lowPhase = -1 * M_PI; const double highPhase = M_PI; const double lowAmplitude = 0.0; const double highAmplitude = 300.0; // JSONCPP's .get really wants this to be typed... int j = 0; const double kt = impedanceMax * (impedenceVals.get(j, 0.0)).asDouble(); const double kp = impedanceMax * (impedenceVals.get(1, 0.0)).asDouble(); const double kv = impedanceMax * (impedenceVals.get(2, 0.0)).asDouble(); const bool def = true; // Overridden by def being true const double cl = 10.0; const double lf = 0.0; const double hf = 30.0; // Feedback parameters const double ffMin = -10.0; const double ffMax = 10.0; const double afMin = 0.0; const double afMax = 200.0; const double pfMin = 0.0; const double pfMax = 0.0; const double tensionFeedback = impedanceMax *(impedenceVals.get(3, 0.0)).asDouble(); JSONGoalControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax, tensionFeedback ); /// @todo fix memory leak that occurs here JSONGoalTension* const myControl = new JSONGoalTension(control_config, suffix, resourcePath); myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
void Cterrain::getBlocks(int jmin,int jmax,int imin,int imax,int curDepth) { //检查当前节点是否与视截体相交--abc //求节点p所表示区域的保守包围盒--abc // 上面--abc // p[0]--p[3] // | | // p[1]--p[2] // 下面--abc // p[4]--p[7] // | | // p[5]--p[6] float xmin=m_range.getMinX()+gridSize*jmin; float xmax=m_range.getMinX()+gridSize*jmax; float zmin=m_range.getMinZ()+gridSize*imin; float zmax=m_range.getMinZ()+gridSize*imax; float ymin=m_range.getMinY(); float ymax=m_range.getMaxY(); float c[3]={(xmax+xmin)/2,(ymin+ymax)/2,(zmin+zmax)/2}; float r=max(xmax-xmin,ymax-ymin)*0.86602540378443864676372317075294;//由于zmax-zmin与xmax-xmin相等,所以不用考虑--abc //看球体(c,r)是否都在planeList中某个面的反面,如果是则可剔除--abc bool visible=true; for(int i=0;i<5;i++){//不考虑远平面--abc const Cc3dPlane&plane=this->getMesh()->getSubMeshByIndex(0)->getCamera()->getFrustum().getPlaneByIndex(i); //看球体(c,r)是否在plane的背面--abc float PND=directedDistanceFromPointToPlane(plane, c); if(PND<-r){//如果在背面--abc //断定为不可见,不用再继续检测--abc visible=false; break; } }//得到visible if(visible){//如果可见--abc bool needDiv=false;//是否需要再分--abc //求needDiv if(imin+1==imax){//无须再分,因为已经无法再分--abc needDiv=false; }else{//进一步判断--abc //求c到视点的距离--abc float d2=square(this->getMesh()->getSubMeshByIndex(0)->getCamera()->getEyePos().x()-c[0]) /// +square(this->getMesh()->getSubMeshByIndex(0)->getCamera()->getEyePos().y()-c[1]) +square(this->getMesh()->getSubMeshByIndex(0)->getCamera()->getEyePos().z()-c[2]); float e=xmax-xmin;//边长--abc if(d2<square(e*reso))needDiv=true; }//得到needDiv if(needDiv){//继续分--abc int imid=(imin+imax)>>1;//除2 int jmid=(jmin+jmax)>>1; markmat[imid][jmid]=true; markedElementIndexList.push_back(Cij(imid,jmid)); //对四个孩子继续递归--abc getBlocks(jmin,jmid,imin,imid,curDepth+1); getBlocks(jmin,jmid,imid,imax,curDepth+1); getBlocks(jmid,jmax,imid,imax,curDepth+1); getBlocks(jmid,jmax,imin,imid,curDepth+1); }else{//不分--abc CterrainBlock block(imin,imax,jmin,jmax); m_blockList.push_back(block); } }
bool AppTSGoal::setup() { // First create the world const double scale = 100; world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation /// @todo add position and angle to configuration TetraSpineGoal* myModel = new TetraSpineGoal(nSegments, 0.0, scale); // Fifth create the controllers, attach to model if (add_controller) { const int segmentSpan = 3; const int numMuscles = 6; const int numParams = 2; const int segNumber = 5; // For learning results const double controlTime = .01; const double lowPhase = -1 * M_PI; const double highPhase = M_PI; const double lowAmplitude = 0.0; const double highAmplitude = 300.0; const double kt = 0.0; const double kp = 1000.0; const double kv = 200.0; const bool def = true; // Overridden by def being true const double cl = 10.0; const double lf = 0.0; const double hf = 30.0; // Feedback parameters const double ffMin = -0.5; const double ffMax = 10.0; const double afMin = 0.0; const double afMax = 200.0; const double pfMin = -0.5; const double pfMax = 6.28; const double tensionFeedback = 1000.0; #if (0) // Switch for .nnw or JSON based methods JSONGoalControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax, tensionFeedback ); /// @todo fix memory leak that occurs here JSONGoalControl* const myControl = new JSONGoalControl(control_config, suffix, "bmirletz/Tetra_Goal/"); #else JSONFeedbackControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax); /// @todo fix memory leak that occurs here JSONFeedbackControl * const myControl = new JSONFeedbackControl(control_config, suffix, "bmirletz/Tetra_Goal/"); #endif myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }
bool AppQuadControl::setup() { // First create the world world = createWorld(); // Second create the view if (use_graphics) view = createGraphicsView(world); // For visual experimenting on one tensegrity else view = createView(world); // For running multiple episodes // Third create the simulation simulation = new tgSimulation(*view); // Fourth create the models with their controllers and add the models to the // simulation /// @todo add position and angle to configuration //FlemonsSpineModelContact* myModel = //new FlemonsSpineModelContact(nSegments); //Parameters for the structure: const int segments = 7; const int hips = 4; const int legs = 4; const int feet = 4; BigPuppySymmetric* myModel = new BigPuppySymmetric(segments, hips, legs, feet); // Fifth create the controllers, attach to model if (add_controller) { const int segmentSpan = 3; //Not sure what this will be for mine! const int numMuscles = 8; //This may be ok, but confirm. const int numParams = 2; const int segNumber = 0; // For learning results const double controlTime = .01; const double lowPhase = -1 * M_PI; const double highPhase = M_PI; const double lowAmplitude = 0.0; const double highAmplitude = 300.0; const double kt = 0.0; //May need to retune kt, kp, and kv const double kp = 1000.0; const double kv = 200.0; const bool def = true; // Overridden by def being true const double cl = 10.0; const double lf = 0.0; const double hf = 30.0; // Feedback parameters... may need to retune const double ffMin = -0.5; const double ffMax = 10.0; const double afMin = 0.0; const double afMax = 200.0; const double pfMin = -0.5; const double pfMax = 6.28; const double maxH = 60.0; const double minH = 1.0; JSONQuadFeedbackControl::Config control_config(segmentSpan, numMuscles, numMuscles, numParams, segNumber, controlTime, lowAmplitude, highAmplitude, lowPhase, highPhase, kt, kp, kv, def, cl, lf, hf, ffMin, ffMax, afMin, afMax, pfMin, pfMax, maxH, minH); /// @todo fix memory leak that occurs here JSONQuadFeedbackControl* const myControl = new JSONQuadFeedbackControl(control_config, suffix, lowerPath); #if (0) tgCPGJSONLogger* const myLogger = new tgCPGJSONLogger("logs/CPGValues.txt"); myControl->attach(myLogger); #endif myModel->attach(myControl); } // Sixth add model & controller to simulation simulation->addModel(myModel); if (add_blocks) { tgModel* blockField = getBlocks(); simulation->addObstacle(blockField); } bSetup = true; return bSetup; }