Skip to content

Commit

Permalink
Fix Rotation return value
Browse files Browse the repository at this point in the history
A really weird quirk of Flipper build system, or something...
  • Loading branch information
ginkage committed Aug 9, 2023
1 parent 9d4f47b commit 06b91a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tracking/orientation_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Vector4 OrientationTracker::OnGyroscopeData(const GyroscopeData& event)

sensor_fusion_->ProcessGyroscopeSample(data);

return OrientationTracker::GetPose(data.sensor_timestamp_ns + sampling_period_ns_);
return GetPose(data.sensor_timestamp_ns + sampling_period_ns_);
}

} // namespace cardboard
13 changes: 8 additions & 5 deletions tracking/sensors/sensor_fusion_ekf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ namespace {
// angle = norm(a)
// axis = a.normalized()
// If norm(a) == 0, it returns an identity rotation.
static inline Rotation RotationFromVector(const Vector3& a)
static inline void RotationFromVector(const Vector3& a, Rotation& r)
{
const double norm_a = Length(a);
if (norm_a < kEpsilon) {
return Rotation::Identity();
r = Rotation::Identity();
return;
}
return Rotation::FromAxisAndAngle(a / norm_a, norm_a);
r = Rotation::FromAxisAndAngle(a / norm_a, norm_a);
}

} // namespace
Expand Down Expand Up @@ -199,7 +200,8 @@ void SensorFusionEkf::ComputeMeasurementJacobian()
Vector3 delta = Vector3::Zero();
delta[dof] = kFiniteDifferencingEpsilon;

const Rotation epsilon_rotation = RotationFromVector(delta);
Rotation epsilon_rotation;
RotationFromVector(delta, epsilon_rotation);
const Vector3 delta_rotation
= ComputeInnovation(epsilon_rotation * current_state_.sensor_from_start_rotation);

Expand Down Expand Up @@ -263,7 +265,8 @@ void SensorFusionEkf::ProcessAccelerometerSample(const AccelerometerData& sample
* state_covariance_;

// Updates pose and associate covariance matrix.
const Rotation rotation_from_state_update = RotationFromVector(state_update_);
Rotation rotation_from_state_update;
RotationFromVector(state_update_, rotation_from_state_update);

current_state_.sensor_from_start_rotation
= rotation_from_state_update * current_state_.sensor_from_start_rotation;
Expand Down

0 comments on commit 06b91a0

Please sign in to comment.