Skip to content

Commit

Permalink
optimize cache for compute_position_control
Browse files Browse the repository at this point in the history
  • Loading branch information
makeecat committed Nov 1, 2024
1 parent 23cfd3f commit b185eef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,10 @@ impl PIDController {
+ self.kpid_pos[2].component_mul(&self.integral_pos_error);
let gravity_compensation = Vector3::new(0.0, 0.0, self.gravity);
let total_acceleration = acceleration + gravity_compensation;
let thrust = self.mass * total_acceleration.norm();
let desired_orientation = if total_acceleration.norm() > 1e-6 {
let z_body = total_acceleration.normalize();
let total_acc_norm = total_acceleration.norm();
let thrust = self.mass * total_acc_norm;
let desired_orientation = if total_acc_norm > 1e-6 {
let z_body = total_acceleration / total_acc_norm;
let yaw_rotation = UnitQuaternion::from_euler_angles(0.0, 0.0, desired_yaw);
let x_body_horizontal = yaw_rotation * Vector3::new(1.0, 0.0, 0.0);
let y_body = z_body.cross(&x_body_horizontal).normalize();
Expand Down

0 comments on commit b185eef

Please sign in to comment.