Added amplification of gyro rates when applying to head, for more sensitivity, and to allow easily looking to one side and another

This commit is contained in:
Philip Rosedale 2013-05-23 12:17:24 -07:00
parent 7a0ea8bd59
commit eb15aa602c
2 changed files with 11 additions and 11 deletions

View file

@ -128,19 +128,19 @@ void Avatar::reset() {
// Update avatar head rotation with sensor data
void Avatar::updateHeadFromGyros(float deltaTime, SerialInterface* serialInterface, glm::vec3* gravity) {
float measuredPitchRate = 0.0f;
float measuredRollRate = 0.0f;
float measuredYawRate = 0.0f;
const float AMPLIFY_PITCH = 2.f;
const float AMPLIFY_YAW = 2.f;
const float AMPLIFY_ROLL = 2.f;
measuredPitchRate = serialInterface->getLastPitchRate();
measuredYawRate = serialInterface->getLastYawRate();
measuredRollRate = serialInterface->getLastRollRate();
float measuredPitchRate = serialInterface->getLastPitchRate();
float measuredYawRate = serialInterface->getLastYawRate();
float measuredRollRate = serialInterface->getLastRollRate();
// Update avatar head position based on measured gyro rates
_head.addPitch(measuredPitchRate * deltaTime);
_head.addYaw (measuredYawRate * deltaTime);
_head.addRoll (measuredRollRate * deltaTime);
_head.addPitch(measuredPitchRate * AMPLIFY_PITCH * deltaTime);
_head.addYaw (measuredYawRate * AMPLIFY_YAW * deltaTime);
_head.addRoll (measuredRollRate * AMPLIFY_ROLL * deltaTime);
// Update head lean distance based on accelerometer data
glm::vec3 headRotationRates(_head.getPitch(), _head.getYaw(), _head.getRoll());

View file

@ -76,10 +76,10 @@ void Head::simulate(float deltaTime, bool isMine) {
_roll *= (1.0f - HEAD_MOTION_DECAY * _returnSpringScale * deltaTime);
}
// For invensense gyro, decay only slightly when roughly centered
// For invensense gyro, decay only slightly when near center (until we add fusion)
if (isMine) {
const float RETURN_RANGE = 15.0;
const float RETURN_STRENGTH = 2.0;
const float RETURN_STRENGTH = 0.5;
if (fabs(_pitch) < RETURN_RANGE) { _pitch *= (1.0f - RETURN_STRENGTH * deltaTime); }
if (fabs(_yaw ) < RETURN_RANGE) { _yaw *= (1.0f - RETURN_STRENGTH * deltaTime); }
if (fabs(_roll ) < RETURN_RANGE) { _roll *= (1.0f - RETURN_STRENGTH * deltaTime); }