microsoft / AirSim

Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research
https://microsoft.github.io/AirSim/
Other
16.53k stars 4.6k forks source link

Execution order of simulation loop for drone in Unity #3126

Open ykeuter opened 4 years ago

ykeuter commented 4 years ago

InvokeTickInAirSimis called in LateUpdate: https://github.com/microsoft/AirSim/blob/d59ceb7f63878f5e087ea802d603ba0fd282ff56/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs#L116 while transformis updated in FixedUpdate: https://github.com/microsoft/AirSim/blob/d59ceb7f63878f5e087ea802d603ba0fd282ff56/Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Multirotor/Drone.cs#L41 Is there a reason for this? FixedUpdateand LateUpdateare not necessarily in sync.

Also, I would expect currentPose = poseFromAirLib; after transform is updated.

What am I missing?

ykeuter commented 4 years ago

I changed this execution order in PR #3128 .

Without these changes, on the first call to FixedUpdate the drones are positioned at the origin (since poseFromAirLib is not set yet), causing a collision. AirSim then processes this collision, but at the actual position of the drones, causing the drones to tumble down.

Something similar happens in single drone mode. In this case the "fake" collision (with the floor at the origin now) is interpreted as a landing by AirSim, making the drone "hover" mid-air at the start, even though it is only armed.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity from the community in the last year. It will be closed if no further activity occurs within 20 days.