Skip to content

Commit

Permalink
[Spinal][AttitudeControl] add nan value checker for gimbal angles
Browse files Browse the repository at this point in the history
  • Loading branch information
sugihara-16 committed Sep 15, 2023
1 parent 6ecfd1f commit 5b31162
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -962,13 +962,10 @@ void AttitudeController::pwmConversion()
f_i.x = target_thrust_[i*2];
f_i.z = target_thrust_[i*2+1];
target_thrust_[i] = ap::pythagorous2(f_i.x,f_i.z);

if(integrate_flag_){
target_gimbal_angles_[i] = atan2f(-f_i.x, f_i.z);
}
else
float gimbal_candidate = atan2f(-f_i.x, f_i.z);
if(std::isfinite(gimbal_candidate))
{
target_gimbal_angles_[i] = 0.0;
target_gimbal_angles_[i] =(target_gimbal_angles_[i]+ gimbal_candidate)/2;
}
}

Expand Down Expand Up @@ -1003,6 +1000,8 @@ void AttitudeController::pwmConversion()
}
else
{
// gimbal_map[i+1] = 0;
// int target_angle = (int)(0);
gimbal_map[i+1] = 100.0;
}
}
Expand Down

0 comments on commit 5b31162

Please sign in to comment.