示例#1
0
文件: glquad.cpp 项目: dwsaxton/quad
void GLQuad::paintGL()
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
  setupView();
  drawAxes();
  drawIntercept();

  glColor3f(0.8,0.5,0.5);
  Quad *quad = Globals::self().simulatedQuad();
  drawQuad(quad->state(), quad->propInput());
  glColor3f(0.5,0.5,0.8);
  drawQuad(Globals::self().imu()->lastState(), Globals::self().propellers()->input());
  glColor3f(0.5,0.5,0.5);
  quad = Globals::self().remoteQuad();
  drawQuad(quad->state(), quad->propInput());
}
示例#2
0
void Interface::updateLabels()
{
  bool isSimulation = Globals::self().isSimulation();
  Quad *quad;
  if (isSimulation) {
    quad = Globals::self().simulatedQuad();
  } else {
    quad = Globals::self().remoteQuad();
  }
   
  QuadState state = quad->state();

  positionLabel->setText( toCoords( state.pos ) );
  velocityLabel->setText( toCoords( state.vel ) );

  Vector3d accel = Globals::self().imu()->lastAcceleration();
  Vector3d gyro = Globals::self().imu()->lastAngularAcceleration();

  accelerometersLabel->setText(toCoords(accel));
  gyroLabel->setText(toCoords(gyro, 3));

  // Update plot 
  double duration = quad->path_ != nullptr ? quad->path_->duration() : 0;
  interceptPlot->setIntercept(quad->intercept, duration);

  runPauseSimulationButton->setText(Globals::self().isSimulatedQuadRunning() ? "Pause" : "Run");

  Vector4d propInput = Globals::self().propellers()->input();

  // Update slider values
  for ( int i = 0; i < 4; ++i ) {
    double p = propInput[i];
    int v = int(p * m_propInputs[i]->maximum());
    m_propInputs[i]->setValue( v );
  }
}