void func() { PROF_TIMER_FUNC(FUNC_TIMER); for (int i=0; i<100000; i++) { double a = sqrt(5); } }
/*! Note that this is always a copy, and does not allow for using a recordset or cursor. */ bool Table::Populate(QSqlQuery query) { PROF_TIMER_FUNC(TABLE_POPULATE); data_.clear(); column_names_.clear(); if (query.next()) { QSqlRecord first_record = query.record(); num_columns_ = first_record.count(); data_.resize(num_columns_, vector<QVariant>(query.numRowsAffected())); for (int i = 0; i < num_columns_; ++i) { column_names_.insert(make_pair(first_record.fieldName(i).toStdString(), i)); //cerr << "Column name: " << first_record.fieldName(i).toStdString() << "\n"; } do { for (int i = 0; i < num_columns_; ++i) data_[i].push_back(query.value(i)); } while(query.next()); if (!data_.empty()) num_rows_ = data_[0].size(); return true; } return false; }
double CompliantEnergy::energy() const { PROF_RESET(QS); PROF_TIMER_FUNC(QS); //approach the object until contact; go really far if needed mHand->findInitialContact(200); //check if we've actually touched the object if (!mHand->getNumContacts(mObject)) { return 1; } //close the hand, but do additional processing when each new contact happens mCompUnbalanced = false; mMaxUnbalancedForce.set(0.0, 0.0, 0.0); QObject::connect(mHand, SIGNAL(moveDOFStepTaken(int, bool &)), this, SLOT(autoGraspStep(int, bool &))); mHand->autoGrasp(!mDisableRendering, 1.0, false); QObject::disconnect(mHand, SIGNAL(moveDOFStepTaken(int, bool &)), this, SLOT(autoGraspStep(int, bool &))); if (mCompUnbalanced || mMaxUnbalancedForce.len() > unbalancedForceThreshold) { //the equivalent of an unstable grasp } //check if we've actually grasped the object if (mHand->getNumContacts(mObject) < 2) { return 1; } PRINT_STAT(mOut, "unbal: " << mMaxUnbalancedForce); //compute unbalanced force again. Is it zero? //but compute it for all the force that the dofs will apply //a big hack for now. It is questionable if the hand should even allow //this kind of intrusion into its dofs. for (int d = 0; d < mHand->getNumDOF(); d++) { mHand->getDOF(d)->setForce(mHand->getDOF(d)->getMaxForce()); } mHand->getWorld()->resetDynamicWrenches(); //passing true means the set dof force will be used in computations Matrix tau(mHand->staticJointTorques(true)); int result = mHand->getGrasp()->computeQuasistaticForces(tau); if (result) { if (result > 0) { PRINT_STAT(mOut, "Final_unbalanced"); } else { PRINT_STAT(mOut, "Final_ERROR"); } return 1.0; } double *extWrench = static_cast<DynamicBody *>(mObject)->getExtWrenchAcc(); vec3 force(extWrench[0], extWrench[1], extWrench[2]); vec3 torque(extWrench[3], extWrench[4], extWrench[5]); //perform traditional f-c check mHand->getGrasp()->collectContacts(); mHand->getGrasp()->updateWrenchSpaces(); double epsQual = mEpsQual->evaluate(); PRINT_STAT(mOut, "eps: " << epsQual); if (epsQual < 0.05) { return 1.0; } PROF_PRINT(QS); PRINT_STAT(mOut, "torque: " << torque << " " << torque.len()); PRINT_STAT(mOut, "force: " << force << " " << force.len()); return -200.0 + force.len();// + torque.len(); }