Skip to content
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

enabling angle of attack logging in tecs_status message #22823

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions msg/TecsStatus.msg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ float32 true_airspeed_derivative_raw # True airspeed derivative raw [m/s^2]

float32 total_energy_rate_sp # Total energy rate setpoint [m^2/s^3]
float32 total_energy_rate # Total energy rate estimate [m^2/s^3]
float32 alpha # Angle of attack in radians

float32 total_energy_balance_rate_sp # Energy balance rate setpoint [m^2/s^3]
float32 total_energy_balance_rate # Energy balance rate estimate [m^2/s^3]
Expand Down
9 changes: 9 additions & 0 deletions src/modules/fw_pos_control/FixedwingPositionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ FixedwingPositionControl::tecs_status_publish(float alt_sp, float equivalent_air
tecs_status.pitch_sp_rad = _tecs.get_pitch_setpoint();
tecs_status.throttle_trim = throttle_trim;
tecs_status.underspeed_ratio = _tecs.get_underspeed_ratio();
tecs_status.alpha = _aoa;

tecs_status.timestamp = hrt_absolute_time();

Expand Down Expand Up @@ -1056,6 +1057,14 @@ FixedwingPositionControl::control_auto_position(const float control_interval, co
// waypoint is a plain navigation waypoint
float position_sp_alt = pos_sp_curr.alt;

if (_airspeed_valid)
{
const Vector2f airspeed_2d{_airspeed_eas*cosf(_yaw), _airspeed_eas*sinf(_yaw)};

const float air_gnd_angle = acosf((airspeed_2d*ground_speed)/(airspeed_2d.length()*ground_speed.length()));
_aoa = air_gnd_angle;
}

// Altitude first order hold (FOH)
if (_position_setpoint_previous_valid &&
((pos_sp_prev.type == position_setpoint_s::SETPOINT_TYPE_POSITION) ||
Expand Down
1 change: 1 addition & 0 deletions src/modules/fw_pos_control/FixedwingPositionControl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ class FixedwingPositionControl final : public ModuleBase<FixedwingPositionContro
double _current_latitude{0};
double _current_longitude{0};
float _current_altitude{0.f};
float _aoa{0};

float _roll{0.f};
float _pitch{0.0f};
Expand Down
Loading