Skip to content

Commit 4b0ed31

Browse files
committed
offset mode: fix wobble when rotating head
1 parent 7a19500 commit 4b0ed31

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/calibrator/offset.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ impl Calibrator for OffsetMethod {
138138
let to_b = data.get_device_origin(self.device_b)?;
139139
let root_b = TransformD::from(to_b.get_offset()?);
140140

141-
//let pos_offset = root_b.origin - (target_a.origin - pose_a.origin);
142141
let pos_offset = root_b.origin + delta_global.origin;
143142

144143
// devices are more than 100m from center → anomaly

src/calibrator/sampled.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,14 @@ impl SampledMethod {
218218
/// informed by "Averaging Quaternions" from F. Landis Markley, Yang Cheng, John
219219
/// L. Crassidis, Yaakov Oshman
220220
/// https://www.acsu.buffalo.edu/%7Ejohnc/ave_quat07.pdf
221-
fn avg_b_to_a_offset(&self, offset: TransformD) -> TransformD {
222-
let mut verts = Vector3::zeros();
221+
fn avg_b_to_a_offset(&self) -> TransformD {
222+
let mut vecs = Vector3::zeros();
223223
let mut quats = Matrix4::zeros();
224224

225225
for samp in self.samples.iter() {
226-
//TODO:validate
227-
let delta = (offset * samp.b).inverse() * samp.a;
226+
let delta = samp.b.inverse() * samp.a;
228227

229-
verts += delta.origin;
228+
vecs += delta.origin;
230229

231230
let mut q = UnitQuaternion::from_rotation_matrix(&delta.basis);
232231
if q.w < 0.0 {
@@ -237,7 +236,7 @@ impl SampledMethod {
237236
quats += v * v.adjoint();
238237
}
239238

240-
let out_pos = verts.scale(1.0 / self.samples.len() as f64);
239+
let out_pos = vecs.scale(1.0 / self.samples.len() as f64);
241240

242241
let eigen = quats.symmetric_eigen();
243242
let e0 = eigen.eigenvectors.column(0);
@@ -306,7 +305,7 @@ impl Calibrator for SampledMethod {
306305
dst_origin.set_offset((offset * dst_root).into())?;
307306

308307
if self.maintain {
309-
let offset = self.avg_b_to_a_offset(offset);
308+
let offset = self.avg_b_to_a_offset();
310309

311310
match data.save_calibration(self.src_dev, self.dst_dev, offset, OffsetType::Device) {
312311
Ok(_) => log::info!(

0 commit comments

Comments
 (0)