Skip to content

Project Restructuring#4

Open
ehenry344 wants to merge 4 commits into
betaflight:gzfrom
ehenry344:gz
Open

Project Restructuring#4
ehenry344 wants to merge 4 commits into
betaflight:gzfrom
ehenry344:gz

Conversation

@ehenry344

@ehenry344 ehenry344 commented May 30, 2026

Copy link
Copy Markdown

This pull request restructures the project to improve workflow. Changes include default build output rerouting, README update and more.

Summary by CodeRabbit

  • Improvements

    • Tightened simulation timestep and adjusted rotor aerodynamic parameters for more realistic behaviour.
  • Documentation

    • Rewrote README with supported platforms, setup and launcher guidance.
    • Removed outdated migration guide and simplified plugin/build instructions.
  • Chores

    • Refined build scripts and project path handling.
    • Reorganised ignore rules with clearer artifact categorisation.

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Refactors build paths and scripts, reorganises .gitignore, increases LiftDrag a0 for all four rotors, reduces world max_step_size, and replaces README content with setup and platform guidance.

Changes

Project build, model, world and docs updates

Layer / File(s) Summary
Build system & scripts
CMakeLists.txt, scripts/build_plugin.sh, .gitignore
CMakeLists now references src/BetaflightPlugin.cc. scripts/build_plugin.sh computes PROJECT_DIR from the script location, derives SRC_DIR and BUILD_DIR, and simplifies the cmake existence check; .gitignore reorganised into Gazebo, SDF, config, and build sections.
Model LiftDrag parameter tuning
assets/models/betaloop_iris_with_standoffs/model.sdf
All gz::sim::systems::LiftDrag plugin a0 parameters for rotors rotor_0..rotor_3 were increased from 0.025 to 0.05; EOF newline around </sdf> adjusted.
World physics timestep
assets/worlds/betaloop_iris_betaflight_demo_harmonic.sdf
realtime physics max_step_size changed from 0.004 to 0.001.
README rewrite
README.md
README body replaced with new project description, supported platforms, prerequisites, setup guide, launcher guidance, and acknowledgements.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 From roots the build scripts now depart,
Rotors tuned to stronger lifting art,
The world ticks smaller steps in time,
Docs now guide the setup line by line,
A little hop, a tidy vault — work done with heart.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Project Restructuring' is vague and generic, failing to convey the specific nature of the changes made across multiple files and systems. Use a more descriptive title that highlights the primary change, such as 'Restructure project paths and build configuration' or 'Refactor build system and update model parameters'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
assets/models/betaloop_iris_with_standoffs/model.sdf (1)

645-696: ⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

Fix Betaflight rotor→joint mapping: <rotor id> is ignored for motor indexing (order matters), so the current jointName / turningDirection don’t match the documented BF QUADX motor order.

BetaflightPlugin reads <rotor id> but applies commands as this->rotors[i].cmd = pkt.motorSpeed[i] where i is the <rotor> element parse order—so motorSpeed[0] drives the first <rotor> block’s jointName/turningDirection. In assets/models/betaloop_iris_with_standoffs/model.sdf the comment mapping (639-644) is therefore contradicted by the current rotor blocks (648-695).

🐛 Proposed fix to align mapping with the documented BF motor order
       <rotor id="0">
         ...
-        <jointName>rotor_0_joint</jointName>
-        <turningDirection>ccw</turningDirection>
+        <jointName>rotor_3_joint</jointName>
+        <turningDirection>cw</turningDirection>
         <rotorVelocitySlowdownSim>1</rotorVelocitySlowdownSim>
       </rotor>
       <rotor id="1">
         ...
-        <jointName>rotor_1_joint</jointName>
-        <turningDirection>ccw</turningDirection>
+        <jointName>rotor_0_joint</jointName>
+        <turningDirection>ccw</turningDirection>
         <rotorVelocitySlowdownSim>1</rotorVelocitySlowdownSim>
       </rotor>
       <rotor id="2">
         ...
-        <jointName>rotor_2_joint</jointName>
-        <turningDirection>cw</turningDirection>
+        <jointName>rotor_1_joint</jointName>
+        <turningDirection>ccw</turningDirection>
         <rotorVelocitySlowdownSim>1</rotorVelocitySlowdownSim>
       </rotor>
       <rotor id="3">
         ...
-        <jointName>rotor_3_joint</jointName>
-        <turningDirection>cw</turningDirection>
+        <jointName>rotor_2_joint</jointName>
+        <turningDirection>cw</turningDirection>
         <rotorVelocitySlowdownSim>1</rotorVelocitySlowdownSim>
       </rotor>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@assets/models/betaloop_iris_with_standoffs/model.sdf` around lines 645 - 696,
The BetaflightPlugin uses the parse order of <rotor> elements (not the <rotor
id>) to map motorSpeed[i] to this->rotors[i].cmd, so reorder the <rotor> blocks
in the SDF to match the documented Betaflight QUADX motor order and update each
<jointName> and <turningDirection> values accordingly; keep the existing <rotor
id> values if you want them for readability but ensure the element order of the
<rotor> blocks matches the expected motorSpeed index mapping used by
BetaflightPlugin (references: BetaflightPlugin, <rotor>, <jointName>,
<turningDirection>, motorSpeed).
🧹 Nitpick comments (1)
scripts/build_plugin.sh (1)

18-20: 💤 Low value

SRC_DIR is unused — drop it.

Static analysis (SC2034) flags SRC_DIR as never referenced after the restructure; only PROJECT_DIR and BUILD_DIR are used.

♻️ Proposed cleanup
 PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
-SRC_DIR="$PROJECT_DIR/src"
 BUILD_DIR="$PROJECT_DIR/build"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build_plugin.sh` around lines 18 - 20, Remove the unused SRC_DIR
variable assignment to satisfy SC2034: delete the line that sets
SRC_DIR="$PROJECT_DIR/src" and leave only PROJECT_DIR and BUILD_DIR declarations
(PROJECT_DIR="$(dirname "$SCRIPT_DIR")" and BUILD_DIR="$PROJECT_DIR/build");
also scan for any remaining references to SRC_DIR in the script and remove or
replace them so no stale usage remains.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Line 7: The README currently uses the incorrect product name "MacOS"; update
the sentence in the README that reads "Ubuntu Linux and MacOS" to use the
correct capitalization and spelling "macOS" so it reads "Ubuntu Linux and macOS"
(locate the string in README.md).

---

Outside diff comments:
In `@assets/models/betaloop_iris_with_standoffs/model.sdf`:
- Around line 645-696: The BetaflightPlugin uses the parse order of <rotor>
elements (not the <rotor id>) to map motorSpeed[i] to this->rotors[i].cmd, so
reorder the <rotor> blocks in the SDF to match the documented Betaflight QUADX
motor order and update each <jointName> and <turningDirection> values
accordingly; keep the existing <rotor id> values if you want them for
readability but ensure the element order of the <rotor> blocks matches the
expected motorSpeed index mapping used by BetaflightPlugin (references:
BetaflightPlugin, <rotor>, <jointName>, <turningDirection>, motorSpeed).

---

Nitpick comments:
In `@scripts/build_plugin.sh`:
- Around line 18-20: Remove the unused SRC_DIR variable assignment to satisfy
SC2034: delete the line that sets SRC_DIR="$PROJECT_DIR/src" and leave only
PROJECT_DIR and BUILD_DIR declarations (PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
and BUILD_DIR="$PROJECT_DIR/build"); also scan for any remaining references to
SRC_DIR in the script and remove or replace them so no stale usage remains.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 30023ab4-5b0d-45b2-869b-e8abcd9a9fef

📥 Commits

Reviewing files that changed from the base of the PR and between a6c16d2 and 8645829.

⛔ Files ignored due to path filters (12)
  • assets/models/battery_tattu_1300/mesh/tattu_1300.dae is excluded by !**/*.dae
  • assets/models/betaloop_gimbal_2d/meshes/base_arm.dae is excluded by !**/*.dae
  • assets/models/betaloop_gimbal_2d/meshes/base_main.dae is excluded by !**/*.dae
  • assets/models/betaloop_gimbal_2d/meshes/tilt.dae is excluded by !**/*.dae
  • assets/models/betaloop_iris_with_standoffs/meshes/iris.dae is excluded by !**/*.dae
  • assets/models/betaloop_iris_with_standoffs/meshes/iris_prop_ccw.dae is excluded by !**/*.dae
  • assets/models/betaloop_iris_with_standoffs/meshes/iris_prop_cw.dae is excluded by !**/*.dae
  • assets/models/camera_runcam_micro_swift/meshes/runcam_micro_swift.dae is excluded by !**/*.dae
  • assets/models/motor_emax_rs2306/mesh/motor_emax_rs2306.dae is excluded by !**/*.dae
  • assets/models/quadcopter_model/meshes/iris.dae is excluded by !**/*.dae
  • assets/models/quadcopter_model/meshes/iris_prop_ccw.dae is excluded by !**/*.dae
  • assets/models/quadcopter_model/meshes/iris_prop_cw.dae is excluded by !**/*.dae
📒 Files selected for processing (38)
  • .gitignore
  • CMakeLists.txt
  • GAZEBO_HARMONIC_MIGRATION.md
  • README.md
  • assets/models/README.md
  • assets/models/battery_tattu_1300/README.md
  • assets/models/betaloop_gimbal_2d/model.config
  • assets/models/betaloop_gimbal_2d/model.sdf
  • assets/models/betaloop_iris_with_standoffs/model.config
  • assets/models/betaloop_iris_with_standoffs/model.sdf
  • assets/models/betaloop_iris_with_standoffs_demo/model.config
  • assets/models/betaloop_iris_with_standoffs_demo/model.sdf
  • assets/models/camera_runcam_micro_swift/README.md
  • assets/models/camera_runcam_micro_swift/model.config
  • assets/models/camera_runcam_micro_swift/model.sdf
  • assets/models/motor_emax_rs2306/README.md
  • assets/models/quadcopter/model.config
  • assets/models/quadcopter/model.sdf
  • assets/models/quadcopter_attitude_control/model.config
  • assets/models/quadcopter_attitude_control/model.sdf
  • assets/models/quadcopter_model/model.config
  • assets/models/quadcopter_model/model.sdf
  • assets/models/quadcopter_model/model.tpl
  • assets/models/test_quad/model.config
  • assets/models/test_quad/model.sdf
  • assets/worlds/betaloop_iris_betaflight_demo.world
  • assets/worlds/betaloop_iris_betaflight_demo_gasstation.world
  • assets/worlds/betaloop_iris_betaflight_demo_harmonic.sdf
  • assets/worlds/fixed.world
  • assets/worlds/quadcopter_test_harmonic.sdf
  • assets/worlds/test_betaflight.sdf
  • assets/worlds/test_harmonic.sdf
  • plugins/README.md
  • scripts/build_plugin.sh
  • scripts/install_gazebo_harmonic.sh
  • src/BetaflightPlugin.cc
  • src/BetaflightPlugin.hh
  • start_gazebo.sh
💤 Files with no reviewable changes (3)
  • plugins/README.md
  • GAZEBO_HARMONIC_MIGRATION.md
  • start_gazebo.sh

Comment thread README.md
developing realistic and accurate aircraft models.
## Supported Platforms

This project has native support and has been tested with Ubuntu Linux and MacOS. Windows is supported through WSL2.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the correct product name "macOS".

Apple's OS is written "macOS", not "MacOS".

✏️ Proposed fix
-This project has native support and has been tested with Ubuntu Linux and MacOS. Windows is supported through WSL2.
+This project has native support and has been tested with Ubuntu Linux and macOS. Windows is supported through WSL2.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
This project has native support and has been tested with Ubuntu Linux and MacOS. Windows is supported through WSL2.
This project has native support and has been tested with Ubuntu Linux and macOS. Windows is supported through WSL2.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~7-~7: The operating system from Apple is written “macOS”.
Context: ...d has been tested with Ubuntu Linux and MacOS. Windows is supported through WSL2. ##...

(MAC_OS)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 7, The README currently uses the incorrect product name
"MacOS"; update the sentence in the README that reads "Ubuntu Linux and MacOS"
to use the correct capitalization and spelling "macOS" so it reads "Ubuntu Linux
and macOS" (locate the string in README.md).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
assets/worlds/betaloop_iris_betaflight_demo_harmonic.sdf (1)

17-17: ⚡ Quick win

Confirm the performance impact of the tighter physics timestep.

The max_step_size has been reduced from 0.004 to 0.001 (4 ms to 1 ms), which increases the physics update rate by a factor of four. While this improves simulation accuracy and better aligns with the 1000 Hz IMU update rate, it will also increase computational load by approximately 4×.

Ensure that the target hardware can maintain real-time performance with this configuration, particularly when combined with the modified LiftDrag parameters.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@assets/worlds/betaloop_iris_betaflight_demo_harmonic.sdf` at line 17, The
physics timestep was tightened by changing the <max_step_size> value from 0.004
to 0.001 which will raise physics update rate ~4× and likely increase CPU load;
verify real-time performance on the target hardware (run the full stack with the
modified <max_step_size> and the updated LiftDrag parameters, measure CPU usage
and real-time factor), and if the system cannot sustain real-time, either: raise
<max_step_size> to a value that meets performance targets (e.g., back to 0.004
or an intermediate value), offload/optimize costly components, or document the
hardware requirements and intended trade-offs in the world file comment. Ensure
tests include IMU/physics-coupled scenarios so timing and stability are
validated.
assets/models/betaloop_iris_with_standoffs/model.sdf (2)

505-623: ⚡ Quick win

Verify the impact of doubling the a0 lift parameter.

The a0 parameter has been increased from 0.025 to 0.05 across all eight LiftDrag plugin instances (two per rotor for four rotors). This change doubles the zero-angle-of-attack lift coefficient, which will significantly alter the aircraft's aerodynamic behaviour and likely reduce the required hover throttle by approximately half.

Ensure this tuning change has been tested in simulation and produces the desired flight characteristics.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@assets/models/betaloop_iris_with_standoffs/model.sdf` around lines 505 - 623,
The a0 lift parameter was doubled from 0.025 to 0.05 across all LiftDrag plugin
instances, which will significantly change aircraft lift; locate every
gz::sim::systems::LiftDrag plugin block in model.sdf for link_name entries
rotor_0, rotor_1, rotor_2, and rotor_3 (each rotor has two LiftDrag blocks) and
either revert a0 back to 0.025 or run controlled simulation tests (hover
throttle, trim, and stability) to validate the new value; if the new behavior is
undesired, set a0=0.025 in those plugin blocks and add a short comment
documenting the tested values and test results.

501-501: ⚡ Quick win

Update the comment to reflect the new a0 value.

The comment still references a0=0.025 and ~42% hover throttle, but the actual a0 value has been changed to 0.05. Please update this comment to document the new tuning parameters and expected hover throttle percentage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@assets/models/betaloop_iris_with_standoffs/model.sdf` at line 501, The inline
comment that currently says "a0=0.025 tuned for ~42% hover throttle" is stale;
change it to state the new tuning parameter a0=0.05 and update the expected
hover throttle percentage accordingly (recompute or measure the hover throttle
with a0=0.05 and replace "~42%" with the observed value). Locate the comment
near the a0 parameter in the model.sdf and ensure the text documents the actual
a0 value and the measured/expected hover throttle percentage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@assets/models/betaloop_iris_with_standoffs/model.sdf`:
- Around line 505-623: The a0 lift parameter was doubled from 0.025 to 0.05
across all LiftDrag plugin instances, which will significantly change aircraft
lift; locate every gz::sim::systems::LiftDrag plugin block in model.sdf for
link_name entries rotor_0, rotor_1, rotor_2, and rotor_3 (each rotor has two
LiftDrag blocks) and either revert a0 back to 0.025 or run controlled simulation
tests (hover throttle, trim, and stability) to validate the new value; if the
new behavior is undesired, set a0=0.025 in those plugin blocks and add a short
comment documenting the tested values and test results.
- Line 501: The inline comment that currently says "a0=0.025 tuned for ~42%
hover throttle" is stale; change it to state the new tuning parameter a0=0.05
and update the expected hover throttle percentage accordingly (recompute or
measure the hover throttle with a0=0.05 and replace "~42%" with the observed
value). Locate the comment near the a0 parameter in the model.sdf and ensure the
text documents the actual a0 value and the measured/expected hover throttle
percentage.

In `@assets/worlds/betaloop_iris_betaflight_demo_harmonic.sdf`:
- Line 17: The physics timestep was tightened by changing the <max_step_size>
value from 0.004 to 0.001 which will raise physics update rate ~4× and likely
increase CPU load; verify real-time performance on the target hardware (run the
full stack with the modified <max_step_size> and the updated LiftDrag
parameters, measure CPU usage and real-time factor), and if the system cannot
sustain real-time, either: raise <max_step_size> to a value that meets
performance targets (e.g., back to 0.004 or an intermediate value),
offload/optimize costly components, or document the hardware requirements and
intended trade-offs in the world file comment. Ensure tests include
IMU/physics-coupled scenarios so timing and stability are validated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4f8a8a9f-50c3-4194-b600-18d099661cb9

📥 Commits

Reviewing files that changed from the base of the PR and between 8645829 and 85e245a.

📒 Files selected for processing (2)
  • assets/models/betaloop_iris_with_standoffs/model.sdf
  • assets/worlds/betaloop_iris_betaflight_demo_harmonic.sdf

@ehenry344

Copy link
Copy Markdown
Author

@blckmn Please review when you get a chance.

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