void VerticalSpinePassiveController::onStep(VerticalSpineModel& subject, double dt)
{
  // first, check if our input arguments are sane
  if( dt <= 0.0)
  {
    throw std::invalid_argument("dt is not positive");
  }
  else
  {
    // check our update time. This is so that samples are taken only every
    // certain number of steps, not all the time.
    updateTime += dt;
    if( updateTime >= m_updateTime )
    {
      // Take a step: call the observers' step function.
      // TO FIX: why do we have to call the data logger's onStep individually?
      notifyStep(updateTime);
      m_dataObserver.onStep(subject, updateTime);
      // then, reset the counter to zero
      updateTime = 0.0;
    }
  } 
  // log only.
  //notifyStep(dt);
  //m_dataObserver.onStep(subject, dt);
}
void TensegrityModel::step(double timeStep) {
    if (timeStep <= 0.0) {
        throw std::invalid_argument("time step is not positive");
    }
    else {
        notifyStep(timeStep);
        tgModel::step(timeStep);
    }
}
Esempio n. 3
0
void CraterDeep::step(double dt) {
    // Precondition
    if (dt <= 0.0) {
        throw std::invalid_argument("dt is not positive");
    }
    else { //Notify observers (controllers) of the step so that they can take action
        notifyStep(dt);
        tgModel::step(dt); // Step any children
    }
}
Esempio n. 4
0
void DuCTTTestModel::step(double dt)
{
    if (dt < 0.0)
    {
        throw std::invalid_argument("dt is not positive");
    }
    else
    {
        // Notify observers (controllers) of the step so that they can take action
        notifyStep(dt);
        // Step any children
        tgModel::step(dt);
    }
}
Esempio n. 5
0
void RPModel::step(double dt)
{
  // Precondition
  if (dt <= 0.0)
    {
      throw std::invalid_argument("dt is not positive");
    }
  else
    {
      // Notify observers (controllers) of the step so that they can take action
      notifyStep(dt);
      tgModel::step(dt);  // Step any children
    }
  for(int k=1;k<36;k++){
    std::cout << allActuators[k]->getTension() << " ";
  }
  std::cout << std::endl;
  
}
Esempio n. 6
0
void RadiosityRenderer::compute() {
    for(currentStep_=0; currentStep_<stepCount_; currentStep_++) {
        notifyStep();
        this->computeStep();
    }
}
void VerticalSpineBendingController::onStep(VerticalSpineModel& subject, double dt)
 {
     if (dt <= 0.0)
     {
         throw std::invalid_argument("dt is not positive");
     }
     else
       {
 	updateTime += dt;
 	if (updateTime >= 1.0/100)  //Speed of actuators
 	  {
 	    updateTime = 0.0;

	    // logging
	    notifyStep(m_updateTime);
	    m_dataObserver.onStep(subject, m_updateTime);

 	    // Bend & Unbend
 	    if(verticalRLA1 <= 2.0 && state == -1.0)  //min length of cable
 	      {
 		state = 1.0;
 	      }
 	    else if (verticalRLA1 >= 4.0 && state == 1.0)  //stop at upright position
 	      {
 		state = -1.0;
 	      }

 	    if (state == -1.0)
 	      {
 		verticalRLA1 -= dL;
 		verticalRLB1 += dL;
 	      }
 	    else if (state == 1.0)
 	      {
 		verticalRLA1 += dL;
 		verticalRLB1 -= dL;
 	      }
 	  }
	
         // First, get all muscles (cables)
         const std::vector<tgSpringCableActuator*> muscles = subject.getAllMuscles();
        
         // get all vertical muscles
         const std::vector<tgSpringCableActuator*> v_musclesA = subject.getMuscles("vertical a");
         const std::vector<tgSpringCableActuator*> v_musclesB = subject.getMuscles("vertical b");
         const std::vector<tgSpringCableActuator*> v_musclesC = subject.getMuscles("vertical c");
         const std::vector<tgSpringCableActuator*> v_musclesD = subject.getMuscles("vertical d");
        

         // set string length for vertical muscles
         for (size_t i = 0; i < v_musclesA.size(); ++ i)
         {
 	    //A   **Contracting Cable
             tgSpringCableActuator * const pMuscleA = v_musclesA[i];
             assert(pMuscleA != NULL);
             pMuscleA->setControlInput(verticalRLA1,dt);
           
             //B   **Elongating Cable
             tgSpringCableActuator * const pMuscleB = v_musclesB[i];
             assert(pMuscleB != NULL);
             pMuscleB->setControlInput(verticalRLB1,dt);
            
             // //C
             // tgBasicActuator * const pMuscleC = v_musclesC[i];
             // assert(pMuscleC != NULL);
             // pMuscleC->setControlInput(verticalRL);
            
             // //D
             // tgBasicActuator * const pMuscleD = v_musclesD[i];
             // assert(pMuscleD != NULL);
             // pMuscleD->setControlInput(verticalRL);
         }
      
     }
}