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

SITL: fix json airspeed #27476

Merged
merged 1 commit into from
Jul 9, 2024
Merged
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
13 changes: 7 additions & 6 deletions libraries/SITL/SIM_JSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,15 @@ void JSON::recv_fdm(const struct sitl_input &input)

airspeed_pitot = state.airspeed;
} else {
// velocity relative to airmass in body frame
velocity_air_bf = dcm.transposed() * velocity_ef;

// wind is not supported yet for JSON sim, assume zero for now
wind_ef.zero();

// airspeed
airspeed = velocity_air_bf.length();
Copy link
Contributor

Choose a reason for hiding this comment

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

I see other backends still updating these; why do we no longer need to do that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The calculation is already done inside update_eas_airspeed(). If left as it is, the variable airspeed will be
rewritten anyway. I figure it's better to remove the line to avoid confusion.

// velocity relative to airmass in Earth's frame
velocity_air_ef = velocity_ef - wind_ef;

// airspeed as seen by a fwd pitot tube (limited to 120m/s)
airspeed_pitot = constrain_float(velocity_air_bf * Vector3f(1.0f, 0.0f, 0.0f), 0.0f, 120.0f);
// velocity relative to airmass in body frame
velocity_air_bf = dcm.transposed() * velocity_air_ef;

// airspeed fix for eas2tas
update_eas_airspeed();
Expand Down
Loading