-
Notifications
You must be signed in to change notification settings - Fork 280
Add utility classes for go2 operations: free avoid, stand up, stand d… #239
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
Conversation
…own, move, stop move Add utility classes for go2 operations: free avoid, stand up, stand down, move, stop move
WalkthroughThis pull request introduces five new modules that each add a tool class for controlling the Unitree Go2 robot. Each tool (i.e., FreeAvoid, Move, StandDown, StandUp, and StopMove) is implemented as a subclass of a base tool and features its own argument schema, network interface validation, and error handling. The changes also initialize necessary clients (such as the SportClient, and in one case, the ChannelFactory) and implement the core control flow for executing robot commands safely. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant T as Tool (FreeAvoid/Move/etc.)
participant S as SportClient
participant L as Logger
U->>T: Invoke tool with parameters
T->>T: Validate network_interface_name
T->>S: Initialize client & send command (_run)
alt Command successful
S-->>T: Return success response
T-->>U: Deliver success message
else Command fails
S-->>T: Raise exception
T->>L: Log error details
T-->>U: Return failure message
end
Poem
Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py (1)
1-71
: 🛠️ Refactor suggestionConsider refactoring common code across Go2 tool classes
There is significant duplication across all the Go2 tool classes (StandUp, StandDown, Move, StopMove). Consider creating a base class for Go2 tools that handles common functionality like:
- Import management
- Network interface validation
- SportClient initialization
- Error handling and response formatting
A potential design could be:
# Create a base class for Go2 tools class BaseGo2Tool(BaseTool): """Base class for Unitree Go2 robot tools.""" class Config: """Configuration for this pydantic object.""" extra = "allow" arbitrary_types_allowed = True network_interface_name: Optional[str] def __init__(self, **data: Any) -> None: super().__init__(**data) ChannelFactoryInitialize(0, self.network_interface_name) self.sport_client = SportClient() self.sport_client.SetTimeout(10.0) self.sport_client.Init() @field_validator("network_interface_name") @classmethod def network_interface_name_validator(cls, network_interface_name: Union[str, None]) -> Union[str, None]: if network_interface_name is None: raise ValueError("network interface name is not provided.") return network_interface_name def execute_command(self, command_fn, error_msg): """Execute a command with standard error handling.""" try: command_fn() return { "code": 0, "msg": "success", } except Exception as e: logging.error(f"{error_msg}: {e}") return { "code": 500, "msg": "failed", }Then each specific tool could be simplified:
@registry.register_tool() class StopMove(BaseGo2Tool): """Tool for making Unitree Go2 robot stop move.""" args_schema: ArgSchema = ArgSchema(**ARGSCHEMA) description: str = "Control the Unitree Go2 robot to stop move." def _run(self) -> Dict[str, Any]: """Control the Go2 to stop move.""" return self.execute_command( lambda: self.sport_client.StopMove(), "Stop move failed" )🧰 Tools
🪛 Ruff (0.8.2)
5-5:
unitree_sdk2py.core.channel.ChannelSubscriber
imported but unusedRemove unused import:
unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10:
unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unusedRemove unused import
(F401)
11-11:
unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unusedRemove unused import
(F401)
48-48: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
🧹 Nitpick comments (17)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py (4)
5-12
: Clean up unused importsSeveral imports are not being used in this file:
ChannelSubscriber
(line 5)unitree_go_msg_dds__SportModeState_
(line 6)SportModeState_
(line 7)PathPoint
(line 10)SPORT_PATH_POINT_SIZE
(line 11)-from unitree_sdk2py.core.channel import ChannelSubscriber, ChannelFactoryInitialize +from unitree_sdk2py.core.channel import ChannelFactoryInitialize -from unitree_sdk2py.idl.default import unitree_go_msg_dds__SportModeState_ -from unitree_sdk2py.idl.unitree_go.msg.dds_ import SportModeState_ from unitree_sdk2py.go2.sport.sport_client import ( SportClient, - PathPoint, - SPORT_PATH_POINT_SIZE, )🧰 Tools
🪛 Ruff (0.8.2)
5-5:
unitree_sdk2py.core.channel.ChannelSubscriber
imported but unusedRemove unused import:
unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10:
unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unusedRemove unused import
(F401)
11-11:
unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unusedRemove unused import
(F401)
18-18
: Remove unused variableThe variable
CURRENT_PATH
is defined but never used in this file.-CURRENT_PATH = Path(__file__).parents[0]
48-50
: Useis None
for identity comparisonWhen checking for
None
, useis None
instead of== None
for proper identity comparison.- if network_interface_name == None: + if network_interface_name is None: raise ValueError("network interface name is not provided.")🧰 Tools
🪛 Ruff (0.8.2)
48-48: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
59-70
: Consider using constant error codesThe success and error codes (0 and 500) are hardcoded. Consider defining these as constants to improve maintainability.
+SUCCESS_CODE = 0 +ERROR_CODE = 500 + def _run( self ) -> Dict[str, Any]: """ Control the Go2 to stand down. """ try: self.sport_client.StandDown() return { - "code": 0, + "code": SUCCESS_CODE, "msg": "success", } except Exception as e: logging.error(f"Stand down failed: {e}") return { - "code": 500, + "code": ERROR_CODE, "msg": "failed", }omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py (3)
5-12
: Clean up unused importsSeveral imports are not being used in this file:
ChannelSubscriber
(line 5)unitree_go_msg_dds__SportModeState_
(line 6)SportModeState_
(line 7)PathPoint
(line 10)SPORT_PATH_POINT_SIZE
(line 11)-from unitree_sdk2py.core.channel import ChannelSubscriber, ChannelFactoryInitialize +from unitree_sdk2py.core.channel import ChannelFactoryInitialize -from unitree_sdk2py.idl.default import unitree_go_msg_dds__SportModeState_ -from unitree_sdk2py.idl.unitree_go.msg.dds_ import SportModeState_ from unitree_sdk2py.go2.sport.sport_client import ( SportClient, - PathPoint, - SPORT_PATH_POINT_SIZE, )🧰 Tools
🪛 Ruff (0.8.2)
5-5:
unitree_sdk2py.core.channel.ChannelSubscriber
imported but unusedRemove unused import:
unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10:
unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unusedRemove unused import
(F401)
11-11:
unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unusedRemove unused import
(F401)
18-18
: Remove unused variableThe variable
CURRENT_PATH
is defined but never used in this file.-CURRENT_PATH = Path(__file__).parents[0]
48-50
: Useis None
for identity comparisonWhen checking for
None
, useis None
instead of== None
for proper identity comparison.- if network_interface_name == None: + if network_interface_name is None: raise ValueError("network interface name is not provided.")🧰 Tools
🪛 Ruff (0.8.2)
48-48: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py (4)
5-12
: Clean up unused importsSeveral imports are not being used in this file:
ChannelSubscriber
(line 5)unitree_go_msg_dds__SportModeState_
(line 6)SportModeState_
(line 7)PathPoint
(line 10)SPORT_PATH_POINT_SIZE
(line 11)-from unitree_sdk2py.core.channel import ChannelSubscriber, ChannelFactoryInitialize +from unitree_sdk2py.core.channel import ChannelFactoryInitialize -from unitree_sdk2py.idl.default import unitree_go_msg_dds__SportModeState_ -from unitree_sdk2py.idl.unitree_go.msg.dds_ import SportModeState_ from unitree_sdk2py.go2.sport.sport_client import ( SportClient, - PathPoint, - SPORT_PATH_POINT_SIZE, )🧰 Tools
🪛 Ruff (0.8.2)
5-5:
unitree_sdk2py.core.channel.ChannelSubscriber
imported but unusedRemove unused import:
unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10:
unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unusedRemove unused import
(F401)
11-11:
unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unusedRemove unused import
(F401)
18-18
: Remove unused variableThe variable
CURRENT_PATH
is defined but never used in this file.-CURRENT_PATH = Path(__file__).parents[0]
63-65
: Useis None
for identity comparisonWhen checking for
None
, useis None
instead of== None
for proper identity comparison.- if network_interface_name == None: + if network_interface_name is None: raise ValueError("network interface name is not provided.")🧰 Tools
🪛 Ruff (0.8.2)
63-63: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
78-79
: Remove or document commented codeThere's a commented line that references
BalanceStand()
. Either remove this line if it's not needed or add a comment explaining why it's commented out.- # self.sport_client.BalanceStand() self.sport_client.Move(vx, vy, vyaw)
Or if it's there for a specific reason:
- # self.sport_client.BalanceStand() + # Note: BalanceStand() call is disabled because [reason] self.sport_client.Move(vx, vy, vyaw)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py (3)
5-12
: Clean up unused importsSeveral imports are not being used in this file:
ChannelSubscriber
(line 5)unitree_go_msg_dds__SportModeState_
(line 6)SportModeState_
(line 7)PathPoint
(line 10)SPORT_PATH_POINT_SIZE
(line 11)-from unitree_sdk2py.core.channel import ChannelSubscriber, ChannelFactoryInitialize +from unitree_sdk2py.core.channel import ChannelFactoryInitialize -from unitree_sdk2py.idl.default import unitree_go_msg_dds__SportModeState_ -from unitree_sdk2py.idl.unitree_go.msg.dds_ import SportModeState_ from unitree_sdk2py.go2.sport.sport_client import ( SportClient, - PathPoint, - SPORT_PATH_POINT_SIZE, )🧰 Tools
🪛 Ruff (0.8.2)
5-5:
unitree_sdk2py.core.channel.ChannelSubscriber
imported but unusedRemove unused import:
unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10:
unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unusedRemove unused import
(F401)
11-11:
unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unusedRemove unused import
(F401)
18-18
: Remove unused variableThe variable
CURRENT_PATH
is defined but never used in this file.-CURRENT_PATH = Path(__file__).parents[0]
48-50
: Useis None
for identity comparisonWhen checking for
None
, useis None
instead of== None
for proper identity comparison.- if network_interface_name == None: + if network_interface_name is None: raise ValueError("network interface name is not provided.")🧰 Tools
🪛 Ruff (0.8.2)
48-48: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py (3)
1-12
: Remove unused imports to improve code maintainabilitySeveral imports are not used in this file and should be removed:
ChannelSubscriber
(line 5)unitree_go_msg_dds__SportModeState_
(line 6)SportModeState_
(line 7)PathPoint
(line 10)SPORT_PATH_POINT_SIZE
(line 11)from pathlib import Path from typing import Any, Dict, Optional, Union from pydantic import field_validator -from unitree_sdk2py.core.channel import ChannelSubscriber, ChannelFactoryInitialize -from unitree_sdk2py.idl.default import unitree_go_msg_dds__SportModeState_ -from unitree_sdk2py.idl.unitree_go.msg.dds_ import SportModeState_ -from unitree_sdk2py.go2.sport.sport_client import ( - SportClient, - PathPoint, - SPORT_PATH_POINT_SIZE, -) +from unitree_sdk2py.core.channel import ChannelFactoryInitialize +from unitree_sdk2py.go2.sport.sport_client import SportClient🧰 Tools
🪛 Ruff (0.8.2)
5-5:
unitree_sdk2py.core.channel.ChannelSubscriber
imported but unusedRemove unused import:
unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unusedRemove unused import:
unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10:
unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unusedRemove unused import
(F401)
11-11:
unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unusedRemove unused import
(F401)
18-18
: Remove unused variableThe
CURRENT_PATH
variable is defined but not used anywhere in this file.-CURRENT_PATH = Path(__file__).parents[0]
52-55
: Useis None
instead of== None
for None comparisonPython best practices recommend using
is None
instead of== None
for None comparisons.@field_validator("network_interface_name") @classmethod def network_interface_name_validator(cls, network_interface_name: Union[str, None]) -> Union[str, None]: - if network_interface_name == None: + if network_interface_name is None: raise ValueError("network interface name is not provided.") return network_interface_name🧰 Tools
🪛 Ruff (0.8.2)
53-53: Comparison to
None
should becond is None
Replace with
cond is None
(E711)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py
(1 hunks)omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py
(1 hunks)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py
(1 hunks)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py
(1 hunks)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py
(1 hunks)
🧰 Additional context used
🧬 Code Definitions (4)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py (4)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py (3) (3)
Config
(33:37)network_interface_name_validator
(52:55)_run
(57:76)omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py (3) (3)
Config
(43:47)network_interface_name_validator
(62:65)_run
(67:89)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py (4)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py (3) (3)
Config
(33:37)network_interface_name_validator
(52:55)_run
(57:76)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py (4)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py (3) (3)
Config
(33:37)network_interface_name_validator
(52:55)_run
(57:76)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py (3) (3)
Config
(43:47)network_interface_name_validator
(62:65)_run
(67:89)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py (4)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py (3) (3)
Config
(43:47)network_interface_name_validator
(62:65)_run
(67:89)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py (3) (3)
Config
(28:32)network_interface_name_validator
(47:50)_run
(52:70)
🪛 Ruff (0.8.2)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py
5-5: unitree_sdk2py.core.channel.ChannelSubscriber
imported but unused
Remove unused import: unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10: unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unused
Remove unused import
(F401)
11-11: unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unused
Remove unused import
(F401)
48-48: Comparison to None
should be cond is None
Replace with cond is None
(E711)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py
5-5: unitree_sdk2py.core.channel.ChannelSubscriber
imported but unused
Remove unused import: unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10: unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unused
Remove unused import
(F401)
11-11: unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unused
Remove unused import
(F401)
63-63: Comparison to None
should be cond is None
Replace with cond is None
(E711)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py
5-5: unitree_sdk2py.core.channel.ChannelSubscriber
imported but unused
Remove unused import: unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10: unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unused
Remove unused import
(F401)
11-11: unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unused
Remove unused import
(F401)
48-48: Comparison to None
should be cond is None
Replace with cond is None
(E711)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py
5-5: unitree_sdk2py.core.channel.ChannelSubscriber
imported but unused
Remove unused import: unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10: unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unused
Remove unused import
(F401)
11-11: unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unused
Remove unused import
(F401)
48-48: Comparison to None
should be cond is None
Replace with cond is None
(E711)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py
5-5: unitree_sdk2py.core.channel.ChannelSubscriber
imported but unused
Remove unused import: unitree_sdk2py.core.channel.ChannelSubscriber
(F401)
6-6: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.default.unitree_go_msg_dds__SportModeState_
(F401)
7-7: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
imported but unused
Remove unused import: unitree_sdk2py.idl.unitree_go.msg.dds_.SportModeState_
(F401)
10-10: unitree_sdk2py.go2.sport.sport_client.PathPoint
imported but unused
Remove unused import
(F401)
11-11: unitree_sdk2py.go2.sport.sport_client.SPORT_PATH_POINT_SIZE
imported but unused
Remove unused import
(F401)
53-53: Comparison to None
should be cond is None
Replace with cond is None
(E711)
🔇 Additional comments (5)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py (1)
38-44
: Consider resource management for SportClient initializationThe current implementation initializes
ChannelFactoryInitialize
in the constructor. If multiple instances of this tool are created, it might cause initialization issues. Consider if there's a need for a resource management pattern here.Are there any side effects or restrictions with multiple calls to
ChannelFactoryInitialize
with different network interfaces? Does the Go2 SDK documentation provide any guidance on proper initialization patterns?omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py (4)
20-26
: Well-defined argument schemaThe argument schema is properly defined with appropriate type, description, and required flag for the "switch" parameter.
33-37
: Config class maintains consistency with other tool implementationsThe Config class allows for arbitrary types and extra fields, which is consistent with the implementation of other Go2 tools, promoting code uniformity across the codebase.
43-48
: Proper initialization of required componentsThe initialization method correctly sets up the required components for interacting with the Go2 robot:
- It initializes the channel factory with the provided network interface
- It creates and initializes the SportClient with an appropriate timeout
57-76
: Robust error handling in the_run
methodThe method properly implements the free avoid functionality with robust error handling:
- It handles exceptions appropriately
- It returns a structured response with code and message
- The error logging includes useful diagnostic information
- The implementation follows the pattern established in other Go2 tools
Docstrings generation was requested by @panregedit. * #239 (comment) The following files were modified: * `omagent-core/src/omagent_core/tool_system/tools/ut_dog/free_avoid.py` * `omagent-core/src/omagent_core/tool_system/tools/ut_dog/move.py` * `omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py` * `omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_up.py` * `omagent-core/src/omagent_core/tool_system/tools/ut_dog/stop_move.py`
Note Generated docstrings for this pull request at #241 |
…own, move, stop move
Add utility classes for go2 operations: free avoid, stand up, stand down, move, stop move
Summary by CodeRabbit