Esempio n. 1
0
static void tsuroStart()
{
	timerUpdate(&g_time);
	timerUpdate(&g_demoTimer);

	memset(&g_game, 0, sizeof(g_game));

	//g_game.mode = TSURO_MODE_DEMO;
	g_game.mode = TSURO_MODE_SINGLE_PLAYER;

	tsuroCreateDeck();
	tsuroReset();
}
/**
 * @details
 * Runs the pipeline.
 *
 * This method is run repeatedly by the pipeline application every time
 * data matching the requested remote data is available until either
 * the pipeline application is killed or the method 'stop()' is called.
 */
void UdpBFPipeline::run(QHash<QString, DataBlob*>& remoteData)
{
  timerStart(&_totalTime);
  
    // Get pointer to the remote time series data blob.
    // This is a block of data containing a number of time series of length
    // N for each sub-band and polarisation.
    timeSeries = (TimeSeriesDataSetC32*) remoteData[_streamIdentifier];
    dataOutput( timeSeries, _streamIdentifier);

    // Run the polyphase channeliser.
    // Generates spectra from a blocks of time series indexed by sub-band
    // and polarisation.
    ppfChanneliser->run(timeSeries, spectra);

    // Convert spectra in X, Y polarisation into spectra with stokes parameters.
    stokesGenerator->run(spectra, stokes);
    // Clips RFI and modifies blob in place
    weightedIntStokes->reset(stokes);

    timerStart(&_rfiClipperTime);
    rfiClipper->run(weightedIntStokes);
    timerUpdate(&_rfiClipperTime);
    dataOutput(&(weightedIntStokes->stats()), "RFI_Stats");

    stokesIntegrator->run(stokes, intStokes);

    // Calls output stream managed->send(data, stream) the output stream
    // manager is configured in the xml.
     dataOutput(intStokes, "SpectrumDataSetStokes");

//    stop();
     if (_iteration % 100 == 0)
       cout << "Finished the CV beamforming pipeline, iteration " << _iteration << " out of " << _totalIterations << endl;
     
     _iteration++;

     if (_iteration == _totalIterations) stop();
     #ifdef TIMING_ENABLED
     timerUpdate(&_totalTime);
     if( _iteration % 100 == 0 )
       {
         timerReport(&_rfiClipperTime, "RFI_Clipper");
         timerReport(&_totalTime, "Pipeline Time (excluding adapter)");
         std::cout << std::endl;
       }
#endif


}
Esempio n. 3
0
PlayerGst::PlayerGst() : pipeline(0), bus(0), paused(false), Gstart(0), Glength(0), link(0), usePlaybin(false)
{
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
	gstplayer = this;
	gst_init (0, 0);
}
Esempio n. 4
0
static void tsuroDemoUpdate(float dt)
{
	tsuroPlayer* player = &g_game.player;

	if (!g_paused)
	{
		tsuroMovePlayer(dt * tsuroPlayerSpeed);
		float timeRunning = timerGetTickSinceLastUUpdate(&g_demoTimer);
		if (timeRunning>5.f)
		{
			tsuroReset();
			timerUpdate(&g_demoTimer);
		}
	}
	if (g_rotate)
	{

		for (int i=0; i<tsuroNumCells; i++)
		{
			for (int j=0; j<tsuroNumCells; j++)
			{
				tsuroNode* node = &g_game.nodes[i][j];
				if (node->used)
				{
					if (g_rotate) tsuroCardRotate(&node->card, g_rotate);
				}
			}
		}
		player->current.path = (player->current.path + g_rotate*2 + 8) % 8;
		g_rotate = 0;

		tsuroCardDump(&g_game.nodes[0][0].card);
	}
}
Esempio n. 5
0
GLWidget277::GLWidget277(QWidget *parent)
    : QOpenGLWidget(parent) {
  // Allow the timer to redraw the window
  connect(&timer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
  // Tell the timer to redraw 60 times per second
  timer.start(16);
}
Esempio n. 6
0
static void animateScene ()
{
	float dt = timerGetTickSinceLastUUpdate(&g_time);
	timerUpdate(&g_time);

	vehicleTick(dt);

    glutPostRedisplay();
}
Esempio n. 7
0
  void _TimeManager::start()
  {
    m_timer = new QTimer( this );
    connect( m_timer, SIGNAL(timeout()), this, SLOT(timerUpdate()) );
    int maxFPS = 60;
    // Determines the refresh rate based off of the max number of frames/sec.
    m_timer->start( (float)1000/maxFPS );
    m_time.start();

  } // _TimeManager::start()
Esempio n. 8
0
// Конструктор TransCoder
TransCoder::TransCoder(QWidget *parent) : QMainWindow(parent)
{
    setupUi(this);

    defaultContainer = 1;
    defaultCodec = 1;
    transcoder = this;
    bitrateList << 8 << 16 << 24 << 32 << 40 <<
                48 << 56 << 64 << 80 << 96 << 112 <<
                128 << 160 << 192 << 224 << 256 << 320;

    treeWidget->setHeaderLabels(QStringList() << trUtf8("Композиция") << trUtf8("Время"));
    treeWidget->header()->setStretchLastSection(false);
    treeWidget->setColumnWidth(1, 75);
    treeWidget->header()->setSectionResizeMode(0,QHeaderView::Stretch);

    containerBox->addItems(QStringList() << "ogg" << "mp3" << "flac" << "aac");
    codecBox->addItems(QStringList() << "vorbis" << "lame" << "flac" << "faac");

    containerBox->setCurrentIndex(defaultContainer);
    codecBox->setCurrentIndex(defaultCodec);

    statusLabel = new QLabel();
    lineEdit->setText(QDir::homePath());
    dirdialog = new QFileDialog(this, trUtf8("Выбрать директорию для сохранения альбома"), QDir::homePath());
    dirdialog->setFileMode(QFileDialog::DirectoryOnly);
    dirdialog->setOption(QFileDialog::DontUseNativeDialog, true);
    statusBar()->addWidget(statusLabel, 1);
    selectAllAction->setStatusTip(trUtf8("Выбор всех композиций для кодирования"));

    selected = false;
    transcode = false;
    numTrack = 0;

    timer = new QTimer(this);

    // Костыль для неюникодовых локалей
    localFileNamesEncoder = QTextCodec::codecForLocale()->makeEncoder();

    restoreSettings();

    connect(selectDirButton, SIGNAL(clicked()), dirdialog, SLOT(exec()));
    connect(dirdialog, SIGNAL(directoryEntered(QString)), lineEdit, SLOT(setText(QString)));
    connect(dirdialog, SIGNAL(directoryEntered(QString)), this, SLOT(updateSettings()));
    connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
    connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAllTrigger()));
    connect(startButton, SIGNAL(clicked()), this, SLOT(startTranscode()));
    connect(stopButton, SIGNAL(clicked()), this, SLOT(stopAll()));
    connect(containerBox, SIGNAL(activated(int)), codecBox, SLOT(setCurrentIndex(int)));
    connect(codecBox, SIGNAL(activated(int)), containerBox, SLOT(setCurrentIndex(int)));
    connect(treeWidget, SIGNAL(itemEntered(QTreeWidgetItem*,int)), this, SLOT(toolItem(QTreeWidgetItem*,int)));
    connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem*,int)), this, SLOT(toolItem(QTreeWidgetItem*,int)));
    connect(quitAction, SIGNAL(triggered()), this, SIGNAL(transQuit()));
    connect(prefAction, SIGNAL(triggered()), this, SIGNAL(prefShow()));
}
Esempio n. 9
0
RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent)
	: MainPage(parent)
{
	_timer = new QTimer ;
	_timer->setInterval(ms_update_period);
	_timer->setSingleShot(true);

	QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate())) ;

	_timer->start() ;
}
CFunctionTestSpeedTableWindow::CFunctionTestSpeedTableWindow(QWidget *parent) :
    QWidget(parent)
{
    setProperty("testFlag",false);

   //***UI CONPONENTS
    QVBoxLayout *top = new QVBoxLayout;

    QGroupBox *_mainGroupBox = new QGroupBox(tr("车速表测试"));
    QGridLayout *_mainGrid = new QGridLayout(_mainGroupBox);
    _currentValue = new QSpinBox;
    _currentValue->setMinimum(0);
    _currentValue->setMaximum(300);
    _autoTestButton = new QPushButton(tr("自动检测"));
    _singleTestButton = new QPushButton(tr("测单点"));
    _signOutLabel = new QLabel;
    _signOutLabel->setStyleSheet("border-radius:20px;background:#fff;border:1px solid #666;");
    _signOutLabel->setFixedSize(40,40);
    _statusLabel = new QLabel(tr("状态:"));
    _statusLabel->setStyleSheet("font:bold 16px;color:#0099FF;max-height:50px;min-height:26px;background:#CCFF99;");

    QLabel *_bitMap = new QLabel();
    _bitMap->setScaledContents(true);
    _bitMap->setPixmap(QPixmap(":/res/高低档切换.bmp"));
    _bitMap->setFixedSize(48,50);
    _bitMap->setProperty("picture",true);

    //***Layout
    _mainGrid->addWidget(_statusLabel,0,0,1,3);
    _mainGrid->addWidget(new QLabel(tr("高低档切换指示灯:")),1,0);
    _mainGrid->addWidget(_bitMap,1,1);
    _mainGrid->addWidget(_signOutLabel,1,2);
    _mainGrid->addWidget(new QLabel(tr("车速:")),2,0);
    _mainGrid->addWidget(_currentValue,2,1);
    _mainGrid->addWidget(new QLabel(tr("km/h")),2,2);
    _mainGrid->addWidget(_autoTestButton,3,1);
    _mainGrid->addWidget(_singleTestButton,3,2);

    top->addWidget(_mainGroupBox);
    top->setSizeConstraint(QLayout::SetFixedSize);
    top->setAlignment(Qt::AlignCenter);
    setLayout(top);

    //***signals
    connect(_autoTestButton,SIGNAL(clicked()),this,SLOT(autoTestButtonClicked()));
    connect(_singleTestButton,SIGNAL(clicked()),this,SLOT(singleTestButtonClicked()));

    _timer = new QTimer;
    connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate()));

    cf = ((CApp*)qApp)->_tjob->_mconfig;
}
Esempio n. 11
0
EventDialog::EventDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EventDialog)
{
    ui->setupUi(this);
    id1 = startTimer(1000);
    id2 = startTimer(2000);
    id3 = startTimer(10000);

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()),this, SLOT(timerUpdate()));
    timer->start(1000);
}
Esempio n. 12
0
Boolean timerExpired(UInteger16 index, IntervalTimer *itimer)
{
  timerUpdate(itimer);
  
  if(index >= TIMER_ARRAY_SIZE)
    return FALSE;
  
  if(!itimer[index].expire)
    return FALSE;
  
  itimer[index].expire = FALSE;
  
  return TRUE;
}
Esempio n. 13
0
int CCQApplication::run()
{
    /* Initialize instance and cocos2d */
    if (! applicationDidFinishLaunching())
    {
        return 0;
    }

    _timer = new QTimer(this);
    connect(_timer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
    _timer->start(_qAnimationInterval);

    return cocos2d::CCQApplication::getInstance()->exec();
}
seekerBarTicker::seekerBarTicker(int minute)
{
    this->minute = minute;
    this->isPoint = false;
    this->painted = false;

    updateTimer = new QTimer(this);
    updateTimer->setInterval(6000);

    connect(updateTimer,SIGNAL(timeout()),this,SLOT(timerUpdate()));

    timer = time(0);

    updateTimer->start();

}
CFullTestSelfPowerWindow::CFullTestSelfPowerWindow(QWidget *parent) :
    QWidget(parent)
{
    setProperty("testFlag",0);
    setProperty("index",0);

    //***UI components
    _statusLabel = new QLabel(tr("点击测试按钮开始仪表自供电测试,请观察仪表是否在主电,常电切换过程中是否工作正常。"));
    _statusLabel->setStyleSheet("font:bold 14px;color:#0099FF;max-height:26px;min-height:26px;background:#CCFF99;");
    _testResult = new QLabel(tr("...自供电状态..."));
    _testResult->setStyleSheet("background:wheat;min-width:240px;min-height:30px;border:1px solid blue;");
    _testResult->setAlignment(Qt::AlignCenter);
    _startButton = new QPushButton(tr("开始自供电测试"));

    //***Layout
    QVBoxLayout *globalVLayout = new QVBoxLayout;
    QGroupBox *_mainGroupBox =new QGroupBox(tr("自供电测试"));
    QVBoxLayout *_vl = new QVBoxLayout(_mainGroupBox);
    _vl->addWidget(_statusLabel);
    QGridLayout *grid = new QGridLayout();

    _label1 = new QLabel(tr(" 主电开 "));
    _label1->setStyleSheet("font:bold 18px;color:green;max-height:30px;min-height:30px;background:#CCFF99;");
    _label2 = new QLabel(tr(" 常电关 "));
    _label2->setStyleSheet("font:bold 18px;color:red;max-height:30px;min-height:30px;background:wheat;");

    grid->addWidget(_label1,0,0);
    grid->addWidget(_label2,0,1);

    grid->addWidget(new QLabel(tr("仪表反馈:")),1,0);
    grid->addWidget(_testResult,1,1);
    grid->addWidget(_startButton,2,1);

    _vl->addLayout(grid);
    globalVLayout->addWidget(_mainGroupBox);
    setLayout(globalVLayout);

    //***signal
    connect(_startButton,SIGNAL(clicked()),this,SLOT(startButtonClicked()));
    connect((CApp*)qApp,SIGNAL(sendBackFullTestData_selfpower(QByteArray)),this,SLOT(sendBackData(QByteArray)));

    _timer = new QTimer;
    connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate()));

    cf = ((CApp*)qApp)->_tjob->_mconfig;
}
Esempio n. 16
0
Boolean 
timerExpired(UInteger16 index, IntervalTimer * itimer)
{
	timerUpdate(itimer);

	if (index >= TIMER_ARRAY_SIZE)
		return FALSE;

	if (!itimer[index].expire)
		return FALSE;

	itimer[index].expire = FALSE;


	DBG2("timerExpired:   Timer %d expired, taking actions.   current interval: %d; current left: %d\n", index, itimer[index].left , itimer[index].interval);

	return TRUE;
}
Esempio n. 17
0
void Baker::update(double dt)
{
	if (isBaking())
	{
		if (timeLimit == 0)
		{
			startTimer(5, 10);
		}
		else
		{
			if (timerUpdate(dt))
			{
				setToPlacingFood();
				stopTimer();
			}
		}
	}
}
Esempio n. 18
0
PlayerAudiere::PlayerAudiere() : svolume(100), file(""), sync(false), paused(false)
{
    stream = 0;
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(timerUpdate()));
	whiteList << "application/ogg";
	whiteList << "audio/ogg";
	whiteList << "audio/x-vorbis+ogg";
	whiteList << "audio/x-flac+ogg";
	whiteList << "audio/mpeg";
	whiteList << "audio/x-flac";
	whiteList << "audio/x-wav";
	whiteList << "audio/x-aiff";
	whiteList << "audio/x-aiffc";
	whiteList << "audio/x-mod";
	whiteList << "audio/x-s3m";
	whiteList << "audio/x-xm";
	whiteList << "audio/x-it";
}
Esempio n. 19
0
static void tsuroUpdate ()
{
	float dt = timerGetTickSinceLastUUpdate(&g_time);
	timerUpdate(&g_time);

	switch(g_game.mode)
	{
		case TSURO_MODE_DEMO:
			tsuroDemoUpdate(dt);
			break;

		case TSURO_MODE_SINGLE_PLAYER:
			tsuroSinglePlayerUpdate(dt);
			break;
	}

	// Reset
	g_rotate = 0;

    glutPostRedisplay();
}
/**
 * @details
 * Runs the pipeline.
 *
 * This method is run repeatedly by the pipeline application every time
 * data matching the requested remote data is available until either
 * the pipeline application is killed or the method 'stop()' is called.
 */
void TimingPipeline::run(QHash<QString, DataBlob*>& remoteData)
{
  timerStart(&_totalTime);

    // Get pointer to the remote time series data blob.
    // This is a block of data containing a number of time series of length
    // N for each sub-band and polarisation.
    timeSeries = (TimeSeriesDataSetC32*) remoteData["LofarTimeStream1"];

    // Get the total number of samples per chunk.
    _totalSamplesPerChunk =
            timeSeries->nTimesPerBlock() * timeSeries->nTimeBlocks();

    // Run the polyphase channeliser.
    // Generates spectra from a blocks of time series indexed by sub-band
    // and polarisation.
    timerStart(&_ppfTime);
    ppfChanneliser->run(timeSeries, spectra);
    timerUpdate(&_ppfTime);

    // Convert spectra in X, Y polarisation into spectra with stokes parameters.
    timerStart(&_stokesTime);
    stokesGenerator->run(spectra, stokes);
    timerUpdate(&_stokesTime);

    // The RFI clipper

    timerStart(&_rfiClipper);
    weightedIntStokes->reset(stokes);
    rfiClipper->run(weightedIntStokes);
    timerUpdate(&_rfiClipper);

    //    timerStart(&_integratorTime);
    //    stokesIntegrator->run(stokes, intStokes);
    //    timerUpdate(&_integratorTime);

    // Calls output stream managed->send(data, stream) the output stream
    // manager is configured in the xml.
    //dataOutput(spectra, "SpectrumDataSetC32");
    timerStart(&_outputTime);
    dataOutput(stokes, "SpectrumDataSetStokes");
    timerUpdate(&_outputTime);

//    stop();

    if (_iteration % 50 == 0)
        cout << "Finished the UDP beamforming pipeline, iteration " << _iteration << endl;
  timerUpdate(&_totalTime);
    ++_iteration;

//    if (_iteration > 43000) stop();
    if (_iteration * _totalSamplesPerChunk >= 16*16384*5) {
        stop();
    //timerReport(&(adapter->timeData()), "Adapter Time");
    timerReport(&_ppfTime, "Polyphase Filter");
    timerReport(&_stokesTime, "Stokes Generator");
    timerReport(&_rfiClipper, "RFI_Clipper");
    //    	timerReport(&_integratorTime, "Stokes Integrator");
    timerReport(&_outputTime, "Output");
    timerReport(&_totalTime, "Pipeline Time (excluding adapter)");
    cout << endl;
    cout << "Total (average) allowed time per iteration = "
         << _totalSamplesPerChunk * 5.12e-6 << " sec" << endl;
    //cout << "Total (average) actual time per iteration = "
    //     << adapterTime.timeAverage + _totalTime.timeAverage << " sec" << endl;
    cout << "nSubbands = " << timeSeries->nSubbands() << endl;
    cout << "nPols = " << timeSeries->nPolarisations() << endl;
    cout << "nBlocks = " << timeSeries->nTimeBlocks() << endl;
    cout << "nChannels = " << timeSeries->nTimesPerBlock() << endl;
    cout << endl;
    }
}
Esempio n. 21
0
int main (int argc, char **argv)
{
#if 0
	
	const int N = 4;
	float y[N] = {-0.653828, -0.653828, 0.753333, 0.753333};
	float k[N];

	float l[2] = {0.f, 0.f};
	float kdl[2] = {0.f, 0.f};
	float n[2] = {0.f, 0.f};

	for (int i=0; i<N; i++)
	{
		if (y[i] > 0.f)
		{
			l[1] += y[i];
			n[1] += 1.f;
		}
		else
		{
			l[0] -= y[i];
			n[0] += 1.f;
		}
	}

	kdl[1] = l[1] / (n[1]*l[0] + n[0]*l[1]);
	kdl[0] = l[0] / (n[1]*l[0] + n[0]*l[1]);

	for (int i=0; i<2; i++)
	{
		printf("[%d] l = %f kdl = %f\n", i, l[i], kdl[i]);
	}

	for (int i=0; i<N; i++)
	{
		k[i] = y[i] > 0.f ? kdl[1] : kdl[0];
	}


	float force = 0.f;
	float torque = 0.f;
	for (int i=0; i<N; i++)
	{
		force += k[i]; 
		torque += y[i] * k[i];
	}

	printf("force = %f\n", force);
	printf("torque = %f\n", torque);

	printf("kdl[0]/kdl[1] = %f\n", kdl[0]/kdl[1]);



	return 0;

#endif

#if 0
	vec3 r = {1.f, -0.3f, 0.f};
	vec3 fground = {0.f, 1.f, 0.f};
	vec3 fcent = {-1.f, 0.f, 0.f};

	vec3 tground;
	vec3 tcent;
	veccross(&tground, &r, &fground);
	veccross(&tcent, &r, &fcent);

	printf("tground = %f\n", tground.z);
	printf("tcent = %f\n", tcent.z);

	return 0;
	float axleFriction = 200.1f;
	float mass = 10.f;
	float invMass = 1.f/mass;
	float v = 10.0f;
	float dt = 0.01;

	for (int r=0; r<100; r++)
	{
		float force = -axleFriction*sgn(v);
		v = v + force*invMass * dt;
		printf("v = %f\n", v);
	}

	return 0;
#endif

#if 0
	float mass = 10.f;
	float wheelmass = 1.0f;
	float radius = 0.1f;
	float wheelInertia = 2.f/5.f*radius*radius*wheelmass;
	float vel = 0.f;
	float wheelVel= 0.f;

	float dt = 0.01f;
	float torque = 1000.f;
	float angSpeed = -dt*torque*radius/wheelInertia; 

	float momentum = angSpeed*wheelInertia;
	printf("momentum put in = %f \n", momentum);

	for (int repeat = 0; repeat<10; repeat++)
	{
		{
			float contactSpeed = radius * angSpeed + wheelVel;
			float error = contactSpeed;
			float denom = 1.f/wheelmass + radius*radius/wheelInertia;
			float impulse = error / denom;

			// Add impulse to the wheel
			wheelVel = wheelVel - impulse/wheelmass;
			angSpeed = angSpeed - radius*impulse/wheelInertia;
		}

		// Axis error
		{
			float error = wheelVel - vel;
			float denom = 1.f/wheelmass + 1.f/mass;
			float impulse = error/denom;
			wheelVel = wheelVel - impulse/wheelmass;
			vel = vel + impulse/mass;
		}
	}
	
	printf("momentum c = %f\n", vel*mass);
	printf("momentum w = %f\n", vel*wheelmass);
	printf("momentum aw = %f\n", angSpeed*wheelInertia);
	printf("total momentum = %f\n", vel*(mass+wheelmass) + angSpeed*wheelInertia);
	printf("chassis = %f, wheel = %f\n", vel, wheelVel);

	return 0;
#endif

#if 0
	float mass = 10.f;
	float inertia = mass * 0.4f;
	vec3 wheelOffset = {0.f, 1.5f, -0.2f};
	float wheelmass = 1.0f;
	float radius = 0.1f;
	float wheelInertia = 2.f/5.f*radius*radius*wheelmass;
	vec3 vel = {0.f, 0.f, 0.f};
	vec3 w = {0.f, 0.f, 0.f};
	float wheelVel= 0.f;

	float dt = 0.01f;
	float torque = 1000.f;
	float angSpeed = -dt*torque*radius/wheelInertia; 

	for (int repeat = 0; repeat<100; repeat++)
	{
		{
			float contactSpeed = radius * angSpeed + wheelVel;
			float error = contactSpeed;
			float denom = 1.f/wheelmass + radius*radius/wheelInertia;
			float impulse = error / denom;

			// Add impulse to the wheel
			wheelVel = wheelVel - impulse/wheelmass;
			angSpeed = angSpeed - radius*impulse/wheelInertia;
		}

		// Axis error
		{
			// float axleVel = vel;
			vec3 cross;
			veccross(&cross, &w, &wheelOffset);
			float axleVel = vel.y + cross.y;

			vec3 pulldir = {0.f, 1.f, 0.f};
			float error = wheelVel - axleVel;
			if (error < 0.000001f) break;
			float denom = 1.f/wheelmass + computeDenominator(1.f/mass, 1.f/inertia, &wheelOffset, &pulldir);
			float impulse = error/denom;
			wheelVel = wheelVel - impulse/wheelmass;
			//vel = vel + impulse/mass;
			{
				vecscale(&pulldir, &pulldir, impulse);
				addImpulseAtOffset(&vel, &w, 1.f/mass, 1.f/inertia, &wheelOffset, &pulldir);
			}
		}
	}

	printf("wheelVel = %f, vel = %f, w = %f\n", wheelVel, vel.y, w.x);
	printf("%f\n", w.x/vel.y);

	// Simple force application!
	{
		wheelVel = 0.f;
		vec3 impulse = {0.f, dt * torque / radius, 0.f};
		veczero(&vel);
		veczero(&w);
		vec3 offset = wheelOffset;
		//offset.z -= radius;
		printf("wheelVel = %f, vel = %f, w = %f\n", wheelVel, vel.y, w.x);
		addImpulseAtOffset(&vel, &w, 1.f/mass, 1.f/inertia, &offset, &impulse);
	}

	printf("wheelVel = %f, vel = %f, w = %f\n", wheelVel, vel.y, w.x);

	printf("%f\n", w.x/vel.y);

	return 0;
#endif

#if 0
	float x = 100.f;
	float friction = 20.f;
	float dt = 0.01f;
	float r = dt*friction;
	int n=0;

	while (n<1000)
	{
		//x = x - r*x/(fabsf(x)+r);
		printf("%f\n", x);
		n++;
	}


	return 0;
#endif

	timerUpdate(&g_time);
    vehicleInit();

    // GLUT Window Initialization:
    glutInit (&argc, argv);
    glutInitWindowSize (s_width, s_height);
    glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow ("CS248 GLUT example");

    // Initialize OpenGL graphics state
    initGraphics();

    // Register callbacks:
    glutDisplayFunc (display);
    glutReshapeFunc (reshape);
    glutKeyboardFunc (keyboard);
    glutMouseFunc (mouseButton);
    glutMotionFunc (mouseMotion);
    glutIdleFunc (animateScene);

    //BuildPopupMenu ();
    //glutAttachMenu (GLUT_RIGHT_BUTTON);

    // Turn the flow of control over to GLUT
    glutMainLoop ();

    return 0;
}
Esempio n. 22
0
void AutoGraspGenerationDlg::init()
{ 


    millisecondsPerMeshPoint = 30000;
    meshPointIncrement = 10;
    currentMeshPointIndex = 0;
    grasp_dir =  "/home/jvarley/grasp_deep_learning/graspit_gdl/saved_grasps/";

    seedHandMovementTimer = new QTimer(this);
    connect(seedHandMovementTimer,SIGNAL(timeout()), this, SLOT(timerUpdate()));

  energyBox->insertItem("Hand Contacts");
  energyBox->insertItem("Potential Quality");
  energyBox->insertItem("Contacts AND Quality");
  energyBox->insertItem("Autograsp Quality");
  energyBox->insertItem("Guided Autograsp");
  energyBox->setCurrentItem(1);//CHANGED!
  plannerTypeBox->insertItem("Sim. Ann.");
  plannerTypeBox->insertItem("Loop");
  plannerTypeBox->insertItem("Multi-Threaded");
  plannerTypeBox->insertItem("Online");
  plannerTypeBox->insertItem("Assisted Control");
  plannerTypeBox->insertItem("Time Test");
  plannerTypeBox->setCurrentItem(3);//CHANGED!

  plannerInitButton->setEnabled(TRUE);
  plannerResetButton->setEnabled(FALSE);
  plannerStartButton->setEnabled(FALSE);
  instantEnergyButton->setEnabled(FALSE);

  QString n;
  QIntValidator* vAnnSteps = new QIntValidator(1,500000,this);
  annStepsEdit->setValidator(vAnnSteps);
  n.setNum(70000);
  annStepsEdit->setText(n);

  spaceSearchBox->insertItem("Complete");
  spaceSearchBox->insertItem("Axis-angle");
  spaceSearchBox->insertItem("Ellipsoid");
  spaceSearchBox->insertItem("Approach");
  spaceSearchBox->setCurrentItem(3);

  prevGraspButton->setEnabled(FALSE);
  nextGraspButton->setEnabled(FALSE);
  bestGraspButton->setEnabled(FALSE);
  executeGraspButton->setEnabled(FALSE);

  variableBox->setColumnLayout(0, Qt::Vertical);

  varGridLayout = new QGridLayout( variableBox->layout(),1,5 );
  varGridLayout->setSpacing(5);
  varGridLayout->setAlignment(Qt::AlignTop);
  varGridLayout->addMultiCellWidget(spaceSearchLabel,0,0,0,1);
  varGridLayout->addMultiCellWidget(spaceSearchBox,0,0,2,4);

  varGridLayout->addWidget( new QLabel("On", variableBox),1,0 );
  varGridLayout->addWidget( new QLabel("Name", variableBox),1,1 );
  varGridLayout->addWidget( new QLabel("Input", variableBox),1,2 );
  varGridLayout->addWidget( new QLabel("Target", variableBox),1,3 );
  varGridLayout->addWidget( new QLabel("Confidence", variableBox),1,4 );

  inputGloveBox->setEnabled(FALSE);
  inputLoadButton->setEnabled(FALSE);


 
}
Esempio n. 23
0
void run() {

    view.firstTimeStamp = view.lastRecordFrame = view.lastVideoFrame = getMS();

    view.dirty = 0;
    view.lastVideoFrameSkip=0;
    view.zoomTarget = view.zoom;
    view.zoomSpeed = 0;
    VectorCopy(view.rot, view.rotTarget);
    VectorZero(view.rotSpeed);

    while (!view.quit) {

        Uint32 ts_before, ts_after;
        Uint32 ts;
        ts_before =  getMS();

        if (state.mode & SM_RECORD) {

            view.frameSkipCounter = 0;

            //if (view.verboseMode)
            //    conAdd(LLOW, "R frame:%5i dt:%5i fs:%2i", state.totalFrames, view.deltaVideoFrame, state.historyNFrame);

            setTitle(va("%s frame: %i/%i (skip:%i)", STRING_RECORD, state.totalFrames, state.historyFrames, state.historyNFrame));

            processFrame();
            ts = getMS();
            view.deltaRecordFrame = ts - view.lastRecordFrame;
            view.lastRecordFrame = ts;

            if (state.autoSave && (state.totalFrames - state.lastSave) >= state.autoSave) {
                cmdSaveFrameDump(0);
                state.lastSave = state.totalFrames;
            }

        }

        else if (state.mode & SM_PLAY) {

            if (view.frameSkip < 0) {
                view.frameSkipCounter++;
                if (view.frameSkipCounter > -view.frameSkip) {
                    view.frameSkipCounter = 0;
                    state.currentFrame++;
                }
            } else {
                state.currentFrame++;
                state.currentFrame+=view.frameSkip;
            }

            if (state.currentFrame >= state.frame) {
                state.currentFrame = 0;
                view.frameSkipCounter = 0;
            }

            //if (view.verboseMode)
            //    conAdd(LLOW, "P frame:%5i dt:%5i fs:%2i", state.currentFrame, view.deltaVideoFrame, state.historyNFrame);

        }

        timerUpdate();

        runInput();
        if (view.quit) return;

        if (state.autoRecordNext) {
            state.autoRecordNext = 0;
            cmdRecord(0);
        }

        setColours();
        if (view.zoomFitAuto == 2) {
            cmdZoomFit(NULL);
            view.zoomTarget = view.zoom;
            view.zoomSpeed = 0;
        }

        runVideo();

        /* if we are not recording or replaying, wait a bit -- helps to cool down you laptop :-)) */
        if (((state.mode & (SM_RECORD|SM_PLAY) ) == 0) && (view.dirty < 1)) {
            ts_after =  getMS();
            if (ts_after < (ts_before + SMALL_NAP)) SDL_Delay( SMALL_NAP - (ts_after - ts_before));
        }

        /* pull the break on very fast video cards - 60fps playback is enough */
        if (((state.mode & SM_PLAY ) == SM_PLAY) || (state.mode == 0)) {
            ts_after =  getMS();
            if (ts_after < (ts_before + PLAY_MIN_TIME)) SDL_Delay(PLAY_MIN_TIME - (ts_after - ts_before));
        }

	/* if minVideoRefreshTime is set, hold the current frame a bit longer*/
	if (view.minVideoRefreshTime >= SDL_TIMESLICE) {
            ts_after =  getMS();
            if (ts_after < (ts_before + view.minVideoRefreshTime)) SDL_Delay(view.minVideoRefreshTime - (ts_after - ts_before));
        }

        // if last video frame was displayed, reset dirty flag
        if (view.lastVideoFrameSkip==0) {
            view.dirty = 0;
            if (view.drawAxis==3) view.drawAxis=1;
        }
    }

}