@@ -345,9 +345,9 @@ void AC_AttitudeControl::input_quaternion(Quaternion& attitude_desired_quat, Vec
345
345
void AC_AttitudeControl::input_euler_angle_roll_pitch_euler_rate_yaw_cd (float euler_roll_angle_cd, float euler_pitch_angle_cd, float euler_yaw_rate_cds)
346
346
{
347
347
// Convert from centidegrees on public interface to radians
348
- float euler_roll_angle_rad = euler_roll_angle_cd * radians (0 .01f );
349
- float euler_pitch_angle_rad = euler_pitch_angle_cd * radians (0 .01f );
350
- float euler_yaw_rate_rads = euler_yaw_rate_cds * radians (0 .01f );
348
+ const float euler_roll_angle_rad = euler_roll_angle_cd * radians (0 .01f );
349
+ const float euler_pitch_angle_rad = euler_pitch_angle_cd * radians (0 .01f );
350
+ const float euler_yaw_rate_rads = euler_yaw_rate_cds * radians (0 .01f );
351
351
input_euler_angle_roll_pitch_euler_rate_yaw_rad (euler_roll_angle_rad, euler_pitch_angle_rad, euler_yaw_rate_rads);
352
352
}
353
353
@@ -403,9 +403,9 @@ void AC_AttitudeControl::input_euler_angle_roll_pitch_euler_rate_yaw_rad(float e
403
403
void AC_AttitudeControl::input_euler_angle_roll_pitch_yaw_cd (float euler_roll_angle_cd, float euler_pitch_angle_cd, float euler_yaw_angle_cd, bool slew_yaw)
404
404
{
405
405
// Convert from centidegrees on public interface to radians
406
- float euler_roll_angle_rad = euler_roll_angle_cd * radians (0 .01f );
407
- float euler_pitch_angle_rad = euler_pitch_angle_cd * radians (0 .01f );
408
- float euler_yaw_angle_rad = euler_yaw_angle_cd * radians (0 .01f );
406
+ const float euler_roll_angle_rad = euler_roll_angle_cd * radians (0 .01f );
407
+ const float euler_pitch_angle_rad = euler_pitch_angle_cd * radians (0 .01f );
408
+ const float euler_yaw_angle_rad = euler_yaw_angle_cd * radians (0 .01f );
409
409
410
410
input_euler_angle_roll_pitch_yaw_rad (euler_roll_angle_rad, euler_pitch_angle_rad, euler_yaw_angle_rad, slew_yaw);
411
411
}
@@ -470,9 +470,9 @@ void AC_AttitudeControl::input_euler_angle_roll_pitch_yaw_rad(float euler_roll_a
470
470
void AC_AttitudeControl::input_euler_rate_roll_pitch_yaw_cds (float euler_roll_rate_cds, float euler_pitch_rate_cds, float euler_yaw_rate_cds)
471
471
{
472
472
// Convert from centidegrees on public interface to radians
473
- float euler_roll_rate_rads = euler_roll_rate_cds * radians (0 .01f );
474
- float euler_pitch_rate_rads = euler_pitch_rate_cds * radians (0 .01f );
475
- float euler_yaw_rate_rads = euler_yaw_rate_cds * radians (0 .01f );
473
+ const float euler_roll_rate_rads = euler_roll_rate_cds * radians (0 .01f );
474
+ const float euler_pitch_rate_rads = euler_pitch_rate_cds * radians (0 .01f );
475
+ const float euler_yaw_rate_rads = euler_yaw_rate_cds * radians (0 .01f );
476
476
477
477
input_euler_rate_roll_pitch_yaw_rads (euler_roll_rate_rads, euler_pitch_rate_rads, euler_yaw_rate_rads);
478
478
}
@@ -521,9 +521,9 @@ void AC_AttitudeControl::input_euler_rate_roll_pitch_yaw_rads(float euler_roll_r
521
521
void AC_AttitudeControl::input_rate_bf_roll_pitch_yaw_cds (float roll_rate_bf_cds, float pitch_rate_bf_cds, float yaw_rate_bf_cds)
522
522
{
523
523
// Convert from centidegrees on public interface to radians
524
- float roll_rate_bf_rads = roll_rate_bf_cds * radians (0 .01f );
525
- float pitch_rate_bf_rads = pitch_rate_bf_cds * radians (0 .01f );
526
- float yaw_rate_bf_rads = yaw_rate_bf_cds * radians (0 .01f );
524
+ const float roll_rate_bf_rads = roll_rate_bf_cds * radians (0 .01f );
525
+ const float pitch_rate_bf_rads = pitch_rate_bf_cds * radians (0 .01f );
526
+ const float yaw_rate_bf_rads = yaw_rate_bf_cds * radians (0 .01f );
527
527
528
528
input_rate_bf_roll_pitch_yaw_rads (roll_rate_bf_rads, pitch_rate_bf_rads, yaw_rate_bf_rads);
529
529
}
@@ -567,9 +567,9 @@ void AC_AttitudeControl::input_rate_bf_roll_pitch_yaw_rads(float roll_rate_bf_ra
567
567
void AC_AttitudeControl::input_rate_bf_roll_pitch_yaw_2_cds (float roll_rate_bf_cds, float pitch_rate_bf_cds, float yaw_rate_bf_cds)
568
568
{
569
569
// Convert from centidegrees on public interface to radians
570
- float roll_rate_bf_rads = roll_rate_bf_cds * radians (0 .01f );
571
- float pitch_rate_bf_rads = pitch_rate_bf_cds * radians (0 .01f );
572
- float yaw_rate_bf_rads = yaw_rate_bf_cds * radians (0 .01f );
570
+ const float roll_rate_bf_rads = roll_rate_bf_cds * radians (0 .01f );
571
+ const float pitch_rate_bf_rads = pitch_rate_bf_cds * radians (0 .01f );
572
+ const float yaw_rate_bf_rads = yaw_rate_bf_cds * radians (0 .01f );
573
573
574
574
input_rate_bf_roll_pitch_yaw_2_rads (roll_rate_bf_rads, pitch_rate_bf_rads, yaw_rate_bf_rads);
575
575
}
@@ -598,9 +598,9 @@ void AC_AttitudeControl::input_rate_bf_roll_pitch_yaw_2_rads(float roll_rate_bf_
598
598
void AC_AttitudeControl::input_rate_bf_roll_pitch_yaw_3_cds (float roll_rate_bf_cds, float pitch_rate_bf_cds, float yaw_rate_bf_cds)
599
599
{
600
600
// Convert from centidegrees on public interface to radians
601
- float roll_rate_bf_rads = roll_rate_bf_cds * radians (0 .01f );
602
- float pitch_rate_bf_rads = pitch_rate_bf_cds * radians (0 .01f );
603
- float yaw_rate_bf_rads = yaw_rate_bf_cds * radians (0 .01f );
601
+ const float roll_rate_bf_rads = roll_rate_bf_cds * radians (0 .01f );
602
+ const float pitch_rate_bf_rads = pitch_rate_bf_cds * radians (0 .01f );
603
+ const float yaw_rate_bf_rads = yaw_rate_bf_cds * radians (0 .01f );
604
604
605
605
input_rate_bf_roll_pitch_yaw_3_rads (roll_rate_bf_rads, pitch_rate_bf_rads, yaw_rate_bf_rads);
606
606
}
@@ -692,9 +692,9 @@ void AC_AttitudeControl::input_rate_bf_roll_pitch_yaw_no_shaping_rads(float roll
692
692
void AC_AttitudeControl::input_angle_step_bf_roll_pitch_yaw_cd (float roll_angle_step_bf_cd, float pitch_angle_step_bf_cd, float yaw_angle_step_bf_cd)
693
693
{
694
694
// Convert from centidegrees on public interface to radians
695
- float roll_angle_step_bf_rad = roll_angle_step_bf_cd * radians (0 .01f );
696
- float pitch_angle_step_bf_rad = pitch_angle_step_bf_cd * radians (0 .01f );
697
- float yaw_angle_step_bf_rad = yaw_angle_step_bf_cd * radians (0 .01f );
695
+ const float roll_angle_step_bf_rad = roll_angle_step_bf_cd * radians (0 .01f );
696
+ const float pitch_angle_step_bf_rad = pitch_angle_step_bf_cd * radians (0 .01f );
697
+ const float yaw_angle_step_bf_rad = yaw_angle_step_bf_cd * radians (0 .01f );
698
698
699
699
input_angle_step_bf_roll_pitch_yaw_rad (roll_angle_step_bf_rad, pitch_angle_step_bf_rad, yaw_angle_step_bf_rad);
700
700
}
@@ -724,9 +724,9 @@ void AC_AttitudeControl::input_angle_step_bf_roll_pitch_yaw_rad(float roll_angle
724
724
void AC_AttitudeControl::input_rate_step_bf_roll_pitch_yaw_cds (float roll_rate_step_bf_cds, float pitch_rate_step_bf_cds, float yaw_rate_step_bf_cds)
725
725
{
726
726
// Convert from centidegrees on public interface to radians
727
- float roll_rate_step_bf_rads = roll_rate_step_bf_cds * radians (0 .01f );
728
- float pitch_rate_step_bf_rads = pitch_rate_step_bf_cds * radians (0 .01f );
729
- float yaw_rate_step_bf_rads = yaw_rate_step_bf_cds * radians (0 .01f );
727
+ const float roll_rate_step_bf_rads = roll_rate_step_bf_cds * radians (0 .01f );
728
+ const float pitch_rate_step_bf_rads = pitch_rate_step_bf_cds * radians (0 .01f );
729
+ const float yaw_rate_step_bf_rads = yaw_rate_step_bf_cds * radians (0 .01f );
730
730
731
731
input_rate_step_bf_roll_pitch_yaw_rads (roll_rate_step_bf_rads, pitch_rate_step_bf_rads, yaw_rate_step_bf_rads);
732
732
}
@@ -750,7 +750,7 @@ void AC_AttitudeControl::input_rate_step_bf_roll_pitch_yaw_rads(float roll_rate_
750
750
void AC_AttitudeControl::input_thrust_vector_rate_heading_cds (const Vector3f& thrust_vector, float heading_rate_cds, bool slew_yaw)
751
751
{
752
752
// Convert from centidegrees on public interface to radians
753
- float heading_rate_rads = heading_rate_cds * radians (0 .01f );
753
+ const float heading_rate_rads = heading_rate_cds * radians (0 .01f );
754
754
755
755
input_thrust_vector_rate_heading_rads (thrust_vector, heading_rate_rads, slew_yaw);
756
756
}
@@ -812,8 +812,8 @@ void AC_AttitudeControl::input_thrust_vector_rate_heading_rads(const Vector3f& t
812
812
void AC_AttitudeControl::input_thrust_vector_heading_cd (const Vector3f& thrust_vector, float heading_angle_cd, float heading_rate_cds)
813
813
{
814
814
// Convert from centidegrees on public interface to radians
815
- float heading_rate_rads = heading_rate_cds * radians (0 .01f );
816
- float heading_angle_rad = heading_angle_cd * radians (0 .01f );
815
+ const float heading_rate_rads = heading_rate_cds * radians (0 .01f );
816
+ const float heading_angle_rad = heading_angle_cd * radians (0 .01f );
817
817
818
818
input_thrust_vector_heading_rad (thrust_vector, heading_angle_rad, heading_rate_rads);
819
819
}
@@ -1000,10 +1000,10 @@ void AC_AttitudeControl::thrust_vector_rotation_angles(const Quaternion& attitud
1000
1000
// attitude_target and attitude_body are passive rotations from target / body frames to the NED frame
1001
1001
1002
1002
// Rotating [0,0,-1] by attitude_target expresses (gets a view of) the target thrust vector in the inertial frame
1003
- Vector3f att_target_thrust_vec = attitude_target * thrust_vector_up; // target thrust vector
1003
+ const Vector3f att_target_thrust_vec = attitude_target * thrust_vector_up; // target thrust vector
1004
1004
1005
1005
// Rotating [0,0,-1] by attitude_target expresses (gets a view of) the current thrust vector in the inertial frame
1006
- Vector3f att_body_thrust_vec = attitude_body * thrust_vector_up; // current thrust vector
1006
+ const Vector3f att_body_thrust_vec = attitude_body * thrust_vector_up; // current thrust vector
1007
1007
1008
1008
// the dot product is used to calculate the current lean angle for use of external functions
1009
1009
thrust_angle_rad = acosf (constrain_float (thrust_vector_up * att_body_thrust_vec,-1 .0f ,1 .0f ));
@@ -1107,7 +1107,7 @@ void AC_AttitudeControl::ang_vel_limit(Vector3f& euler_rad, float ang_vel_roll_m
1107
1107
euler_rad.y = constrain_float (euler_rad.y , -ang_vel_pitch_max_rads, ang_vel_pitch_max_rads);
1108
1108
}
1109
1109
} else {
1110
- Vector2f thrust_vector_ang_vel (euler_rad.x / ang_vel_roll_max_rads, euler_rad.y / ang_vel_pitch_max_rads);
1110
+ const Vector2f thrust_vector_ang_vel (euler_rad.x / ang_vel_roll_max_rads, euler_rad.y / ang_vel_pitch_max_rads);
1111
1111
float thrust_vector_length = thrust_vector_ang_vel.length ();
1112
1112
if (thrust_vector_length > 1 .0f ) {
1113
1113
euler_rad.x = thrust_vector_ang_vel.x * ang_vel_roll_max_rads / thrust_vector_length;
@@ -1309,11 +1309,11 @@ float AC_AttitudeControl::max_rate_step_bf_roll()
1309
1309
// Return pitch rate step size in centidegrees/s that results in maximum output after 4 time steps
1310
1310
float AC_AttitudeControl::max_rate_step_bf_pitch ()
1311
1311
{
1312
- float dt_average = AP::scheduler ().get_filtered_loop_time ();
1313
- float alpha = MIN (get_rate_pitch_pid ().get_filt_E_alpha (dt_average), get_rate_pitch_pid ().get_filt_D_alpha (dt_average));
1314
- float alpha_remaining = 1 - alpha;
1312
+ const float dt_average = AP::scheduler ().get_filtered_loop_time ();
1313
+ const float alpha = MIN (get_rate_pitch_pid ().get_filt_E_alpha (dt_average), get_rate_pitch_pid ().get_filt_D_alpha (dt_average));
1314
+ const float alpha_remaining = 1 - alpha;
1315
1315
// todo: When a thrust_max is available we should replace 0.5f with 0.5f * _motors.thrust_max
1316
- float throttle_hover = constrain_float (_motors.get_throttle_hover (), 0 .1f , 0 .5f );
1316
+ const float throttle_hover = constrain_float (_motors.get_throttle_hover (), 0 .1f , 0 .5f );
1317
1317
float rate_max = 2 .0f * throttle_hover * AC_ATTITUDE_RATE_RP_CONTROLLER_OUT_MAX / ((alpha_remaining * alpha_remaining * alpha_remaining * alpha * get_rate_pitch_pid ().kD ()) / _dt + get_rate_pitch_pid ().kP ());
1318
1318
if (is_positive (_ang_vel_pitch_max_degs)) {
1319
1319
rate_max = MIN (rate_max, get_ang_vel_pitch_max_rads ());
@@ -1324,11 +1324,11 @@ float AC_AttitudeControl::max_rate_step_bf_pitch()
1324
1324
// Return yaw rate step size in centidegrees/s that results in maximum output after 4 time steps
1325
1325
float AC_AttitudeControl::max_rate_step_bf_yaw ()
1326
1326
{
1327
- float dt_average = AP::scheduler ().get_filtered_loop_time ();
1328
- float alpha = MIN (get_rate_yaw_pid ().get_filt_E_alpha (dt_average), get_rate_yaw_pid ().get_filt_D_alpha (dt_average));
1329
- float alpha_remaining = 1 - alpha;
1327
+ const float dt_average = AP::scheduler ().get_filtered_loop_time ();
1328
+ const float alpha = MIN (get_rate_yaw_pid ().get_filt_E_alpha (dt_average), get_rate_yaw_pid ().get_filt_D_alpha (dt_average));
1329
+ const float alpha_remaining = 1 - alpha;
1330
1330
// todo: When a thrust_max is available we should replace 0.5f with 0.5f * _motors.thrust_max
1331
- float throttle_hover = constrain_float (_motors.get_throttle_hover (), 0 .1f , 0 .5f );
1331
+ const float throttle_hover = constrain_float (_motors.get_throttle_hover (), 0 .1f , 0 .5f );
1332
1332
float rate_max = 2 .0f * throttle_hover * AC_ATTITUDE_RATE_YAW_CONTROLLER_OUT_MAX / ((alpha_remaining * alpha_remaining * alpha_remaining * alpha * get_rate_yaw_pid ().kD ()) / _dt + get_rate_yaw_pid ().kP ());
1333
1333
if (is_positive (_ang_vel_yaw_max_degs)) {
1334
1334
rate_max = MIN (rate_max, get_ang_vel_yaw_max_rads ());
0 commit comments