// get PHANTOM state and update shared data void updatePhantom(void) { // initialize frequency counter p_sharedData->phantomFreqCounter.reset(); while(p_sharedData->simulationRunning) { if (p_sharedData->m_phantomLoopTimer.timeoutOccurred()) { p_sharedData->m_phantomLoopTimer.stop(); if (p_sharedData->input == PHANTOM) { // get PHANTOM position and velocity vectors p_sharedData->p_Phantom->getPosition(pos); p_sharedData->p_Phantom->getLinearVelocity(vel); // extract X elements from vectors p_sharedData->phantomPos = pos.y(); p_sharedData->phantomVel = vel.y(); // update frequency counter p_sharedData->phantomFreqCounter.signal(1); } p_sharedData->m_phantomLoopTimer.start(true); Sleep(1); } } }
void updateGraphics(void) { int px; // update position of label labelHapticDeviceModel->setLocalPos(10, displayH - 30, 0.0); // update position of label and content double posX = 1000 * hapticDevicePosition.x(); double posY = 1000 * hapticDevicePosition.y(); double posZ = 1000 * hapticDevicePosition.z(); labelHapticDevicePosition->setString("position [mm]: " + cStr(posX, 0) + " " + cStr(posY, 0) + " " + cStr(posZ, 0)); labelHapticDevicePosition->setLocalPos(10, displayH - 50, 0.0); // update haptic rate label labelHapticRate->setString ("haptic rate: "+cStr(frequencyCounter.getFrequency(), 0) + " [Hz]"); px = (int)(0.5 * (displayW - labelHapticRate->getWidth())); labelHapticRate->setLocalPos(px, 15); // render world camera->renderView(displayW, displayH); // swap buffers glutSwapBuffers(); // check for any OpenGL errors GLenum err; err = glGetError(); if (err != GL_NO_ERROR) printf("Error: %s\n", gluErrorString(err)); }