mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:23:33 +02:00
Head improvements
This commit is contained in:
parent
eba62cf136
commit
f0d432d98d
5 changed files with 28 additions and 20 deletions
|
@ -28,6 +28,9 @@ const int ECHO_SERVER_TEST = 1;
|
||||||
|
|
||||||
const int AUDIO_UDP_LISTEN_PORT = 55444;
|
const int AUDIO_UDP_LISTEN_PORT = 55444;
|
||||||
|
|
||||||
|
char WORKCLUB_AUDIO_SERVER[] = "192.168.1.19";
|
||||||
|
char EC2_WEST_AUDIO_SERVER[] = "54.241.92.53";
|
||||||
|
|
||||||
pthread_mutex_t jitterMutex;
|
pthread_mutex_t jitterMutex;
|
||||||
|
|
||||||
#define LOG_SAMPLE_DELAY 1
|
#define LOG_SAMPLE_DELAY 1
|
||||||
|
@ -71,7 +74,7 @@ int audioCallback (const void *inputBuffer,
|
||||||
// int16_t *inputRight = ((int16_t **) inputBuffer)[1];
|
// int16_t *inputRight = ((int16_t **) inputBuffer)[1];
|
||||||
|
|
||||||
if (inputLeft != NULL) {
|
if (inputLeft != NULL) {
|
||||||
data->audioSocket->send((char *) "192.168.1.19", 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES);
|
data->audioSocket->send((char *) EC2_WEST_AUDIO_SERVER, 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t *outputLeft = ((int16_t **) outputBuffer)[0];
|
int16_t *outputLeft = ((int16_t **) outputBuffer)[0];
|
||||||
|
|
|
@ -69,18 +69,18 @@ void Head::UpdatePos(float frametime, SerialInterface * serialInterface, int hea
|
||||||
float measured_roll_rate = serialInterface->getRelativeValue(ROLL_RATE);
|
float measured_roll_rate = serialInterface->getRelativeValue(ROLL_RATE);
|
||||||
|
|
||||||
// Update avatar head position based on measured gyro rates
|
// Update avatar head position based on measured gyro rates
|
||||||
const float HEAD_ROTATION_SCALE = 0.20;
|
const float HEAD_ROTATION_SCALE = 0.80;
|
||||||
const float HEAD_ROLL_SCALE = 0.50;
|
const float HEAD_ROLL_SCALE = 0.80;
|
||||||
const float HEAD_LEAN_SCALE = 0.02;
|
const float HEAD_LEAN_SCALE = 0.01;
|
||||||
if (head_mirror) {
|
if (head_mirror) {
|
||||||
addYaw(measured_yaw_rate * HEAD_ROTATION_SCALE * frametime);
|
addYaw(-measured_yaw_rate * HEAD_ROTATION_SCALE * frametime);
|
||||||
addPitch(measured_pitch_rate * -HEAD_ROTATION_SCALE * frametime);
|
addPitch(measured_pitch_rate * -HEAD_ROTATION_SCALE * frametime);
|
||||||
addRoll(measured_roll_rate * HEAD_ROLL_SCALE * frametime);
|
addRoll(-measured_roll_rate * HEAD_ROLL_SCALE * frametime);
|
||||||
addLean(measured_lateral_accel * frametime * HEAD_LEAN_SCALE, measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
addLean(-measured_lateral_accel * frametime * HEAD_LEAN_SCALE, -measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
||||||
} else {
|
} else {
|
||||||
addYaw(measured_yaw_rate * -HEAD_ROTATION_SCALE * frametime);
|
addYaw(measured_yaw_rate * -HEAD_ROTATION_SCALE * frametime);
|
||||||
addPitch(measured_pitch_rate * -HEAD_ROTATION_SCALE * frametime);
|
addPitch(measured_pitch_rate * -HEAD_ROTATION_SCALE * frametime);
|
||||||
addRoll(measured_roll_rate * HEAD_ROLL_SCALE * frametime);
|
addRoll(-measured_roll_rate * HEAD_ROLL_SCALE * frametime);
|
||||||
addLean(measured_lateral_accel * frametime * -HEAD_LEAN_SCALE, measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
addLean(measured_lateral_accel * frametime * -HEAD_LEAN_SCALE, measured_fwd_accel*frametime * HEAD_LEAN_SCALE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ char serial_buffer[MAX_BUFFER];
|
||||||
int serial_buffer_pos = 0;
|
int serial_buffer_pos = 0;
|
||||||
int samples_total = 0;
|
int samples_total = 0;
|
||||||
|
|
||||||
|
const int ZERO_OFFSET = 2048;
|
||||||
|
|
||||||
// Init the serial port to the specified values
|
// Init the serial port to the specified values
|
||||||
int SerialInterface::init(char * portname, int baud)
|
int SerialInterface::init(char * portname, int baud)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +81,7 @@ void SerialInterface::renderLevels(int width, int height) {
|
||||||
char val[10];
|
char val[10];
|
||||||
for(i = 0; i < NUM_CHANNELS; i++)
|
for(i = 0; i < NUM_CHANNELS; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Actual value
|
// Actual value
|
||||||
glLineWidth(2.0);
|
glLineWidth(2.0);
|
||||||
glColor4f(1, 1, 1, 1);
|
glColor4f(1, 1, 1, 1);
|
||||||
|
@ -93,12 +96,14 @@ void SerialInterface::renderLevels(int width, int height) {
|
||||||
glVertex2f(disp_x + 2, height*(0.25 + 0.75f*getTrailingValue(i)/4096));
|
glVertex2f(disp_x + 2, height*(0.25 + 0.75f*getTrailingValue(i)/4096));
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
/*
|
||||||
glColor3f(1,0,0);
|
glColor3f(1,0,0);
|
||||||
glBegin(GL_LINES);
|
glBegin(GL_LINES);
|
||||||
glLineWidth(2.0);
|
glLineWidth(4.0);
|
||||||
glVertex2f(disp_x - 10, height*0.5 - getRelativeValue(i));
|
glVertex2f(disp_x - 10, height*0.5 - getValue(i)/4096);
|
||||||
glVertex2f(disp_x + 10, height*0.5 - getRelativeValue(i));
|
glVertex2f(disp_x + 10, height*0.5 - getValue(i)/4096);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
*/
|
||||||
sprintf(val, "%d", getValue(i));
|
sprintf(val, "%d", getValue(i));
|
||||||
drawtext(disp_x-GAP/2, (height*0.95)+2, 0.08, 90, 1.0, 0, val, 0, 1, 0);
|
drawtext(disp_x-GAP/2, (height*0.95)+2, 0.08, 90, 1.0, 0, val, 0, 1, 0);
|
||||||
|
|
||||||
|
@ -120,7 +125,7 @@ void SerialInterface::renderLevels(int width, int height) {
|
||||||
void SerialInterface::readData() {
|
void SerialInterface::readData() {
|
||||||
// This array sets the rate of trailing averaging for each channel.
|
// This array sets the rate of trailing averaging for each channel.
|
||||||
// If the sensor rate is 100Hz, 0.001 will make the long term average a 10-second average
|
// If the sensor rate is 100Hz, 0.001 will make the long term average a 10-second average
|
||||||
const float AVG_RATE[] = {0.001, 0.001, 0.001, 0.001, 0.001, 0.001};
|
const float AVG_RATE[] = {0.01, 0.01, 0.01, 0.01, 0.01, 0.01};
|
||||||
char bufchar[1];
|
char bufchar[1];
|
||||||
while (read(serial_fd, bufchar, 1) > 0)
|
while (read(serial_fd, bufchar, 1) > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
#define NUM_CHANNELS 6
|
#define NUM_CHANNELS 6
|
||||||
|
|
||||||
// Acceleration sensors, in screen/world coord system (X = left/right, Y = Up/Down, Z = fwd/back)
|
// Acceleration sensors, in screen/world coord system (X = left/right, Y = Up/Down, Z = fwd/back)
|
||||||
#define ACCEL_X 4
|
#define ACCEL_X 3
|
||||||
#define ACCEL_Y 5
|
#define ACCEL_Y 4
|
||||||
#define ACCEL_Z 3
|
#define ACCEL_Z 5
|
||||||
|
|
||||||
// Gyro sensors, in coodinate system of head/airplane
|
// Gyro sensors, in coodinate system of head/airplane
|
||||||
#define PITCH_RATE 0
|
#define PITCH_RATE 1
|
||||||
#define YAW_RATE 1
|
#define YAW_RATE 0
|
||||||
#define ROLL_RATE 2
|
#define ROLL_RATE 2
|
||||||
|
|
||||||
class SerialInterface {
|
class SerialInterface {
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
//
|
//
|
||||||
// PIN WIRING: Connect input sensors to the channels in following manner
|
// PIN WIRING: Connect input sensors to the channels in following manner
|
||||||
//
|
//
|
||||||
// AIN 15: Pitch Gyro (nodding your head 'yes')
|
// AIN 10: Yaw Gyro (shaking your head 'no')
|
||||||
// AIN 16: Yaw Gyro (shaking your head 'no')
|
// AIN 16: Pitch Gyro (nodding your head 'yes')
|
||||||
// AIN 17: Roll Gyro (looking quizzical, tilting your head)
|
// AIN 17: Roll Gyro (looking quizzical, tilting your head)
|
||||||
// AIN 18: Lateral acceleration (moving from side-to-side in front of your monitor)
|
// AIN 18: Lateral acceleration (moving from side-to-side in front of your monitor)
|
||||||
// AIN 19: Up/Down acceleration (sitting up/ducking in front of your monitor)
|
// AIN 19: Up/Down acceleration (sitting up/ducking in front of your monitor)
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#define LED_PIN 12
|
#define LED_PIN 12
|
||||||
|
|
||||||
int inputPins[NUM_CHANNELS] = {15,16,17,18,19,20};
|
int inputPins[NUM_CHANNELS] = {10,16,17,18,19,20};
|
||||||
|
|
||||||
int LED = 0;
|
int LED = 0;
|
||||||
unsigned int samplesSent = 0;
|
unsigned int samplesSent = 0;
|
||||||
|
|
Loading…
Reference in a new issue