Skip to content

AC_AttitudeControl: Add conversions from cd to rad #30120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lthall
Copy link
Contributor

@lthall lthall commented May 20, 2025

This PR adds radian (_rad, _rads) variants of all input_XXX rate and attitude commands in AC_AttitudeControl. These functions mirror the existing centidegree-based (_cd, _cds) methods, enabling direct use of SI units or the addition of degrees.

This does add size:

After AC_AttitudeControl: Add conversions from cd to rad

Board,blimp,bootloader,copter,heli,plane,rover,sub
CubeOrange,*,*,464,416,448,*,400


input_euler_rate_roll_pitch_yaw_rads(euler_roll_rate_rads, euler_pitch_rate_rads, euler_yaw_rate_rads);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe put a comment above this new method

@lthall lthall force-pushed the 20250520_ACAttitudeConrol_Interface branch 2 times, most recently from de4517a to ad6479a Compare May 25, 2025 01:59
@lthall lthall force-pushed the 20250520_ACAttitudeConrol_Interface branch 2 times, most recently from 80ad123 to afcbb93 Compare May 25, 2025 13:21
@rmackay9
Copy link
Contributor

instead of using "* radians(0.01)" I'd prefer we create a new method called something like, "radians_from_cd(x)"

@tridge
Copy link
Contributor

tridge commented May 26, 2025

@rmackay9 maybe cd_to_rad() ?

@@ -203,40 +203,51 @@ class AC_AttitudeControl {

// Command an euler roll and pitch angle and an euler yaw rate with angular velocity feedforward and smoothing
virtual void input_euler_angle_roll_pitch_euler_rate_yaw_cd(float euler_roll_angle_cd, float euler_pitch_angle_cd, float euler_yaw_rate_cds);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wrapper functions don't need to be virtual.

@@ -768,7 +768,7 @@ void Mode::land_run_horizontal_control()
// interpolate for 1m above that
const float attitude_limit_cd = linear_interpolate(700, copter.aparm.angle_max, get_alt_above_ground_cm(),
g2.wp_navalt_min*100U, (g2.wp_navalt_min+1)*100U);
const float thrust_vector_max = sinf(radians(attitude_limit_cd * 0.01f)) * GRAVITY_MSS * 100.0f;
const float thrust_vector_max = sinf(attitude_limit_cd * radians(0.01f)) * GRAVITY_MSS * 100.0f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would strongly prefer a cd_to_rad() function or similar

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO cdeg_to_rad would be more readable.

@lthall lthall force-pushed the 20250520_ACAttitudeConrol_Interface branch from afcbb93 to dbb577d Compare May 27, 2025 14:03
@lthall lthall added the WIP label May 27, 2025
@lthall lthall force-pushed the 20250520_ACAttitudeConrol_Interface branch from dbb577d to ad922f7 Compare May 31, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants