Skip to content

Ball-beam via composable-model-graph (transfer function + PD/fuzzy control) - #1

Open
bigboateng wants to merge 1 commit into
masterfrom
feat/cmg-ballbeam
Open

Ball-beam via composable-model-graph (transfer function + PD/fuzzy control)#1
bigboateng wants to merge 1 commit into
masterfrom
feat/cmg-ballbeam

Conversation

@bigboateng

Copy link
Copy Markdown
Owner

What

Adds a headless, runnable take on the ball-beam from this repo, expressed through
composable-model-graph,
plus three browser visualizations (no VPython needed).

  • ballbeam_cmg.py — the same physics as inclinedplane.py / main.py, run
    headless, then two cmg variations: (1) the plant is a transfer function — the
    forward-Euler ball-beam is exactly a discrete double integrator G(q) with
    b=[0,0,dt²], a=[-2,1], and running the tilt input through a cmg TransferFunction
    reproduces the hand-written loop to ~1e-11; (2) a PD controller closes the loop and
    balances the ball at a setpoint. Deterministic and self-checking (PASS/FAIL).
  • ballbeam_sim.html — live animated ball-beam: a PD controller tilts the beam to
    keep the ball on the center mark; click/nudge to disturb it.
  • ballbeam_compare.html — the same beam under PD vs a Sugeno fuzzy controller
    (error + rate-of-error inputs), getting the same disturbances, so the difference in
    behaviour is visible side by side.
  • ballbeam_cmg.html — a chart of the trajectories (Euler vs transfer function
    overlay; the controller settling curve).

Why

It makes the implicit structure explicit: the integration loop in the original sim is a
transfer function, and the fuzzy controller is mathematically the same blend (local
linear consequents weighted by membership). Old files are untouched; these are additive.

Run

# headless script (needs the cmg python package on the path)
PYTHONPATH=/path/to/composable-model-graph/python/src python3 ballbeam_cmg.py
# visualizations: just open the .html files in a browser

🤖 Generated with Claude Code

…D/fuzzy control)

Headless ballbeam_cmg.py (original physics + cmg TransferFunction plant + PD control, self-checking) and three browser visualizations (live PD sim, PD-vs-fuzzy comparison, trajectory chart). Old files untouched; additive only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants