Skip to content

ENH: new dimensions route to get rocket geometry#71

Open
aasitvora99 wants to merge 9 commits intomasterfrom
enh/rocket-drawing-geometry
Open

ENH: new dimensions route to get rocket geometry#71
aasitvora99 wants to merge 9 commits intomasterfrom
enh/rocket-drawing-geometry

Conversation

@aasitvora99
Copy link
Copy Markdown
Member

@aasitvora99 aasitvora99 commented Apr 20, 2026

aasitvora99 and others added 2 commits April 20, 2026 12:40
Exposes structured drawing geometry that mirrors rocketpy.Rocket.draw(),
so clients can redraw a rocket using the same shape math rocketpy uses
without server-side rendering or duplicated geometry logic in the UI.

Response carries per-surface shape_x/shape_y arrays, body tube segments,
motor patch polygons (nozzle, chamber, grains, tanks, outline), rail
button positions, sensors, t=0 CG/CP, and drawing bounds. Coordinates
are already transformed into the draw frame rocketpy uses.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@aasitvora99 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 36 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 36 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2b6dfef8-45fc-40cf-a113-865eb7b2b05e

📥 Commits

Reviewing files that changed from the base of the PR and between eff3b9d and dc8acf2.

📒 Files selected for processing (8)
  • requirements.txt
  • src/controllers/rocket.py
  • src/models/motor.py
  • src/models/sub/tanks.py
  • src/routes/rocket.py
  • src/services/rocket.py
  • src/views/rocket.py
  • tests/unit/test_routes/conftest.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enh/rocket-drawing-geometry

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.

Align MotorModel and MotorTank with RocketPy's actual constructor
requirements so invalid motors are rejected at the API boundary with a
clear error rather than crashing deep inside RocketPy at simulate time.

- MotorModel.validate_dry_inertia_for_kind: SOLID / LIQUID / HYBRID
  motors in RocketPy require dry_inertia with no default. Only
  GenericMotor accepts (0, 0, 0). Reject the default tuple for every
  kind except GENERIC with a message the user can act on.
- MotorTank.discretize: change to Optional[int] = 100 to match the
  RocketPy Tank classes' default. Forms can now omit the field and still
  submit successfully.
- stub_motor_dump fixture: use dry_inertia=[0.1, 0.1, 0.1] so tests that
  override motor_kind to SOLID / LIQUID / HYBRID still pass the new
  validator without each having to add a dry_inertia override locally.
RocketPy's rocket.draw() does not draw a combustion chamber for
GenericMotor because _MotorPlots._generate_combustion_chamber reads
grain-only attributes (grain_initial_height, grain_outer_radius, etc.)
that GenericMotor lacks — it only emits a nozzle. Users who populate
chamber_radius / chamber_height / chamber_position then saw no chamber
in the jarvis playground.

Add a GenericMotor branch in RocketService._build_motor_geometry that
constructs an equivalent rectangular chamber patch from the chamber_*
fields. Vertex ordering mirrors _generate_combustion_chamber so the
patch flows through _generate_motor_region for outline assembly the
same way a SolidMotor chamber does.

Patch is emitted with role='chamber', flowing through the existing
drawingMotorSchema + GeometryRocket renderer without frontend changes.
@aasitvora99 aasitvora99 marked this pull request as ready for review April 22, 2026 17:55
@aasitvora99 aasitvora99 changed the title Enh/rocket drawing geometry ENH: new dimensions route to get rocket geometry Apr 22, 2026
Comment thread src/models/motor.py
# RocketPy's SolidMotor/LiquidMotor/HybridMotor require dry_inertia with no default.
# Only GenericMotor accepts (0, 0, 0). Surface a clear error at the API boundary
# instead of letting RocketPy crash deep in construction.
if self.motor_kind != MotorKinds.GENERIC and self.dry_inertia == (
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why this validator exists (for future reviewers)

RocketPy itself enforces non-zero dry_inertia for every non-Generic motor kind. Verified against the installed rocketpy package:

Motor class dry_inertia default
SolidMotor required (no default)
LiquidMotor required (no default)
HybridMotor required (no default)
GenericMotor (0, 0, 0)

dry_inertia is the motor's dry-mass inertia tensor (I_11, I_22, I_33) in kg·m² about center_of_dry_mass_position. Rocketpy consumes it directly in Motor.__init__:

# rocketpy/motors/motor.py
inertia = (*dry_inertia, 0, 0, 0) if len(dry_inertia) == 3 else dry_inertia
self.dry_I_11 = inertia[0]
self.dry_I_22 = inertia[1]
self.dry_I_33 = inertia[2]

These feed the 6-DOF flight integrator's angular equations of motion. Passing (0, 0, 0) for a Solid/Liquid/Hybrid motor doesn't just fail fast in rocketpy — historically it could silently produce a motor with zero rotational inertia, corrupting every downstream simulation (pitch/yaw response, static margin, stability).

Our MotorModel.dry_inertia defaults to (0, 0, 0) for schema convenience. This validator converts what would otherwise be either (a) a deep rocketpy construction crash or (b) a silent simulation-correctness bug into a clear 422 at the API boundary, with a motor-kind-specific error message telling the client exactly what to provide.

GenericMotor is rocketpy's "black-box thrust curve" motor, explicitly designed for the case where the caller doesn't have real inertia data — so it's the one kind where (0, 0, 0) is legitimate, and the validator allows it.

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.

3 participants