Allow Tikhonov to output negative forces if requested

This commit is contained in:
Torbjørn Ludvigsen 2025-10-16 23:53:02 +02:00
parent c7c809e4f5
commit 9bd021bd08

View file

@ -256,15 +256,17 @@ static_forces_tikhonov(struct winch_flex *wf, const struct coord *pos,
double norm_sq = 0.;
for (int i = 0; i < N; ++i)
norm_sq += d[i] * d[i];
if (norm_sq < tol * tol)
if (norm_sq < tol * tol) {
break;
}
for (int i = 0; i < N; ++i)
T[i] -= step_damp * d[i];
}
// Hard cap on Tmax and 0 if we don't ignore pretension
// Allow negative forces if the user asked for it
for (int i=0;i<N;++i){
if (T[i] < 0.f) T[i] = 0.f;
if (wf->min_force[i] >= 0. && T[i] < 0.) T[i] = 0.;
if (T[i] > wf->max_force[i]) T[i] = wf->max_force[i];
}
}