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

FIX: fixed-wing airspeed problem in SITL #24452

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

TigerWuu
Copy link

@TigerWuu TigerWuu commented Mar 5, 2025

Solved Problem

Fixes #23756
Reopen from #24437

Solution

Publish the differential_pressure in poseInfoCallback from GZBridge, and remove SENS_EN_AIRSIM from 4004_gz_standard_vtol.

Test coverage

Have tested with

gz topic -t /world/default/wind_info -m gz.msgs.Wind -p "linear_velocity: { x: 2, y: 0, z: 0 }";

Context

N/A

@TigerWuu TigerWuu marked this pull request as ready for review March 5, 2025 09:23
@dakejahl
Copy link
Contributor

dakejahl commented Mar 5, 2025

Can you remove SENS_EN_ARSPDSIM from all the gz_* models? Also can you validate a couple of the other models?

dakejahl
dakejahl previously approved these changes Mar 5, 2025
@TigerWuu
Copy link
Author

TigerWuu commented Mar 5, 2025

Can you remove SENS_EN_ARSPDSIM from all the gz_* models? Also can you validate a couple of the other models?

My pleasure. I have checked gz_rc_cessna and gz_advanced_plane, hopefully, I didn't miss any others. gz_rc_cessna works as expected; however, gz_advanced_plane cannot take off, I don't know what it happens.

@dakejahl
Copy link
Contributor

dakejahl commented Mar 5, 2025

Can't takeoff? So this is not working? Is this differential pressure calculation correct? Are you sure the rotation transform is correct? You can re-enable the SimSensor and compare the data to see what might be different.

listener differential_pressure

@TigerWuu
Copy link
Author

TigerWuu commented Mar 6, 2025

Can't takeoff? So this is not working?

I don't think so. I checkout to the main branch and the result is the same. when I arm the cessna, it will take off; however, the advanced plane keeps rolling the propeller and being still.

cessna :
cessna.webm

advanced plane
advanced.webm

I think the advanced plane model might have been broken.

@dakejahl
Copy link
Contributor

dakejahl commented Mar 6, 2025

Can you rebase on main and try again? I pulled your branch and tested and it worked for me.

@dakejahl
Copy link
Contributor

dakejahl commented Mar 6, 2025

Also since we no longer are using the sensor_airspeed_sim module we don't get to use SIM_ARSPD_FAIL anymore. I'm wondering if we need to add that or not. We probably shouldn't use a param though.

@Jaeyoung-Lim @dagar I see the conversation in #21126 Do we want to centralize failure injection for gz sim? Should we use the param until then?

@dakejahl dakejahl requested review from mbjd and Jaeyoung-Lim March 6, 2025 11:24
@TigerWuu
Copy link
Author

TigerWuu commented Mar 6, 2025

Can you rebase on main and try again? I pulled your branch and tested and it worked for me.

That's weird. I merge main into my branch and got a zero compass message this time.
image

I have no idea why I have different gz branch when I checkout between main and pr_fw_airspeed_fix. When I am in commit 6c18846a4c7f9fe786840a29bf4e3237f908611b, the error is gone and the advanced plane can fly under manual mode, however, it still doesn't work under position mode

@dakejahl
Copy link
Contributor

dakejahl commented Mar 6, 2025

You need to rebase your changes. Recently I updated all of the models to use a mag from gz rather than the sim_sensor_mag

@TigerWuu
Copy link
Author

TigerWuu commented Mar 6, 2025

You need to rebase your changes. Recently I updated all of the models to use a mag from gz rather than the sim_sensor_mag

I reset the merge and rebase my branch on main again. I still get the same result. Additionally, I don't understand why the two branches main and pr_fw_airspeed_fix (after rebase on main) have different index for gz module

image

I thought git submodule update should bring us to 6c18846a4c7f9fe786840a29bf4e3237f908611b .
Sorry for my poor knowledge about git....

@dakejahl dakejahl force-pushed the pr_fw_airspeed_fix branch from 1ddc5c1 to c1d37b7 Compare March 7, 2025 00:10
@dakejahl
Copy link
Contributor

dakejahl commented Mar 7, 2025

I rebased your branch and pushed. On the default world the advanced_plane works fine, but on the windy world it doesn't get off the ground. Can you check your calculations and make sure things are correct? You should compare the data in the log from this new implementation against the previous one using the SensorAirspeedSim

@TigerWuu
Copy link
Author

TigerWuu commented Mar 7, 2025

I rebased your branch and pushed. On the default world the advanced_plane works fine, but on the windy world it doesn't get off the ground. Can you check your calculations and make sure things are correct? You should compare the data in the log from this new implementation against the previous one using the SensorAirspeedSim

Thank you. I have pulled the latest branch c1d37b7. However, I still can't get advanced_plane work on default world. I have checked the commit of gz submodule is on the latest one 6c18846a4c. Other vehicles, cessna and standard_vtol, work fine on default world, and I also check the wind velocity, ground speed, and airspeed comply with the wind triangle (I know it is a rough check. I didn't check the log file.). Should I handle this part first and then compare the log file? Where should I start debugging?
Screencast from 03-07-2025 11:32:41 AM.webm

@dakejahl
Copy link
Contributor

dakejahl commented Mar 8, 2025

I tested the rc_cessna on both default and windy world and it works great. The position tracking is greatly improved with the wind triangle implementation for airspeed. There are issues with advanced_plane though. It can takeoff on the default world fine for me, but can't get off the ground on the windy world. I'm wondering if it's an issue with the parameters of the AdvancedLiftDrag plugin.

@ryanjAA would you mind taking a look? I want to merge this PR as it's an improvement but I don't want to break the advanced_plane functionality. Who else can we bring into this discussion who understands planes better than I?

AdvancedLiftDrag plugin
https://github.com/PX4/PX4-gazebo-models/blob/main/models/advanced_plane/model.sdf#L607

windy world wind
https://github.com/PX4/PX4-gazebo-models/blob/main/worlds/windy.sdf#L86

@dakejahl
Copy link
Contributor

dakejahl commented Mar 8, 2025

@fredmarkus tagging you since I see you were the one who added advanced_plane PX4/PX4-gazebo-models#10

Can you help with this?

@ryanjAA
Copy link
Contributor

ryanjAA commented Mar 8, 2025

Took a look. It's friction. There are no wheels on the advanced plane, only the cessna. One sec, I'll fix it.

@ryanjAA
Copy link
Contributor

ryanjAA commented Mar 8, 2025

Ok - a few solutions depending on what we want.

Add friction which I did. That does work but then to can move too freely depending on wind and direction (we should do wheels which wouldnt be too hard).

Or

Set takeoff airspeed to 15 m/s (instead of min airspeed which is 10 and rotation which is 90% of that which is too low with wind [maybe if we make it a true headwind but creates problems later]) and set rotation airspeed to the same (15). The advanced plane has a much smaller wing area 0.34 vs 0.6) so most likely whats happening is at that AoA with the advanced l/d, you simply aren't making enough lift given the more advanced polars.

A couple other unrelated issues though. If you turn up the wind to 10 m/s from due east, it should get up and go. It does but that speed is nowhere near reflected in the wind estimate. The vehicle is moving much faster but the estimate is 1-4 m/s.

Let me know and I'll push a param change or friction change. If youre wondering why it works with no wind, it's because it only needs to overcome forward friction and there just seems to be enough (aka no side force either).

@dakejahl
Copy link
Contributor

I think adding wheels is an easy obvious first step lol. Also having a headwind seems to make the most sense, since this would reflect a more typical real world scenario. I'll defer the decision to you @ryanjAA since you're the subject matter expert here.

but that speed is nowhere near reflected in the wind estimate. The vehicle is moving much faster but the estimate is 1-4 m/s.

Ah you're saying the wind estimate doesn't reflect the reality of the simulation?

@Jaeyoung-Lim
Copy link
Member

@TigerWuu You might need to add wind influence to be modeled in the advanced_liftdrag_plugin

@TigerWuu
Copy link
Author

TigerWuu commented Mar 11, 2025

but that speed is nowhere near reflected in the wind estimate. The vehicle is moving much faster but the estimate is 1-4 m/s.

Ah you're saying the wind estimate doesn't reflect the reality of the simulation?

@ryanjAA I would like to clarify that this issue only occurs in advanced planes, right?

@TigerWuu
Copy link
Author

@TigerWuu You might need to add wind influence to be modeled in the advanced_liftdrag_plugin

@Jaeyoung-Lim I checked the advanced_liftdrag_plugin, and I found that the wind component had been incorporated into the plugin to calculate the airspeed.

const auto &pose = worldPose->Data();
const auto cpWorld = pose.Rot().RotateVector(this->cp);
auto air_velocity = worldLinVel->Data() + worldAngVel->Data().Cross(
  cpWorld);
if (windLinearVel != nullptr){
  air_velocity = worldLinVel->Data() + worldAngVel->Data().Cross(
  cpWorld) - windLinearVel->Data();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] fixed-wing airspeed and wind estimation problem in SITL
4 participants