d/wmr: reduce drifting by applying calibration biases to G2 controllers

For one thing this applies the calibrated gyro and acceleromater bias
provided by the Reverb G2 controllers via the WMR protocol to
to the according sensor values of the controller. For another,
this applies the temperature mixing matrix in the same, partial way as
it is applied to the HMD. That is it currently disregards the polynomial
coefficiency nature - which is okay for the Reverb G2 as any temperature
dependant, non-constant coefficients in the mixing matrix seem to always
be 0 in the calibration data for it.

All this is, in theory, to reduce drifting. However for the Reverb G2 it
did not eliminate it completly, seemingly like for the HMD the
controllers were never temperature calibrated (controllers and HMD use
the same TDK/InvenSense ICM-20602 chip).

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
This commit is contained in:
Linus Lüssing 2023-06-09 17:37:33 +02:00
parent da70666179
commit 8a239623d7

View file

@ -212,6 +212,9 @@ wmr_controller_hp_packet_parse(struct wmr_controller_hp *ctrl, const unsigned ch
acc[1] = read24(&p); // y acc[1] = read24(&p); // y
acc[2] = read24(&p); // z acc[2] = read24(&p); // z
vec3_from_wmr_controller_accel(acc, &last_input->imu.acc); vec3_from_wmr_controller_accel(acc, &last_input->imu.acc);
math_matrix_3x3_transform_vec3(&wcb->config.sensors.accel.mix_matrix, &last_input->imu.acc,
&last_input->imu.acc);
math_vec3_accum(&wcb->config.sensors.accel.bias_offsets, &last_input->imu.acc);
math_quat_rotate_vec3(&wcb->config.sensors.transforms.P_oxr_acc.orientation, &last_input->imu.acc, math_quat_rotate_vec3(&wcb->config.sensors.transforms.P_oxr_acc.orientation, &last_input->imu.acc,
&last_input->imu.acc); &last_input->imu.acc);
@ -228,6 +231,9 @@ wmr_controller_hp_packet_parse(struct wmr_controller_hp *ctrl, const unsigned ch
gyro[1] = read24(&p); gyro[1] = read24(&p);
gyro[2] = read24(&p); gyro[2] = read24(&p);
vec3_from_wmr_controller_gyro(gyro, &last_input->imu.gyro); vec3_from_wmr_controller_gyro(gyro, &last_input->imu.gyro);
math_matrix_3x3_transform_vec3(&wcb->config.sensors.gyro.mix_matrix, &last_input->imu.gyro,
&last_input->imu.gyro);
math_vec3_accum(&wcb->config.sensors.gyro.bias_offsets, &last_input->imu.gyro);
math_quat_rotate_vec3(&wcb->config.sensors.transforms.P_oxr_gyr.orientation, &last_input->imu.gyro, math_quat_rotate_vec3(&wcb->config.sensors.transforms.P_oxr_gyr.orientation, &last_input->imu.gyro,
&last_input->imu.gyro); &last_input->imu.gyro);