int main(int argc, char *argv[]) { //embed fonts QFile res1(":/fonts/bell-gothic-black.ttf"); if (res1.open(QIODevice::ReadOnly)) { QFontDatabase::addApplicationFontFromData(res1.readAll()); } QFile res2(":/fonts/bell-gothic-bold.ttf"); if (res2.open(QIODevice::ReadOnly)) { QFontDatabase::addApplicationFontFromData(res2.readAll()); } QFile res3(":/fonts/bell-gothic-light.ttf"); if (res3.open(QIODevice::ReadOnly)) { QFontDatabase::addApplicationFontFromData(res3.readAll()); } QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt) { //calculate 4 possible cases areas, and take biggest area //also need to keep 'deepest' int maxPenetrationIndex = -1; #define KEEP_DEEPEST_POINT 1 #ifdef KEEP_DEEPEST_POINT btScalar maxPenetration = pt.getDistance(); for (int i=0;i<4;i++) { if (m_pointCache[i].getDistance() < maxPenetration) { maxPenetrationIndex = i; maxPenetration = m_pointCache[i].getDistance(); } } #endif //KEEP_DEEPEST_POINT btScalar res0(btScalar(0.)),res1(btScalar(0.)),res2(btScalar(0.)),res3(btScalar(0.)); if (maxPenetrationIndex != 0) { btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA; btVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; btVector3 cross = a0.cross(b0); res0 = cross.length2(); } if (maxPenetrationIndex != 1) { btVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA; btVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA; btVector3 cross = a1.cross(b1); res1 = cross.length2(); } if (maxPenetrationIndex != 2) { btVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA; btVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA; btVector3 cross = a2.cross(b2); res2 = cross.length2(); } if (maxPenetrationIndex != 3) { btVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA; btVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA; btVector3 cross = a3.cross(b3); res3 = cross.length2(); } btVector4 maxvec(res0,res1,res2,res3); int biggestarea = maxvec.closestAxis4(); return biggestarea; }
void test_verify_1() { cout << "Verify Test 1" << endl; vector<int> res1 (100); vector<int> res2 (100); cout << "res1 == res2: " << TestEnvironment::verify(res1, res2) << endl; vector<int> res3 (50); vector<int> res4 (100); cout << "res3 == res4: " << TestEnvironment::verify(res3, res4) << endl; cout << endl; }
void afslink::sendreply (svccb *sbp) { if (sbp->vers () == 2) sbp->reply (&res); else if (res.status) nfs_error (sbp, res.status); else { readlink3res res3 (NFS3_OK); res3.resok->data = *res.data; mkpoattr (res3.resok->symlink_attributes, sbp2aid (sbp)); sbp->reply (&res3); } }
int main(int argc, char *argv[]) { //embed fonts QFile res1(":/fonts/bell-gothic-black.ttf"); if (res1.open(QIODevice::ReadOnly)) { QFontDatabase::addApplicationFontFromData(res1.readAll()); } QFile res2(":/fonts/bell-gothic-bold.ttf"); if (res2.open(QIODevice::ReadOnly)) { QFontDatabase::addApplicationFontFromData(res2.readAll()); } QFile res3(":/fonts/bell-gothic-light.ttf"); if (res3.open(QIODevice::ReadOnly)) { QFontDatabase::addApplicationFontFromData(res3.readAll()); } bool quiet = false; QApplication a(argc, argv); #ifdef Q_OS_WIN if (argc>1) { QString arg1 = argv[1]; qDebug() << arg1; if (arg1 == "-q" || arg1 == "-quiet" || arg1 == "-s" || arg1 == "-silent") { quiet = true; QuietInstaller qi = QuietInstaller(); } else { qWarning() << "Unknown argument"; } } #endif MainWindow w; w.show(); return a.exec(); }
void SIMPLE_Agents::get_IR_reading( vector <double> &_reading){ double x,z,X,Z,rotation = 0.0; this->pos = this->get_pos(); double y = pos[1] + 0.011; btMatrix3x3 m = btMatrix3x3(body->getWorldTransform().getRotation()); double rfPAngle = btAsin(-m[1][2]); if ( rfPAngle < SIMD_HALF_PI ) { if ( rfPAngle > -SIMD_HALF_PI ) rotation = btAtan2(m[0][2],m[2][2]); else rotation = -btAtan2(-m[0][1],m[0][0]); } else rotation = btAtan2(-m[0][1],m[0][0]); // IR0 reading x = pos[0]+((robot_radius) * cos(-rotation + 0.3)); //calc IR sensor X based on robot radius z = pos[2]+((robot_radius) * sin(-rotation + 0.3)); from1[0] = btVector3(x, y, z); //sensor position based on robot rotation vector to hold btVector X = x+((IR_range) * cos(-rotation + 0.3 )); //calc IR ray end position based on IR range and placement of sensor on the robot Z = z+((IR_range) * sin(-rotation + 0.3 )); to1[0] = btVector3( X, y, Z ); //Max reading pos of the IR based on rotation and IR range btCollisionWorld::ClosestRayResultCallback res0(from1[0], to1[0]); //struct for the closest ray callback //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res0.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[0], to1[0], res0); //check for ray collision between the coords sets if(res0.hasHit()){ _reading[0] = IR_range*res0.m_closestHitFraction ; to1[0]=res0.m_hitPointWorld; //update the vector with the btVector results -> used to render it in openGL } // IR7 reading x = pos[0]+((robot_radius) * cos(-rotation - 0.3)); z = pos[2]+((robot_radius) * sin(-rotation - 0.3)); from1[1] = btVector3(x, y, z); X = x+((IR_range) * cos(-rotation - 0.3 )); Z = z+((IR_range) * sin(-rotation - 0.3 )); to1[1] = btVector3( X, y, Z ); btCollisionWorld::ClosestRayResultCallback res7(from1[1], to1[1]); //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res7.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[1], to1[1], res7); if(res7.hasHit()){ _reading[1] = IR_range*res7.m_closestHitFraction; to1[1]=res7.m_hitPointWorld; } // IR1 reading corrospond to epuck x = pos[0]+((robot_radius) * cos(-rotation + 0.8)); z = pos[2]+((robot_radius) * sin(-rotation + 0.8)); from1[2] = btVector3(x, y, z); X = x+((IR_range) * cos(-rotation + 0.8 )); Z = z+((IR_range) * sin(-rotation + 0.8 )); to1[2] = btVector3( X, y, Z ); btCollisionWorld::ClosestRayResultCallback res1(from1[2], to1[2]); //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res1.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[2], to1[2], res1); if(res1.hasHit()){ _reading[2] = IR_range*res1.m_closestHitFraction; to1[2]=res1.m_hitPointWorld; } // IR6 reading x = pos[0]+((robot_radius) * cos(-rotation - 0.8)); z = pos[2]+((robot_radius) * sin(-rotation - 0.8)); from1[3] = btVector3(x, y, z); X = x+((IR_range) * cos(-rotation - 0.8 )); Z = z+((IR_range) * sin(-rotation - 0.8 )); to1[3] = btVector3( X, y, Z ); btCollisionWorld::ClosestRayResultCallback res6(from1[3], to1[3]); //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res6.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[3], to1[3], res6); if(res6.hasHit()){ _reading[3] = IR_range*res6.m_closestHitFraction; to1[3]=res6.m_hitPointWorld; } // IR2 reading x = pos[0]+((0.028) * cos(-rotation + 1.57)); z = pos[2]+((0.028) * sin(-rotation + 1.57)); from1[4] = btVector3(x, y, z); X = x+((0.049) * cos(-rotation + 1.57 )); Z = z+((0.049) * sin(-rotation + 1.57)); to1[4] = btVector3( X, y, Z ); btCollisionWorld::ClosestRayResultCallback res2(from1[4], to1[4]); //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res2.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[4], to1[4], res2); if(res2.hasHit()){ _reading[4] = 0.049*(res2.m_closestHitFraction) - 0.009; to1[4]=res2.m_hitPointWorld; } // IR5 reading x = pos[0]+((0.028) * cos(-rotation - 1.57)); z = pos[2]+((0.028) * sin(-rotation - 1.57)); from1[5] = btVector3(x, y, z); X = x+((0.049) * cos(-rotation - 1.57 )); Z = z+((0.049) * sin(-rotation - 1.57 )); to1[5] = btVector3( X, y, Z ); btCollisionWorld::ClosestRayResultCallback res5(from1[5], to1[5]); //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res5.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[5], to1[5], res5); if(res5.hasHit()){ _reading[5] = 0.049*res5.m_closestHitFraction - 0.009; to1[5]=res5.m_hitPointWorld; } // IR3 reading x = pos[0]+((robot_radius) * cos(-rotation + 2.64)); z = pos[2]+((robot_radius) * sin(-rotation + 2.64)); from1[6] = btVector3(x, y, z); X = x+((IR_range) * cos(-rotation + 2.64 )); Z = z+((IR_range) * sin(-rotation + 2.64 )); to1[6] = btVector3( X, y, Z ); btCollisionWorld::ClosestRayResultCallback res3(from1[6], to1[6]); //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res3.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[6], to1[6], res3); if(res3.hasHit()){ _reading[6] = IR_range*res3.m_closestHitFraction; to1[6]=res3.m_hitPointWorld; } // IR4 reading x = pos[0]+((robot_radius) * cos(-rotation - 2.64)); z = pos[2]+((robot_radius) * sin(-rotation - 2.64)); from1[7] = btVector3(x, y, z); X = x+((IR_range) * cos(-rotation - 2.64 )); Z = z+((IR_range) * sin(-rotation - 2.64 )); to1[7] = btVector3( X, y, Z ); btCollisionWorld::ClosestRayResultCallback res4(from1[7], to1[7]); //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine //res4.m_flags = 0xFFFFFFFF; this->world->rayTest(from1[7], to1[7], res4); if(res4.hasHit()){ _reading[7] = IR_range*res4.m_closestHitFraction; to1[7]=res4.m_hitPointWorld; } // for( int i = 0; i < num_IR_sensors; i++){ // printf(" \nIR%d distance reading= %f ",i,_reading[i]); // } //calibrating distance to IR value reading according to a line equations for(int i = 0; i < num_IR_sensors; i++){ if (_reading[i] > 0.03 && _reading[i] <= 0.04) _reading[i] = -20600 * _reading[i] + 924; else if (_reading[i] > 0.02 && _reading[i] <= 0.03) _reading[i] = -37000 * _reading[i] + 1416; else if (_reading[i] > 0.01 && _reading[i] <= 0.02) _reading[i] = -153500 * _reading[i] + 3746; else if (_reading[i] > 0.005 && _reading[i] <= 0.01) _reading[i] = -252600 * _reading[i] + 4737; else if (_reading[i] >= 0.0 && _reading[i] <= 0.005 ) _reading[i] = -124200 * _reading[i] + 4095; } // for( int i = 0; i < num_IR_sensors; i++){ // printf("\n IR%d distance reading= %f ",i,_reading[i]); // } // take_occupancy_reading(_reading, get_rotation(), get_pos()[0], get_pos()[2] ); }
TEST(TEmaSpVec, Simple1) { try { TSignalProc::TEmaSpVec sum(100, TSignalProc::TEmaType::etLinear, 0, 10000, 0.001); TSignalProc::TEma ema2(100, TSignalProc::TEmaType::etLinear, 0, 10000); TSignalProc::TEma ema5(100, TSignalProc::TEmaType::etLinear, 0, 10000); TSignalProc::TEma ema6(100, TSignalProc::TEmaType::etLinear, 0, 10000); uint64 timestamp1 = 10; TIntFltKdV in1; in1.Add(TIntFltKd(2, 1.0)); sum.Update(in1, timestamp1); ema2.Update(1.0, timestamp1); ema5.Update(0.0, timestamp1); ema6.Update(0.0, timestamp1); EXPECT_EQ(sum.GetTmMSecs(), timestamp1); const TIntFltKdV& res1 = sum.GetValue(); EXPECT_EQ(res1.Len(), 1); EXPECT_EQ(res1[0].Key, 2); EXPECT_EQ(res1[0].Dat, 1.0); // add another sparse vector, don't remove anything uint64 timestamp2 = timestamp1 + 1000; TIntFltKdV in2; in2.Add(TIntFltKd(5, 2.0)); sum.Update(in2, timestamp2); ema2.Update(0.0, timestamp2); ema5.Update(2.0, timestamp2); ema6.Update(0.0, timestamp2); printf("ema2: %f\n", ema2.GetValue()); printf("ema5: %f\n", ema5.GetValue()); printf("ema6: %f\n", ema6.GetValue()); EXPECT_EQ(sum.GetTmMSecs(), timestamp2); const TIntFltKdV& res2 = sum.GetValue(); EXPECT_EQ(res2.Len(), 2); EXPECT_EQ(res2[0].Key, 2); EXPECT_EQ(res2[0].Dat, ema2.GetValue()); EXPECT_EQ(res2[1].Key, 5); EXPECT_EQ(res2[1].Dat, ema5.GetValue()); uint64 timestamp3 = timestamp2 + 1000; TIntFltKdV in3; in3.Add(TIntFltKd(5, 3.0)); in3.Add(TIntFltKd(6, 6.0)); sum.Update(in3, timestamp3); ema2.Update(0.0, timestamp3); ema5.Update(3.0, timestamp3); ema6.Update(6.0, timestamp3); printf("ema2: %f\n", ema2.GetValue()); printf("ema5: %f\n", ema5.GetValue()); printf("ema6: %f\n", ema6.GetValue()); EXPECT_EQ(sum.GetTmMSecs(), timestamp3); TIntFltKdV res3(sum.GetValue()); EXPECT_EQ(res3.Len(), 3); EXPECT_EQ(res3[0].Key, 2); EXPECT_EQ(res3[0].Dat, ema2.GetValue()); EXPECT_EQ(res3[1].Key, 5); EXPECT_EQ(res3[1].Dat, ema5.GetValue()); EXPECT_EQ(res3[2].Key, 6); EXPECT_EQ(res3[2].Dat, ema6.GetValue()); printf("ema2: %f\n", ema2.GetValue()); printf("ema5: %f\n", ema5.GetValue()); printf("ema6: %f\n", ema6.GetValue()); } catch (PExcept& Except) { printf("Error: %s", Except->GetStr()); throw Except; } }