Skip to content

Conversation

djwu563
Copy link
Contributor

@djwu563 djwu563 commented Mar 18, 2025

…own, move, stop move

Add utility classes for go2 operations: free avoid, stand up, stand down, move, stop move

Summary by CodeRabbit

  • New Features
    • Introduced a free avoid tool to enable or disable the robot's avoidance mode.
    • Added a movement control tool for flexible directional and rotational commands.
    • Implemented stand up and stand down commands to adjust the robot's posture.
    • Integrated a stop movement tool to safely halt ongoing commands.

…own, move, stop move

Add utility classes for go2 operations: free avoid, stand up, stand down, move, stop move
Copy link

coderabbitai bot commented Mar 18, 2025

Walkthrough

This 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

Files Change Summary
omagent-core/.../ut_dog/free_avoid.py, omagent-core/.../ut_dog/move.py, omagent-core/.../ut_dog/stand_down.py, omagent-core/.../ut_dog/stand_up.py, omagent-core/.../ut_dog/stop_move.py Added new tool modules (FreeAvoid, Move, StandDown, StandUp, StopMove) for various actions of the Unitree Go2 robot. Each module defines a BaseTool subclass with specialized argument schemas, network interface name validation, client (e.g., SportClient) initialization, and robust error handling in its _run method.

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
Loading

Poem

Hop, hop, hop—a rabbit's here to say,
New tools in code make us dance and play.
FreeAvoid, Move, and more join the band,
StandUp, StandDown, StopMove at hand.
Validation checks and logs that gleam,
I celebrate these changes like a techie dream! 🐇✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Docstrings were successfully generated. (🔄 Check again to generate again)

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@djwu563 djwu563 changed the base branch from main to feature/ut_dog March 18, 2025 06:44
Copy link

@coderabbitai coderabbitai bot left a 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 suggestion

Consider 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 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)

🧹 Nitpick comments (17)
omagent-core/src/omagent_core/tool_system/tools/ut_dog/stand_down.py (4)

5-12: Clean up unused imports

Several 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 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)


18-18: Remove unused variable

The variable CURRENT_PATH is defined but never used in this file.

-CURRENT_PATH = Path(__file__).parents[0]

48-50: Use is None for identity comparison

When checking for None, use is 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 be cond is None

Replace with cond is None

(E711)


59-70: Consider using constant error codes

The 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 imports

Several 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 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)


18-18: Remove unused variable

The variable CURRENT_PATH is defined but never used in this file.

-CURRENT_PATH = Path(__file__).parents[0]

48-50: Use is None for identity comparison

When checking for None, use is 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 be cond 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 imports

Several 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 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)


18-18: Remove unused variable

The variable CURRENT_PATH is defined but never used in this file.

-CURRENT_PATH = Path(__file__).parents[0]

63-65: Use is None for identity comparison

When checking for None, use is 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 be cond is None

Replace with cond is None

(E711)


78-79: Remove or document commented code

There'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 imports

Several 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 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)


18-18: Remove unused variable

The variable CURRENT_PATH is defined but never used in this file.

-CURRENT_PATH = Path(__file__).parents[0]

48-50: Use is None for identity comparison

When checking for None, use is 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 be cond 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 maintainability

Several 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 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)


18-18: Remove unused variable

The CURRENT_PATH variable is defined but not used anywhere in this file.

-CURRENT_PATH = Path(__file__).parents[0]

52-55: Use is None instead of == None for None comparison

Python 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 be cond is None

Replace with cond is None

(E711)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c131f82 and 5869ee0.

📒 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 initialization

The 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 schema

The 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 implementations

The 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 components

The 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 method

The 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

@panregedit panregedit merged commit f1e9eb8 into om-ai-lab:feature/ut_dog Mar 18, 2025
2 checks passed
coderabbitai bot added a commit that referenced this pull request Mar 18, 2025
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`
Copy link

coderabbitai bot commented Mar 18, 2025

Note

Generated docstrings for this pull request at #241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants