From 69ec10958537760ca0f22e5ac1a83fb1f80a80e0 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 31 May 2013 15:28:15 -0700 Subject: [PATCH 1/4] Refactor/Cleanup serial interface to use vectors, correct rotation axes. Added translation estimation for the head. --- interface/src/SerialInterface.cpp | 111 +++++++++++++++++------------- interface/src/SerialInterface.h | 56 +++++++-------- 2 files changed, 86 insertions(+), 81 deletions(-) diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index b730d2a907..2fa078baf4 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -111,52 +111,61 @@ void SerialInterface::renderLevels(int width, int height) { const int LEVEL_CORNER_Y = 200; // Draw the numeric degree/sec values from the gyros - sprintf(val, "Yaw %4.1f", getLastYawRate()); + sprintf(val, "Yaw %4.1f", _estimatedRotation.y); drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y, 0.10, 0, 1.0, 1, val, 0, 1, 0); - sprintf(val, "Pitch %4.1f", getLastPitchRate()); + sprintf(val, "Pitch %4.1f", _estimatedRotation.x); drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 15, 0.10, 0, 1.0, 1, val, 0, 1, 0); - sprintf(val, "Roll %4.1f", getLastRollRate()); + sprintf(val, "Roll %4.1f", _estimatedRotation.z); drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 30, 0.10, 0, 1.0, 1, val, 0, 1, 0); - sprintf(val, "X %4.3f", _lastAccelX); + sprintf(val, "X %4.3f", _lastAcceleration.x - _gravity.x); drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 45, 0.10, 0, 1.0, 1, val, 0, 1, 0); - sprintf(val, "Y %4.3f", _lastAccelY); + sprintf(val, "Y %4.3f", _lastAcceleration.y - _gravity.y); drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 60, 0.10, 0, 1.0, 1, val, 0, 1, 0); - sprintf(val, "Z %4.3f", _lastAccelZ); + sprintf(val, "Z %4.3f", _lastAcceleration.z - _gravity.z); drawtext(LEVEL_CORNER_X, LEVEL_CORNER_Y + 75, 0.10, 0, 1.0, 1, val, 0, 1, 0); // Draw the levels as horizontal lines const int LEVEL_CENTER = 150; - const float ACCEL_VIEW_SCALING = 50.f; + const float ACCEL_VIEW_SCALING = 10.f; + const float POSITION_SCALING = 400.f; + glLineWidth(2.0); - glColor4f(1, 1, 1, 1); glBegin(GL_LINES); - // Gyro rates + // Rotation rates + glColor4f(1, 1, 1, 1); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y - 3); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + getLastYawRate(), LEVEL_CORNER_Y - 3); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 12); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + getLastPitchRate(), LEVEL_CORNER_Y + 12); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 27); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + getLastRollRate(), LEVEL_CORNER_Y + 27); - // Gyro Estimated Rotation + // Estimated Rotation glColor4f(0, 1, 1, 1); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y - 1); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _estimatedRotation.y, LEVEL_CORNER_Y - 1); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 14); - glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _estimatedRotation.z, LEVEL_CORNER_Y + 14); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _estimatedRotation.x, LEVEL_CORNER_Y + 14); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 29); - glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _estimatedRotation.x, LEVEL_CORNER_Y + 29); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + _estimatedRotation.z, LEVEL_CORNER_Y + 29); - - // Acceleration + // Acceleration rates + glColor4f(1, 1, 1, 1); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 42); - glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)((_lastAccelX - _gravity.x)* ACCEL_VIEW_SCALING), - LEVEL_CORNER_Y + 42); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)((_lastAcceleration.x - _gravity.x) *ACCEL_VIEW_SCALING), LEVEL_CORNER_Y + 42); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 57); - glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)((_lastAccelY - _gravity.y) * ACCEL_VIEW_SCALING), - LEVEL_CORNER_Y + 57); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)((_lastAcceleration.y - _gravity.y) *ACCEL_VIEW_SCALING), LEVEL_CORNER_Y + 57); glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 72); - glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)((_lastAccelZ - _gravity.z) * ACCEL_VIEW_SCALING), - LEVEL_CORNER_Y + 72); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)((_lastAcceleration.z - _gravity.z) * ACCEL_VIEW_SCALING), LEVEL_CORNER_Y + 72); + + // Estimated Position + glColor4f(0, 1, 1, 1); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 44); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)(_estimatedPosition.x * POSITION_SCALING), LEVEL_CORNER_Y + 44); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 59); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)(_estimatedPosition.y * POSITION_SCALING), LEVEL_CORNER_Y + 59); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER, LEVEL_CORNER_Y + 74); + glVertex2f(LEVEL_CORNER_X + LEVEL_CENTER + (int)(_estimatedPosition.z * POSITION_SCALING), LEVEL_CORNER_Y + 74); + glEnd(); // Draw green vertical centerline @@ -202,10 +211,8 @@ void SerialInterface::readData(float deltaTime) { // From MPU-9150 register map, with setting on // highest resolution = +/- 2G - _lastAccelX = ((float) accelXRate) * LSB_TO_METERS_PER_SECOND2; - _lastAccelY = ((float) accelYRate) * LSB_TO_METERS_PER_SECOND2; - _lastAccelZ = ((float) -accelZRate) * LSB_TO_METERS_PER_SECOND2; - + _lastAcceleration = glm::vec3(accelXRate, accelYRate, -accelZRate) * LSB_TO_METERS_PER_SECOND2; + int rollRate, yawRate, pitchRate; convertHexToInt(sensorBuffer + 22, rollRate); @@ -213,38 +220,41 @@ void SerialInterface::readData(float deltaTime) { convertHexToInt(sensorBuffer + 30, pitchRate); // Convert the integer rates to floats - const float LSB_TO_DEGREES_PER_SECOND = 1.f / 16.4f; // From MPU-9150 register map, 2000 deg/sec. - _lastRollRate = ((float) -rollRate) * LSB_TO_DEGREES_PER_SECOND; - _lastYawRate = ((float) -yawRate) * LSB_TO_DEGREES_PER_SECOND; - _lastPitchRate = ((float) -pitchRate) * LSB_TO_DEGREES_PER_SECOND; - + const float LSB_TO_DEGREES_PER_SECOND = 1.f / 16.4f; // From MPU-9150 register map, 2000 deg/sec. + _lastRotationRates[0] = ((float) -pitchRate) * LSB_TO_DEGREES_PER_SECOND; + _lastRotationRates[1] = ((float) -yawRate) * LSB_TO_DEGREES_PER_SECOND; + _lastRotationRates[2] = ((float) -rollRate) * LSB_TO_DEGREES_PER_SECOND; + // Update raw rotation estimates - _estimatedRotation += deltaTime * glm::vec3(_lastRollRate - _averageGyroRates[0], - _lastYawRate - _averageGyroRates[1], - _lastPitchRate - _averageGyroRates[2]); + _estimatedRotation += deltaTime * (_lastRotationRates - _averageRotationRates); + + // Update estimated position and velocity + float const DECAY_VELOCITY = 0.95f; + float const DECAY_POSITION = 0.95f; + _estimatedVelocity += deltaTime * (_lastAcceleration - _averageAcceleration); + _estimatedPosition += deltaTime * _estimatedVelocity; + _estimatedVelocity *= DECAY_VELOCITY; + _estimatedPosition *= DECAY_POSITION; + + //glm::vec3 baseline = glm::normalize(_gravity); + //glm::vec3 current = glm::normalize(_lastAcceleration); // Accumulate a set of initial baseline readings for setting gravity if (totalSamples == 0) { - _averageGyroRates[0] = _lastRollRate; - _averageGyroRates[1] = _lastYawRate; - _averageGyroRates[2] = _lastPitchRate; - _gravity.x = _lastAccelX; - _gravity.y = _lastAccelY; - _gravity.z = _lastAccelZ; - + _averageRotationRates = _lastRotationRates; + _averageAcceleration = _lastAcceleration; + _gravity = _lastAcceleration; } else { // Cumulate long term average to (hopefully) take DC bias out of rotation rates - _averageGyroRates[0] = (1.f - 1.f/(float)LONG_TERM_RATE_SAMPLES) * _averageGyroRates[0] + - 1.f/(float)LONG_TERM_RATE_SAMPLES * _lastRollRate; - _averageGyroRates[1] = (1.f - 1.f/(float)LONG_TERM_RATE_SAMPLES) * _averageGyroRates[1] + - 1.f/(float)LONG_TERM_RATE_SAMPLES * _lastYawRate; - _averageGyroRates[2] = (1.f - 1.f/(float)LONG_TERM_RATE_SAMPLES) * _averageGyroRates[2] + - 1.f/(float)LONG_TERM_RATE_SAMPLES * _lastPitchRate; - + _averageRotationRates = (1.f - 1.f / (float)LONG_TERM_RATE_SAMPLES) * _averageRotationRates + + 1.f / (float)LONG_TERM_RATE_SAMPLES * _lastRotationRates; + _averageAcceleration = (1.f - 1.f / (float)LONG_TERM_RATE_SAMPLES) * _averageAcceleration + + 1.f / (float)LONG_TERM_RATE_SAMPLES * _lastAcceleration; + if (totalSamples < GRAVITY_SAMPLES) { _gravity = (1.f - 1.f/(float)GRAVITY_SAMPLES) * _gravity + - 1.f/(float)GRAVITY_SAMPLES * glm::vec3(_lastAccelX, _lastAccelY, _lastAccelZ); + 1.f/(float)GRAVITY_SAMPLES * _lastAcceleration; } } @@ -268,7 +278,12 @@ void SerialInterface::readData(float deltaTime) { void SerialInterface::resetAverages() { totalSamples = 0; _gravity = glm::vec3(0, 0, 0); - _averageGyroRates = glm::vec3(0, 0, 0); + _averageRotationRates = glm::vec3(0, 0, 0); + _averageAcceleration = glm::vec3(0, 0, 0); + _lastRotationRates = glm::vec3(0, 0, 0); + _estimatedRotation = glm::vec3(0, 0, 0); + _estimatedPosition = glm::vec3(0, 0, 0); + _estimatedVelocity = glm::vec3(0, 0, 0); } void SerialInterface::resetSerial() { diff --git a/interface/src/SerialInterface.h b/interface/src/SerialInterface.h index 42d24367f6..50baf5e98f 100644 --- a/interface/src/SerialInterface.h +++ b/interface/src/SerialInterface.h @@ -20,41 +20,32 @@ #include #endif -#define NUM_CHANNELS 6 - -// Acceleration sensors, in screen/world coord system (X = left/right, Y = Up/Down, Z = fwd/back) -#define ACCEL_X 3 -#define ACCEL_Y 4 -#define ACCEL_Z 5 - -// Gyro sensors, in coodinate system of head/airplane -#define HEAD_PITCH_RATE 1 -#define HEAD_YAW_RATE 0 -#define HEAD_ROLL_RATE 2 - extern const bool USING_INVENSENSE_MPU9150; class SerialInterface { public: SerialInterface() : active(false), - _gravity(0,0,0), - _averageGyroRates(0, 0, 0), + _gravity(0, 0, 0), + _averageRotationRates(0, 0, 0), + _averageAcceleration(0, 0, 0), _estimatedRotation(0, 0, 0), - _lastAccelX(0), - _lastAccelY(0), - _lastAccelZ(0), - _lastYawRate(0), - _lastPitchRate(0), - _lastRollRate(0) {} + _estimatedPosition(0, 0, 0), + _estimatedVelocity(0, 0, 0), + _lastAcceleration(0, 0, 0), + _lastRotationRates(0, 0, 0) + {} void pair(); void readData(float deltaTime); - - float getLastYawRate() const { return _lastYawRate - _averageGyroRates[1]; } - float getLastPitchRate() const { return _lastPitchRate - _averageGyroRates[2]; } - float getLastRollRate() const { return _lastRollRate - _averageGyroRates[0]; } - glm::vec3 getLastAcceleration() { return glm::vec3(_lastAccelX, _lastAccelY, _lastAccelZ); }; - glm::vec3 getGravity() {return _gravity;}; + const float getLastPitchRate() const { return _lastRotationRates[0] - _averageRotationRates[0]; } + const float getLastYawRate() const { return _lastRotationRates[1] - _averageRotationRates[1]; } + const float getLastRollRate() const { return _lastRotationRates[2] - _averageRotationRates[2]; } + const glm::vec3 getLastRotationRates() const { return _lastRotationRates; }; + const glm::vec3 getEstimatedRotation() const { return _estimatedRotation; }; + const glm::vec3 getEstimatedPosition() const { return _estimatedPosition; }; + const glm::vec3 getEstimatedVelocity() const { return _estimatedVelocity; }; + const glm::vec3 getLastAcceleration() const { return _lastAcceleration; }; + const glm::vec3 getGravity() const { return _gravity; }; void renderLevels(int width, int height); void resetAverages(); @@ -68,14 +59,13 @@ private: int totalSamples; timeval lastGoodRead; glm::vec3 _gravity; - glm::vec3 _averageGyroRates; + glm::vec3 _averageRotationRates; + glm::vec3 _averageAcceleration; glm::vec3 _estimatedRotation; - float _lastAccelX; - float _lastAccelY; - float _lastAccelZ; - float _lastYawRate; // Rates are in degrees per second. - float _lastPitchRate; - float _lastRollRate; + glm::vec3 _estimatedPosition; + glm::vec3 _estimatedVelocity; + glm::vec3 _lastAcceleration; + glm::vec3 _lastRotationRates; }; #endif From da343215ceac4805e93ab238e0548bb918370ba9 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 3 Jun 2013 17:25:20 -0700 Subject: [PATCH 2/4] Rename serialPort to serialHeadSensor, added passing of lean to eyeOffset --- interface/src/Application.cpp | 60 ++++++++++++++++++++--------------- interface/src/Application.h | 2 +- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4dd3dba178..f3e4eb2c3b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -908,8 +908,8 @@ void Application::timer() { gettimeofday(&_timerStart, NULL); // if we haven't detected gyros, check for them now - if (!_serialPort.active) { - _serialPort.pair(); + if (!_serialHeadSensor.active) { + _serialHeadSensor.pair(); } } @@ -1044,8 +1044,8 @@ void Application::idle() { } // Read serial port interface devices - if (_serialPort.active) { - _serialPort.readData(deltaTime); + if (_serialHeadSensor.active) { + _serialHeadSensor.readData(deltaTime); } // Update transmitter @@ -1446,26 +1446,36 @@ void Application::init() { } void Application::updateAvatar(float deltaTime) { - // Update my avatar's head position from gyros - _myAvatar.updateHeadFromGyros(deltaTime, &_serialPort); - // Grab latest readings from the gyros - float measuredPitchRate = _serialPort.getLastPitchRate(); - float measuredYawRate = _serialPort.getLastYawRate(); - - // Update gyro-based mouse (X,Y on screen) - const float MIN_MOUSE_RATE = 3.0; - const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f; - const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f; - if (powf(measuredYawRate * measuredYawRate + - measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) { - _headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime; - _headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime; + if (_serialHeadSensor.active) { + glm::vec3 headPosition = _serialHeadSensor.getEstimatedPosition(); + const float HEAD_OFFSET_SCALING = 3.f; + headPosition *= HEAD_OFFSET_SCALING; + _myCamera.setEyeOffsetPosition(headPosition); + + // Update my avatar's head position from gyros + //_myAvatar.updateHeadFromGyros(deltaTime, &_serialHeadSensor); + + // Grab latest readings from the gyros + float measuredPitchRate = _serialHeadSensor.getLastPitchRate(); + float measuredYawRate = _serialHeadSensor.getLastYawRate(); + + // Update gyro-based mouse (X,Y on screen) + const float MIN_MOUSE_RATE = 3.0; + const float HORIZONTAL_PIXELS_PER_DEGREE = 2880.f / 45.f; + const float VERTICAL_PIXELS_PER_DEGREE = 1800.f / 30.f; + if (powf(measuredYawRate * measuredYawRate + + measuredPitchRate * measuredPitchRate, 0.5) > MIN_MOUSE_RATE) { + _headMouseX -= measuredYawRate * HORIZONTAL_PIXELS_PER_DEGREE * deltaTime; + _headMouseY -= measuredPitchRate * VERTICAL_PIXELS_PER_DEGREE * deltaTime; + } + _headMouseX = max(_headMouseX, 0); + _headMouseX = min(_headMouseX, _glWidget->width()); + _headMouseY = max(_headMouseY, 0); + _headMouseY = min(_headMouseY, _glWidget->height()); + } - _headMouseX = max(_headMouseX, 0); - _headMouseX = min(_headMouseX, _glWidget->width()); - _headMouseY = max(_headMouseY, 0); - _headMouseY = min(_headMouseY, _glWidget->height()); + if (OculusManager::isConnected()) { float yaw, pitch, roll; @@ -1890,7 +1900,7 @@ void Application::displayOverlay() { } // Show detected levels from the serial I/O ADC channel sensors - if (_displayLevels) _serialPort.renderLevels(_glWidget->width(), _glWidget->height()); + if (_displayLevels) _serialHeadSensor.renderLevels(_glWidget->width(), _glWidget->height()); // Show hand transmitter data if detected if (_myTransmitter.isConnected()) { @@ -2253,8 +2263,8 @@ void Application::resetSensors() { _headMouseX = _mouseX = _glWidget->width() / 2; _headMouseY = _mouseY = _glWidget->height() / 2; - if (_serialPort.active) { - _serialPort.resetAverages(); + if (_serialHeadSensor.active) { + _serialHeadSensor.resetAverages(); } QCursor::setPos(_headMouseX, _headMouseY); _myAvatar.reset(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 22694aaae5..3baa93e821 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -226,7 +226,7 @@ private: QAction* _fullScreenMode; // whether we are in full screen mode QAction* _frustumRenderModeAction; - SerialInterface _serialPort; + SerialInterface _serialHeadSensor; bool _displayLevels; glm::vec3 _gravity; From 5e0a70c52423988042b5806044e7b55bef3e730a Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Mon, 3 Jun 2013 17:36:32 -0700 Subject: [PATCH 3/4] gyro look controls head offset on/off --- interface/src/Application.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f3e4eb2c3b..f070bee823 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1448,13 +1448,17 @@ void Application::init() { void Application::updateAvatar(float deltaTime) { if (_serialHeadSensor.active) { - glm::vec3 headPosition = _serialHeadSensor.getEstimatedPosition(); - const float HEAD_OFFSET_SCALING = 3.f; - headPosition *= HEAD_OFFSET_SCALING; - _myCamera.setEyeOffsetPosition(headPosition); + + // Update avatar head translation + if (_gyroLook->isChecked()) { + glm::vec3 headPosition = _serialHeadSensor.getEstimatedPosition(); + const float HEAD_OFFSET_SCALING = 3.f; + headPosition *= HEAD_OFFSET_SCALING; + _myCamera.setEyeOffsetPosition(headPosition); + } // Update my avatar's head position from gyros - //_myAvatar.updateHeadFromGyros(deltaTime, &_serialHeadSensor); + _myAvatar.updateHeadFromGyros(deltaTime, &_serialHeadSensor); // Grab latest readings from the gyros float measuredPitchRate = _serialHeadSensor.getLastPitchRate(); From 29c4374dc0df2d3e2e80c282ca5b56ae3facd3da Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 5 Jun 2013 09:59:39 -0700 Subject: [PATCH 4/4] Merge fixes for brad, reversed pitch direction to correct mouse look --- interface/src/Application.h | 1 - interface/src/Avatar.cpp | 2 +- interface/src/SerialInterface.h | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index 9d37925c05..5c987f0062 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -292,7 +292,6 @@ private: int _bytesPerSecond; int _bytesCount; - QSettings* _settings; // Contain Menu settings and Avatar data bool _autosave; // True if the autosave is on. }; diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 49b83dd670..d8178ca643 100644 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -353,7 +353,7 @@ void Avatar::updateFromMouse(int mouseX, int mouseY, int screenWidth, int scree if (fabs(mouseLocationY) > MOUSE_MOVE_RADIUS) { float mousePitchAdd = (fabs(mouseLocationY) - MOUSE_MOVE_RADIUS) / (0.5f - MOUSE_MOVE_RADIUS) * MOUSE_PITCH_SPEED; bool downPitching = (mouseLocationY > 0.f); - _head.setPitch(_head.getPitch() + (downPitching ? mousePitchAdd : -mousePitchAdd)); + _head.setPitch(_head.getPitch() + (downPitching ? -mousePitchAdd : mousePitchAdd)); } } diff --git a/interface/src/SerialInterface.h b/interface/src/SerialInterface.h index 50baf5e98f..3fc9ea920a 100644 --- a/interface/src/SerialInterface.h +++ b/interface/src/SerialInterface.h @@ -40,12 +40,12 @@ public: const float getLastPitchRate() const { return _lastRotationRates[0] - _averageRotationRates[0]; } const float getLastYawRate() const { return _lastRotationRates[1] - _averageRotationRates[1]; } const float getLastRollRate() const { return _lastRotationRates[2] - _averageRotationRates[2]; } - const glm::vec3 getLastRotationRates() const { return _lastRotationRates; }; - const glm::vec3 getEstimatedRotation() const { return _estimatedRotation; }; - const glm::vec3 getEstimatedPosition() const { return _estimatedPosition; }; - const glm::vec3 getEstimatedVelocity() const { return _estimatedVelocity; }; - const glm::vec3 getLastAcceleration() const { return _lastAcceleration; }; - const glm::vec3 getGravity() const { return _gravity; }; + const glm::vec3& getLastRotationRates() const { return _lastRotationRates; }; + const glm::vec3& getEstimatedRotation() const { return _estimatedRotation; }; + const glm::vec3& getEstimatedPosition() const { return _estimatedPosition; }; + const glm::vec3& getEstimatedVelocity() const { return _estimatedVelocity; }; + const glm::vec3& getLastAcceleration() const { return _lastAcceleration; }; + const glm::vec3& getGravity() const { return _gravity; }; void renderLevels(int width, int height); void resetAverages();