-
Notifications
You must be signed in to change notification settings - Fork 708
feat(go2): RPP Trajectory controller + decoupled pub/sub benchmark & scoring #2605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mustafab0
wants to merge
1
commit into
main
Choose a base branch
from
mustafa/go2-controller-benchmark
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Copyright 2025-2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Static feedforward gain compensator (Strategy B). | ||
|
|
||
| Sits between any path-following controller and the platform. Rather than | ||
| closing a velocity loop with a PID (which requires actual_velocity feedback | ||
| and is fragile when cascaded over a firmware that already tracks velocity), | ||
| this compensator just **inverts the steady-state plant gain** so the | ||
| controller's "I want vx=X" command actually produces vx=X at the wheels: | ||
|
|
||
| cmd_to_robot = controller_cmd / K_plant | ||
|
|
||
| Stateless, no actual feedback needed, no phase-margin issues. Works as | ||
| long as K is reasonably accurate. Trade: doesn't compensate for plant | ||
| dynamics (tau, L) - controller's own outer loop handles those via pose | ||
| feedback. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| def _clamp(v: float, lo: float, hi: float) -> float: | ||
| return max(lo, min(hi, v)) | ||
|
|
||
|
|
||
| @dataclass | ||
| class FeedforwardGainConfig: | ||
| """Steady-state plant gains. Default = unity (passthrough). | ||
|
|
||
| For Go2, do not hardcode: read the vendored fit | ||
| ``dimos.utils.benchmarking.plant_models.GO2_PLANT_FITTED`` (currently | ||
| ``K_vx≈0.92``, ``K_wz≈2.45``). A stale hardcoded ``K_wz=2.175`` copy | ||
| silently mis-calibrated every FF controller; the single source of | ||
| truth is plant_models. | ||
| """ | ||
|
|
||
| K_vx: float = 1.0 | ||
| K_vy: float = 1.0 | ||
| K_wz: float = 1.0 | ||
| output_min_vx: float = -1.0 | ||
| output_max_vx: float = 1.0 | ||
| output_min_vy: float = -1.0 | ||
| output_max_vy: float = 1.0 | ||
| output_min_wz: float = -1.5 | ||
| output_max_wz: float = 1.5 | ||
|
|
||
|
|
||
| class FeedforwardGainCompensator: | ||
| """Divide controller-output velocities by plant gains; clamp to limits. | ||
|
|
||
| API mirrors :class:`VelocityTrackingPID.compute` so it slots into the | ||
| same place in the path-follower task pipeline. ``actual_*`` arguments | ||
| are accepted but ignored - this is pure feedforward. | ||
| """ | ||
|
|
||
| def __init__(self, config: FeedforwardGainConfig | None = None) -> None: | ||
| self.cfg = config or FeedforwardGainConfig() | ||
|
|
||
| def compute( | ||
| self, | ||
| desired_vx: float, | ||
| desired_vy: float, | ||
| desired_wz: float, | ||
| actual_vx: float = 0.0, | ||
| actual_vy: float = 0.0, | ||
| actual_wz: float = 0.0, | ||
| ) -> tuple[float, float, float]: | ||
| return ( | ||
| _clamp(desired_vx / self.cfg.K_vx, self.cfg.output_min_vx, self.cfg.output_max_vx), | ||
| _clamp(desired_vy / self.cfg.K_vy, self.cfg.output_min_vy, self.cfg.output_max_vy), | ||
| _clamp(desired_wz / self.cfg.K_wz, self.cfg.output_min_wz, self.cfg.output_max_wz), | ||
| ) | ||
|
|
||
| def reset(self) -> None: | ||
| # Stateless. Method exists so it's drop-in for VelocityTrackingPID. | ||
| pass | ||
|
|
||
|
|
||
| __all__ = ["FeedforwardGainCompensator", "FeedforwardGainConfig"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Copyright 2025-2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| TASK_FACTORIES = { | ||
| "path_follower": "dimos.control.tasks.path_follower_task.path_follower_task:create_task", | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_pathcalled under_task_lock— blocks tick loop during path setup_on_pathholds_task_lockfor the entire duration of theset_pathcall chain, which resolves tostart_path→PathDistancer.__init__(numpy cumulative-distance array) +VelocityProfiler.precompute_profile(forward/backward accel passes). For the benchmark's 100–200 waypoint paths this is sub-millisecond and harmless, but it becomes more visible with longer nav-stack paths. Consider copying task references before releasing the lock and doing the setup work outside it.