Repository navigation
fix(actuators): read an actuator's phase from the position it is put in - #63
Merged
Merged
Conversation
An ArcCrank kept its angle and sweep direction, a LinearActuator its extension and direction, and a Mechanism DriverLink / ArcDriverLink its current_angle, as internal state that set_coords() left alone; only a Crank reads its angle from its coordinates. So the second evaluation of a candidate by kinematic_minimization, a sensitivity analysis or a simulation() context started with the actuator wherever the previous run had stopped it, and two evaluations of the same candidate returned different loci. ArcCrank.set_coord() and LinearActuator.set_coord() now read the angle or the extension from the position they are given — the angle brought onto the arc, since an arc can reach past the range of atan2, the extension held within the stroke — and restart the sweep in the positive direction, as a new actuator does. reload() writes x and y directly, so it is unaffected. Mechanism.set_joint_positions(), hence set_coords(), rebuild() and set_completely(), calls the new DriverLink.read_angle() / ArcDriverLink.read_angle(), which do the same from the motor and output joints. Noted in the review of #62.
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.
The pre-existing limitation noted in the review of #62.
set_coords()put the joints back but not the actuators: anArcCrankkept_angle/_direction, aLinearActuator_extension/_direction, aMechanismDriverLink/ArcDriverLinkitscurrent_angle. Only aCrankre-derives its angle from x/y. So in an optimizer, a sensitivity analysis or asimulation()context, each run started with the actuator wherever the previous one had stopped it — two evaluations of the same candidate returned different loci.Fix: coordinates are now the whole state, for every actuator, as they already were for
Crank.ArcCrank.set_coord()reads the angle from the anchor→position direction, brought onto the arc (an arc like[0, 3π/2]reaches pastatan2's range; off the arc, the nearer end), and restarts the sweep forward as a new crank does.reload()writesx/ydirectly, so stepping is unaffected.LinearActuator.set_coord()reads the extension as the projection onto its axis, held within[0, stroke], and restarts extending.DriverLink.read_angle()/ArcDriverLink.read_angle()do the same from the motor and output joints;Mechanism.set_joint_positions()— henceset_coords(),rebuild(),set_completely()— calls them.Tests: repeated
kinematic_default_testevaluations give identical loci forCrank,ArcCrankandLinearActuator(and equal a fresh linkage's run);Mechanismruns repeat afterset_coords; unit tests for eachset_coord/read_angleincluding the arc wrap-around and the unplaced-joint case. 11 of them fail onmain. Full suite (2650) and docs tests green. Also drops the now-stale "cannot be rewound" wording from #62's comment and changelog.__all__untouched:read_angleis a method, the arc helper is private ingeometry.core.