d/vive: Use double for imu ranges

This commit is contained in:
Christoph Haag 2021-04-26 14:23:17 +02:00 committed by Jakob Bornecrantz
parent 0f34fea864
commit 638666100d

View file

@ -346,7 +346,7 @@ update_imu(struct vive_device *d, const void *buffer)
/* From there, handle all new samples */
for (j = 3; j; --j, i = (i + 1) % 3) {
float scale;
double scale;
uint8_t seq;
sample = report->sample + i;
@ -365,7 +365,7 @@ update_imu(struct vive_device *d, const void *buffer)
(int16_t)__le16_to_cpu(sample->acc[2]),
};
scale = (float)d->config.imu.acc_range / 32768.0f;
scale = (double)d->config.imu.acc_range / 32768.0f;
struct xrt_vec3 acceleration = {
scale * d->config.imu.acc_scale.x * acc[0] - d->config.imu.acc_bias.x,
scale * d->config.imu.acc_scale.y * acc[1] - d->config.imu.acc_bias.y,
@ -378,7 +378,7 @@ update_imu(struct vive_device *d, const void *buffer)
(int16_t)__le16_to_cpu(sample->gyro[2]),
};
scale = (float)d->config.imu.gyro_range / 32768.0f;
scale = (double)d->config.imu.gyro_range / 32768.0f;
struct xrt_vec3 angular_velocity = {
scale * d->config.imu.gyro_scale.x * gyro[0] - d->config.imu.gyro_bias.x,
scale * d->config.imu.gyro_scale.y * gyro[1] - d->config.imu.gyro_bias.y,