Repository navigation
feat(blocks): register the parameters of every block, so set_param, parameters() and --set work - #940
Draft
petercorke wants to merge 2 commits into
Draft
petercorke wants to merge 2 commits into
petercorke wants to merge 2 commits into
Conversation
…arameters() and --set work Every __init__ argument of the arm, mobile, spatial and UAV blocks is registered with add_param, with when="anytime", "setup" (read by start()) or "never" (the robot and model, which fix the ports). Values that the block derived state from are properties: FDyn q0, Jacobian frame/representation/inverse/pinv, CirclePath frequency/phase, Point2Tr T, the vehicle limits and dimensions, MultiRotor x0 and MultiRotorMixer wmax/wmin. tests/test_block_parameters.py checks that none is left out. Fixes found on the way: - IKine.start() took no simstate, so any run with an IKINE block failed - IKine ignored its seed argument, it is now used (the default is still 0) - JTraj, CTraj, Trapezoidal and Traj overwrote T with the length of the first run, so a later run of a different length used the old one Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 101 |
| Duplication | 4 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
petercorke
marked this pull request as draft
November 15, 2026 02:55
Owner
Author
|
Held as a draft: this needs bdsim 1.5.0, which is not released yet. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for contributing to RTB!
Summary
Register the parameters of every RTB block with bdsim's parameter registry, so
block.set_param(),block.parameters()and bdsim's--setand--paramwork on them. None was registered:parameters()returned{}for every RTB block.Every
__init__argument of the 27 blocks inarm.py,mobile.py,spatial.pyanduav.pyis registered withadd_param:when="never":robotandmodel, which fix the ports and states.when="setup": anythingstart()reads, such asq0,T, trajectory end points and plot options. It can be set before the run starts, not during it.when="anytime": everything else.propertywhere the block derived state from the argument:FDyn/FDyn_Xq0(the first half of the initial state),Jacobianframe/representation/inverse/pinv(they rebuild the function and check each other),CirclePathfrequency/phase(kept in the unit given),Point2TrT, the vehicle limits andL/wofBicycle/Unicycle/DiffSteer(written into the vehicle model),MultiRotorx0(keeps its short forms) andMultiRotorMixerwmax/wmin.tests/test_block_parameters.pychecks that no argument is left out, and has behaviour tests for the properties.Fixes found on the way, in this commit because the registration made them visible:
IKine.start()took nosimstate, so any run with anIKINEblock failed.IKineignored itsseedargument and always used 0. It is used now; the default is still 0.JTraj,CTraj,TrapezoidalandTrajoverwroteTwith the length of the first run, so a later run of a different length used the old one.Not fixed, found:
CTRAJ,TRAJandTRAPEZOIDALcannot be compiled into a diagram, because bdsim'scompile()evaluates outputs beforestart(); this is so onmain.Trapezoidalalso fails whenq0andqfare vectors. The tests start those blocks directly.VehiclePlot.shapecannot be a parameter, since a block already has ashapeproperty. It is the one exception in the test. petercorke/bdsim#255 removesBlock.shape, after which it can be.Public behaviour:
set_paramand--setnow work on RTB blocks, andseedand per-runTbehave as above. No change to numerical results otherwise.Conflicts with #938 in
FDyn.__init__(both touch the initial acceleration); I will rebase whichever is second.Related: #937 changes how the vehicle limits are stored, which the vehicle-limit properties here write to.
This change was written with AI assistance (Claude Code); I have read the diff myself.
Related issue
None.
Checklist
type: description)pytest): 2470 passed, 9 skipped🤖 Generated with Claude Code