-
Notifications
You must be signed in to change notification settings - Fork 153
feat(robot): Go2 fleet support for multi-robot control #1487
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f6c33a2
feat: obstacle avoid off + balance stand for go2
ruthwikdasyam 2f1afbe
feat: connection to multiple go2
ruthwikdasyam f76fe0f
feat: robot_ips env variable
ruthwikdasyam fe49025
feat: fleet connection
ruthwikdasyam eae4d35
feat: fleet blueprints
ruthwikdasyam 8729005
misc: fixes
ruthwikdasyam 0ea0a11
fix: pre-commit issues
ruthwikdasyam 9031962
fix: try except every error
ruthwikdasyam 75d6053
fix: greptile issues
ruthwikdasyam 37fedd3
fix: liedown method missing
ruthwikdasyam b73376f
fix: remove deploy
ruthwikdasyam de8b8cb
feat: phone teleop blueprint
ruthwikdasyam a247600
feat: obstcale_avoidance variable
ruthwikdasyam 08b2e92
fix: correct logging + remove broadcast method
ruthwikdasyam 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
Some comments aren't visible on the classic Files Changed page.
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
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
39 changes: 39 additions & 0 deletions
39
dimos/robot/unitree/go2/blueprints/basic/unitree_go2_fleet.py
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,39 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| # 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. | ||
|
|
||
| """Blueprint for Go2 fleet — multiple Go2 robots controlled together. | ||
|
|
||
| Usage: | ||
| ROBOT_IPS=10.0.0.102,10.0.0.209 dimos run unitree-go2-fleet | ||
| """ | ||
|
|
||
| from dimos.core.blueprints import autoconnect | ||
| from dimos.protocol.service.system_configurator import ClockSyncConfigurator | ||
| from dimos.robot.unitree.go2.blueprints.basic.unitree_go2_basic import with_vis | ||
| from dimos.robot.unitree.go2.fleet_connection import go2_fleet_connection | ||
| from dimos.web.websocket_vis.websocket_vis_module import websocket_vis | ||
|
|
||
| unitree_go2_fleet = ( | ||
| autoconnect( | ||
| with_vis, | ||
| go2_fleet_connection(), | ||
| websocket_vis(), | ||
| ) | ||
| .global_config(n_workers=4, robot_model="unitree_go2") | ||
| .configurators(ClockSyncConfigurator()) | ||
| ) | ||
|
|
||
| __all__ = ["unitree_go2_fleet"] |
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,140 @@ | ||
| # 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. | ||
|
|
||
| """Go2 Fleet Connection - manage multiple Go2 robots as a fleet""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from dimos.core.core import rpc | ||
| from dimos.core.global_config import GlobalConfig, global_config | ||
| from dimos.robot.unitree.go2.connection import ( | ||
| GO2Connection, | ||
| Go2ConnectionProtocol, | ||
| make_connection, | ||
| ) | ||
| from dimos.utils.logging_config import setup_logger | ||
|
|
||
| if TYPE_CHECKING: | ||
| from dimos.msgs.geometry_msgs import Twist | ||
|
|
||
| logger = setup_logger() | ||
|
|
||
|
|
||
| class Go2FleetConnection(GO2Connection): | ||
| """Inherits all single-robot behaviour from GO2Connection for the primary | ||
| (first) robot. Additional robots only receive broadcast commands | ||
| (move, standup, liedown, publish_request). | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| ips: list[str] | None = None, | ||
| cfg: GlobalConfig = global_config, | ||
| *args: object, | ||
| **kwargs: object, | ||
| ) -> None: | ||
| if not ips: | ||
| raw = cfg.robot_ips | ||
| if not raw: | ||
| raise ValueError( | ||
| "No IPs provided. Pass ips= or set ROBOT_IPS (e.g. ROBOT_IPS=10.0.0.102,10.0.0.209)" | ||
| ) | ||
| ips = [ip.strip() for ip in raw.split(",") if ip.strip()] | ||
| self._extra_ips = ips[1:] | ||
| self._extra_connections: list[Go2ConnectionProtocol] = [] | ||
| super().__init__(ips[0], cfg, *args, **kwargs) | ||
|
|
||
| @rpc | ||
| def start(self) -> None: | ||
| self._extra_connections.clear() | ||
| for ip in self._extra_ips: | ||
| conn = make_connection(ip, self._global_config) | ||
| conn.start() | ||
| self._extra_connections.append(conn) | ||
|
|
||
| # Parent starts primary robot, subscribes sensors, calls standup() on all | ||
| super().start() | ||
| for conn in self._extra_connections: | ||
| conn.balance_stand() | ||
| conn.set_obstacle_avoidance(self._global_config.obstacle_avoidance) | ||
|
|
||
| @rpc | ||
| def stop(self) -> None: | ||
| # one robot's error should not prevent others from stopping | ||
| for conn in self._extra_connections: | ||
| try: | ||
| conn.liedown() | ||
| except Exception as e: | ||
| logger.error(f"Error lying down fleet Go2: {e}") | ||
| try: | ||
| conn.stop() | ||
| except Exception as e: | ||
| logger.error(f"Error stopping fleet Go2: {e}") | ||
| self._extra_connections.clear() | ||
| super().stop() | ||
ruthwikdasyam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @property | ||
| def _all_connections(self) -> list[Go2ConnectionProtocol]: | ||
| return [self.connection, *self._extra_connections] | ||
|
|
||
| @rpc | ||
| def move(self, twist: Twist, duration: float = 0.0) -> bool: | ||
| results: list[bool] = [] | ||
| for conn in self._all_connections: | ||
| try: | ||
| results.append(conn.move(twist, duration)) | ||
| except Exception as e: | ||
| logger.error(f"Fleet move failed: {e}") | ||
| results.append(False) | ||
| return all(results) | ||
|
|
||
| @rpc | ||
| def standup(self) -> bool: | ||
| results: list[bool] = [] | ||
| for conn in self._all_connections: | ||
| try: | ||
| results.append(conn.standup()) | ||
| except Exception as e: | ||
| logger.error(f"Fleet standup failed: {e}") | ||
| results.append(False) | ||
| return all(results) | ||
|
|
||
| @rpc | ||
| def liedown(self) -> bool: | ||
| results: list[bool] = [] | ||
| for conn in self._all_connections: | ||
| try: | ||
| results.append(conn.liedown()) | ||
| except Exception as e: | ||
| logger.error(f"Fleet liedown failed: {e}") | ||
| results.append(False) | ||
| return all(results) | ||
|
|
||
| @rpc | ||
| def publish_request(self, topic: str, data: dict[str, Any]) -> dict[Any, Any]: | ||
| """Publish a request to all robots, return primary's response.""" | ||
| for conn in self._extra_connections: | ||
| try: | ||
| conn.publish_request(topic, data) | ||
| except Exception as e: | ||
| logger.error(f"Fleet publish_request failed: {e}") | ||
| return self.connection.publish_request(topic, data) | ||
ruthwikdasyam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| go2_fleet_connection = Go2FleetConnection.blueprint | ||
|
|
||
|
|
||
| __all__ = ["Go2FleetConnection", "go2_fleet_connection"] | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.