Skip to content

Commit

Permalink
subtract gravity from accel before clamping
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanietsuei committed Oct 27, 2020
1 parent 797eed3 commit a7dd255
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/estimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,25 @@ void Estimator::InertialMeasInternal(const timestamp_t &ts, const Vec3 &gyro,
Vec3 gyro_new;
Vec3 accel_new;

Vec3 grav_s = X_.Rg * g_;
Vec3 grav_b = X_.Rsb.inv() * grav_s;

if (clamp_signals_) {

Vec3 accel_wout_grav = accel + grav_b;

for (int i=0; i < 3; i++) {
number_t sign_gyro = (gyro(i) > 0) ? 1.0 : -1.0;
number_t sign_accel = (accel(i) > 0) ? 1.0 : -1.0;
number_t sign_accel = (accel_wout_grav(i) > 0) ? 1.0 : -1.0;

number_t gyro_mag = (abs(gyro(i)) > max_gyro_(i)) ? max_gyro_(i) : abs(gyro(i));
number_t accel_mag = (abs(accel(i)) > max_accel_(i)) ? max_accel_(i) : abs(accel(i));
number_t accel_mag = (abs(accel_wout_grav(i)) > max_accel_(i)) ? max_accel_(i) : abs(accel_wout_grav(i));

gyro_new(i) = sign_gyro * gyro_mag;
accel_new(i) = sign_accel * accel_mag;

/*
gyro_new(i) = (abs(gyro(i)) > max_gyro_(i)) ? last_gyro_(i) : gyro(i);
accel_new(i) = (abs(accel(i)) > max_accel_(i)) ? last_accel_(i) : accel(i);
*/
}
accel_new -= grav_b;

} else{
gyro_new = gyro;
accel_new = accel;
Expand Down

0 comments on commit a7dd255

Please sign in to comment.