feat: add Coulomb friction feedforward compensation with YAML-driven config#37
Open
JayKuluky wants to merge 6 commits intoi2rt-robotics:mainfrom
Open
feat: add Coulomb friction feedforward compensation with YAML-driven config#37JayKuluky wants to merge 6 commits intoi2rt-robotics:mainfrom
JayKuluky wants to merge 6 commits intoi2rt-robotics:mainfrom
Conversation
…change the params inside once the best has been find.
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.
Motivation
Direct-drive and low-ratio robotic arms (like YAM Ultra) exhibit noticeable static friction (stiction) on the proximal joints (J0–J2). When teleoperating in leader/follower mode, small leader motions often fail to break free of stiction on the follower without raising the position-loop kp gain — which in turn degrades compliance and makes the system feel stiff.
The standard fix is Coulomb friction feedforward (also called "Cff" in MIT mode controllers): a small velocity-direction-dependent torque added on top of the position-loop output, sized just enough to overcome each joint's stiction. This lets kp stay low (compliant) while still making the follower track small leader motions accurately.
This PR adds that capability to
motor_chain_robotand exposes it through the existing arm YAML configs so per-arm tuned values can live in the repo alongside the rest of the kinematic/dynamic config.Design
Friction compensation is applied at the controller layer, on top of whatever torque the existing control mode (position, MIT, etc.) computes. For each joint i with measured velocity q̇ᵢ:
breakaway_i(Nm, per joint) — the magnitude of the feedforward, tuned to approximately match the joint's static-friction torque. Set to0for any joint that does not need comp.eps(rad/s) — the saturation width of the smooth sign function. Smaller values approach an ideal Coulomb sign; larger values smooth the transition through zero velocity (less chatter when the joint is nearly stationary).tanhis chosen over a hardsign()to avoid torque chatter at zero velocity, which can excite the actuator at the control rate.The compensation is off by default (
enable_friction_comp=Falseand an emptybreakawaytuple both disable it), so existing users see no behavior change.API changes
motor_chain_robotconstructor /get_yam_robot()factoryThree new parameters:
enable_friction_compboolFalseFalse, no comp is applied regardless of breakaway.friction_comp_breakawaynp.ndarray | NoneNoneNoneor all-zeros disables comp.friction_comp_epsfloat0.01tanh.YAML config (per-arm, e.g.
yam_ultra.yml)New optional
friction_compblock:When the YAML provides values, they are loaded as defaults at robot construction time. Constructor kwargs (or downstream CLI flags) take precedence over YAML values when explicitly passed. This lets users commit a known-good tuning per arm while still allowing temporary overrides during tuning sessions.
If the
friction_compblock is absent, behavior is identical to today.Behavior
τ_ff = 0for all joints. Bit-identical control output to the pre-PR behavior.τ_ff,i = breakaway_i · tanh(q̇ᵢ / eps)is added to the joint torque command.tanh(q̇/eps) ≈ q̇/eps, soτ_ffis small and proportional to velocity — no jitter at zero crossings.Backward compatibility
friction_compblock load identically to today.Testing
breakaway = 0→ zero output for any velocityq̇ = 0|q̇| ≫ eps→ output saturates at±breakawaysign()chatter)friction_comploads with the expected values; a config without it loads with comp disabledFuture work / open questions
breakaway_pos/breakaway_negsplit could be added later if needed; current per-joint scalar is a deliberate first step to keep the API small.breakawayvalues are good candidates for offline identification from a chirp test. Happy to discuss in a follow-up.Commits in this PR
feat(motor_chain_robot): add friction compensation parameters and methods— addsenable_friction_comp,friction_comp_breakaway,friction_comp_epsto the robot constructor; implements thetanhCff computation; integrates it into the existing per-cycle torque pipeline.feat(yam_config): load friction comp params from YAML— extends the YAM config loader to readfriction_comp:blocks from the per-arm YAML files; constructor kwargs continue to take precedence.Notes for reviewers
This work was developed against a downstream consumer (a teleoperation pipeline) where the immediate use case is bi-manual YAM follower stiction on small leader motions. The downstream side simply forwards CLI flags into the same three constructor kwargs introduced here — no specialized integration glue is required on the SDK side.
Happy to split commits, rename parameters, adjust the YAML schema, or scope the PR down (e.g. ship the params/methods first, YAML loader as a follow-up) based on review preference.