Exemple #1
0
void RWIOPump::setLength(size_t len){
    this->length = len;
    if(length > 0){
        //根据length计算timeoutInterval, readBytesPerEach, sendBytesPerEach
        calculateSpeed(speed, &timeoutInterval, &readBytesPerEach, length>buffSize?buffSize:length);
    }else{
        calculateSpeed(speed, &timeoutInterval, &readBytesPerEach, buffSize);
    } 
}
Exemple #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    coordinatesIsNeeded(true)
{
    ui->setupUi(this);
    ui->enableGpsCheckbox->setChecked(coordinatesIsNeeded);
    ui->videoSlider->setEnabled(false);
    connect(ui->actionOpen, SIGNAL(triggered()), SLOT(openFile()));
    connect(&timer, SIGNAL(timeout()), this, SLOT(stepVideo()));
    connect(ui->videoSlider, SIGNAL(sliderMoved(int)), this, SLOT(startVideo(int)));
    connect(ui->videoSlider, SIGNAL(valueChanged(int)), this, SLOT(startVideo(int)));
    connect(ui->calcSpeedButton, SIGNAL(clicked()), this, SLOT(calculateSpeed()));
    connect(ui->enableGpsCheckbox, SIGNAL(stateChanged(int)), this, SLOT(changeGpsOutputState(int)));
    connect(ui->playPauseButton, SIGNAL(clicked()), this, SLOT(playPause()));
    connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(stop()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close()));

    QStyle *pStyle = qApp->style();
    QIcon icon = pStyle->standardIcon(QStyle::SP_MediaPlay);
    ui->playPauseButton->setIcon(icon);

    icon = pStyle->standardIcon(QStyle::SP_MediaStop);
    ui->stopButton->setIcon(icon);

    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutDialog()));
}
float PlayerTracker::calculateScore(unsigned int playerID)
{

	float speed = calculateSpeed(playerID);

	float speedScore = 1.5 * applySlope(speed,0.2,0.3);
	if(playerID <= MAX_ID)
		speedScore += 0.5;

	/*NON ANCORA TESTATO*/
	/*if(playerID <= MAX_ID)
		for(unsigned int i = MAX_ID+1; i < potentialPlayers.size(); i++) {
			std::vector<float> res = potentialPlayers[i].playerFilter.getStatus();
			std::vector<float> res2 = potentialPlayers[playerID].playerFilter.getStatus();
			float dist = sqrt( (res[0]-res2[0])*(res[0]-res2[0])   + (res[1]-res2[1])*(res[1]-res2[1]))
			if(dist < 1.0) {
				speedScore += 0.5;
				break;
			}
		}
*/

	return speedScore;




}
Exemple #4
0
void Sphere::move(){
    Matrix4 displacement;
    //Matrix4 gravity;
    
    calculateSpeed();
    //std::cout << "Ball x: " << *(center.ptr()) << std::endl;
    //std::cout << "Ball y: " << *(center.ptr()+1) << std::endl;
    //std::cout << "Ball z: " << *(center.ptr()+2) << std::endl;

    if (*center.ptr() >= 10 || *center.ptr() <= -10) {
        x = -x * 0.9;
    }
    if (*(center.ptr()+1) >= 10 || *(center.ptr()+1) <= -10) {
        y = -y * 0.9;
    }
    if (*(center.ptr()+2) >= 10 || *(center.ptr()+2) <= -10) {
        z = -z * 0.9;
    }

    displacement = displacement.makeTranslate(x, s_y, z);
    //gravity = gravity.makeTranslate(0, g, 0);

    toWorld = displacement * toWorld;
    center = displacement * center;
    
    //toWorld = gravity * toWorld;
    //center = gravity * center;
}
Exemple #5
0
/**
 * Changes the speed of the moving target
 * and converts it from standard knots (nautical miles per hour)
 * into radians per 5 in-game seconds.
 * @param speed Speed in knots.
 */
void MovingTarget::setSpeed(int speed)
{
	_speed = speed;
	// Each nautical mile is 1/60th of a degree.
	// Each hour contains 720 5-seconds.
	_speedRadian = _speed * (1 / 60.0) * (M_PI / 180) / 720.0;
	calculateSpeed();
}
void Flywheel::run(){
   switch(getCurrentState()){
      case OFF:
         setRate(0.0);
         break;
      case NOTREADY:
      case READY:
         setRate(calculateSpeed());
         break;
   }
}
void PIDThread::run()
{
    while(1)
    {
        usleep(10000); // 10 ms
        error_last_time = error_this_time;
        error_this_time = targetPosition - currentPosition;
        error_integral += error_this_time;
        double speed = calculateSpeed();
        if (checkEnd(speed)) this->terminate();
        emit updatePosition(RND((currentPosition + speed) * 10));
    }
}
void StepperControlAxis::checkMovement()
{

  checkAxisDirection();

  // Handle movement if destination is not already reached or surpassed
  if (
      (
          (coordDestinationPoint > coordSourcePoint && coordCurrentPoint < coordDestinationPoint) ||
          (coordDestinationPoint < coordSourcePoint && coordCurrentPoint > coordDestinationPoint) ||
          coordHomeAxis) &&
      axisActive)
  {

    // home or destination not reached, keep moving

    // If end stop reached or the encoder doesn't move anymore, stop moving motor, otherwise set the timing for the next step
    if ((coordHomeAxis && !endStopAxisReached(false)) || (!coordHomeAxis && !endStopAxisReached(!movementToHome)))
    {

      // Get the axis speed, in steps per second
      axisSpeed = calculateSpeed(coordSourcePoint, coordCurrentPoint, coordDestinationPoint,
                                 motorSpeedMin, motorSpeedMax, motorStepsAcc);

//      // Set the moments when the step is set to true and false
//      if (axisSpeed > 0)
//      {

        // Take the requested speed (steps / second) and divide by the interrupt speed (interrupts per seconde)
        // This gives the number of interrupts (called ticks here) before the pulse needs to be set for the next step
//        stepOnTick = moveTicks + (1000.0 * 1000.0 / motorInterruptSpeed / axisSpeed / 2);
//        stepOffTick = moveTicks + (1000.0 * 1000.0 / motorInterruptSpeed / axisSpeed);
//      }
    }
    else
    {
      axisActive = false;
    }
  }
  else
  {
    // Destination or home reached. Deactivate the axis.
    axisActive = false;
  }

  // If end stop for home is active, set the position to zero
  if (endStopAxisReached(false))
  {
    coordCurrentPoint = 0;
  }
}
Exemple #9
0
/**
 * Executes a movement cycle for the moving target.
 */
void MovingTarget::move()
{
	calculateSpeed();
	if (_dest != 0)
	{
		if (getDistance(_dest) > _speedRadian)
		{
			setLongitude(_lon + _speedLon);
			setLatitude(_lat + _speedLat);
		}
		else
		{
			setLongitude(_dest->getLongitude());
			setLatitude(_dest->getLatitude());
		}
	}
}
 void AddContolPoint(Vector vp, float t){
     if(n == 1){
         vs[0] = (vp - cps[0]) * (1 / (t-ts[0]));
     }
     if(n < n_circles){
         cps[n] = vp;
         ts[n] = t;
         n++;
     }
     if(n == n_circles){
         cps[n] = cps[0];
         catmull_idoplus = averageTime();
         ts[n] = ts[n-1] + catmull_idoplus;
         vs[n] = vs[0];
         calculateSpeed();
         n++;
     }
 }
Exemple #11
0
/**
 * Changes the destination the moving target is heading to.
 * @param dest Pointer to destination.
 */
void MovingTarget::setDestination(Target *dest)
{
	// Remove moving target from old destination's followers
	if (_dest != 0)
	{
		for (std::vector<Target*>::iterator i = _dest->getFollowers()->begin(); i != _dest->getFollowers()->end(); ++i)
		{
			if ((*i) == this)
			{
				_dest->getFollowers()->erase(i);
				break;
			}
		}
	}
	_dest = dest;
	// Add moving target to new destination's followers
	if (_dest != 0)
	{
		_dest->getFollowers()->push_back(this);
	}
	calculateSpeed();
}
Exemple #12
0
QTime Download::eta() const
{
    calculateSpeed();
    return m_eta;
}
Exemple #13
0
qint64 Download::speedWeighted() const
{
    calculateSpeed();
    return m_weightedSpeed;
}
Exemple #14
0
qint64 Download::speed() const
{
    calculateSpeed();
    return m_speed;
}