Skip to content

fix(project-airsim): integrate JSBSim in 1 ms substeps so the quadrotor rests and flies - #439

Open
andrewjong wants to merge 1 commit into
developfrom
fix/project-airsim-jsbsim
Open

andrewjong wants to merge 1 commit into
developfrom
fix/project-airsim-jsbsim

Conversation

@andrewjong

Copy link
Copy Markdown
Member

What features did you add and/or bugs did you address?

  • Which GitHub issue does this address?

    No issue. It finishes the JSBSim option of the Project AirSim backend (feat(sim): Project AirSim simulator backend (airstack up --sim projectairsim) #437), which was merged as experimental.

  • Additional description if not fully described in the GitHub issue

    With --physics jsbsim, PX4 took about 90 s to pass preflight. The vehicle chattered on the ground: accelerometer spikes near 50 m/s² and ground-truth roll/pitch rates of ±0.3 rad/s while it should have been at rest.

    Cause: we integrated JSBSim at the 3 ms simulator tick (jsbsim-dt = tick, as in upstream's quadrotor example). At that step the landing-gear friction of quadrotor_x (μ = 5) solves unstably. The spike size matches the friction limit (5 × 55 N ≈ 49 m/s² on 5.6 kg), and consecutive samples flip sign, which is the signature of numerical instability rather than real sliding.

    Ruled out:

    • spawn mode (ground with start-landed, ground free, airborne like upstream);
    • Unreal collision (disabled on every link: no change);
    • plugin version (v1.1.0 package vs one built from Project AirSim main).

    The earlier "airborne spawn rejected" finding was the empty jsbsim-model bug, fixed in feat(sim): Project AirSim simulator backend (airstack up --sim projectairsim) #437.

  • Please add videos and images to demonstrate the feature.

    No visual change. Evidence is PX4's state at rest and the flight metrics below.

How did you implement it?

  • simulation/project-airsim/config/generate_scene.py: jsbsim-dt = min(tick, JSBSIM_MAX_DT_S) with JSBSIM_MAX_DT_S = 0.001. Project AirSim runs JSBSim in substeps of at most jsbsim-dt per clock tick (in both v1.1.0 and main), so the default 3 ms tick now runs three 1 ms substeps. The JSBSim model is unchanged.

    Drone at rest, default ground spawn 3 ms (before) 1 ms substeps
    PX4 "Ready for takeoff" after boot 87 s 5 s
    Accelerometer spikes ±47 m/s² ±0.07 m/s²
    PX4 cs_vehicle_at_rest false true
    Ground-truth roll-rate std 0.12 rad/s 0.004 rad/s
    Simulator CPU / RTF — 4.7 cores / 1.01
  • Test harness: new --physics fast-physics|jsbsim option. For Project AirSim runs it sets PROJECT_AIRSIM_PHYSICS, same as airstack up --physics; other sims ignore it. It is part of the run's campaign fingerprint, so JSBSim metrics are never compared against fast-physics ones; unset keeps existing fingerprints unchanged. airstack help test lists it.

  • Docs: the guide's physics table no longer calls JSBSim experimental and explains the substep. The 0.21.0 release note is updated.

How do you run and use it?

airstack up --sim projectairsim --physics jsbsim --headless
airstack ready

Then fly as with fast-physics, for example with the GCS takeoff and land tasks. Per robot via a fleet file: robots.<name>.physics: jsbsim.

Testing with PyTest

  • What pytests did you add to ensure the feature is reliable and robust? What metrics are used?

    test_jsbsim_substeps_at_most_1ms in tests/meta/test_project_airsim_scene_contract.py pins the cap: 1 ms at the default tick, and a finer tick is used as-is. The new --physics option lets the existing liveliness and takeoff/hover/land tests run on JSBSim, using their usual metrics.

  • What's the exact command to run the pytests that test your feature?

    airstack test -m unit -v
    airstack test -m "liveliness or takeoff_hover_land" --sim projectairsim --num-robots 1 \
      --physics jsbsim --takeoff-velocities 0.5,1,2 -v
    
  • What are the expected results of the tests?

    Unit/meta: 439 passed. The JSBSim system run passed 20/20. Against fast-physics on the same harness and image:

    Metric fast-physics JSBSim
    PX4 ready (test_px4_ready) 18.8 s 18.4 s
    Hover position std @ 0.5 / 1 / 2 m/s 0.013 / 0.022 / 0.057 m 0.013 / 0.012 / 0.015 m
    Hover altitude error @ 0.5 / 1 / 2 m/s 0.020 / 0.034 / 0.102 m 0.018 / 0.016 / 0.023 m
    Takeoff velocity RMSE @ 0.5 / 1 m/s 0.180 / 0.256 0.115 / 0.274
    Landing velocity RMSE @ 0.5 / 1 / 2 m/s 0.114 / 0.230 / 0.978 0.115 / 0.231 / 0.993

    Odometry error against ground truth is 0.38–0.55 m on JSBSim (0.28–0.39 m on fast-physics). That includes a constant −0.20 m altitude offset, because JSBSim's vehicle rests on its gear 0.2 m above the spawn point.

Documentation

  • Was mkdocs.yml updated? (y/n)

    n. Existing pages changed: the Project AirSim guide (physics section) and the release notes. mkdocs build --strict is clean.

  • Do the docs have sufficient scope such that a newcomer can easily reproduce and use your feature?

    Yes. The guide's physics section covers selection, the substep and its reason, and the test flag.

  • Is there sufficient visual media?

    Not applicable.

Versioning

  • Did you make sure to bump the version number in the .env file according to semantic versioning?

    Yes: 0.21.0-dev.20 → 0.21.0-dev.21.

🤖 Generated with Claude Code

…or rests and flies

With JSBSim physics, jsbsim-dt equalled the 3 ms simulator tick (as in
upstream's quadrotor example). At that step quadrotor_x's landing-gear
friction (mu = 5) solves unstably: the vehicle chatters on the ground
(IMU spikes near 50 m/s^2, ground-truth rates +/-0.3 rad/s) and PX4 needs
~90 s before preflight passes. Project AirSim runs JSBSim in substeps of
at most jsbsim-dt per tick, so capping it at 1 ms gives three substeps:
at rest, ready in ~5 s, no measurable CPU or RTF cost. Spawn mode and
Unreal collision were ruled out; the model is unchanged.

- generate_scene.py: jsbsim-dt = min(tick, JSBSIM_MAX_DT_S = 1 ms)
- harness: --physics fast-physics|jsbsim for Project AirSim runs (sets
  PROJECT_AIRSIM_PHYSICS; part of the campaign fingerprint); listed in
  `airstack help test`
- contract test pins the cap; guide and release note drop "experimental"
- VERSION 0.21.0-dev.21

Validated: liveliness + takeoff/hover/land at 0.5/1/2 m/s on
--physics jsbsim, 20/20.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant