Skip to content

Conversation

@GyuH13
Copy link
Member

@GyuH13 GyuH13 commented Nov 17, 2025

Easy SDK Python is updated.

File added

connector.py:
The connector class handles communication and acts as a factory that creates Motor and GroupExecutor objects.

control_table.py:
The control table class is responsible for parsing the control table file.

data_types.py:
This module includes all data type classes such as enums and data classes.

dynamixel_error.py:
Defines custom exception types for Dynamixel (DXL).

group_executor.py:
It manages sync and bulk commands and executes them.

motor.py:
The Motor class represents a Dynamixel actuator and maps directly to a physical DXL device.

Feature

  1. The control table file is now included in the package so that it is installed in the user’s environment when the package is distributed via PyPI (installed through pip).

  2. All errors are now handled through Python-style exception handling for a more pythonic design.

CPP improvement

  1. Added and applied internal functions writeData and readData
  • Simplified code structure
  • Enable to support for 1-byte and 2-byte based models
  1. Added data_types.hpp and removed stagedcommand.hpp
  • Consolidated all data types into a single header
  1. Renamed error enum
    EASY_SDK_MOTOR_TORQUE_OFFEASY_SDK_TORQUE_STATUS_MISMATCH

  2. Updated group control logic to raise errors based on status conditions

  • Added functions to read Current and PWM values
  1. Changed the return type of getOperatingMode:
    uint8_t → OperatingMode enum value

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @GyuH13, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces significant updates and improvements to both the Python and C++ Easy SDKs for Dynamixel motors. The Python SDK has been completely refactored into a more modular and Pythonic design, including native exception handling and better management of control table data. Concurrently, the C++ SDK has undergone refactoring to streamline data read/write operations, consolidate data type definitions, and enhance error handling and status checking within group commands, ultimately providing a more robust and user-friendly experience across both platforms.

Highlights

  • Python Easy SDK Overhaul: The Python Easy SDK has been completely rewritten and modularized, introducing new classes like connector.py, control_table.py, data_types.py, dynamixel_error.py, group_executor.py, and motor.py to improve structure and maintainability.
  • Pythonic Error Handling: Errors in the Python SDK are now handled using Python-style exception handling, providing a more idiomatic and robust way to manage issues.
  • Control Table Integration (Python): Control table definition files (.model) are now included directly within the Python package, ensuring they are available when the package is distributed via PyPI.
  • C++ SDK Refactoring for Data Access: Internal writeData and readData functions have been added and applied across the C++ SDK, simplifying the code structure and enabling support for 1-byte and 2-byte based models more consistently.
  • C++ Data Type Consolidation: The C++ SDK now uses a single data_types.hpp header to consolidate all data type definitions, replacing the previous staged_command.hpp and removing redundant definitions.
  • Enhanced C++ Error Enumeration: A C++ error enum has been renamed from EASY_SDK_MOTOR_TORQUE_OFF to EASY_SDK_TORQUE_STATUS_MISMATCH for clearer semantics.
  • Improved C++ Group Control Logic: The group control logic in the C++ SDK has been updated to raise more specific errors based on motor status conditions, and new functions to read Current and PWM values have been added.
  • C++ Operating Mode Return Type: The getOperatingMode function in the C++ SDK now returns an OperatingMode enum value instead of a raw uint8_t, improving type safety and readability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copilot finished reviewing on behalf of GyuH13 November 17, 2025 04:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a complete Python Easy SDK implementation and improves the C++ Easy SDK with cleaner abstractions and better error handling.

Key Changes:

  • Complete Python Easy SDK with Motor, Connector, and GroupExecutor classes
  • Control table files packaged for PyPI distribution
  • Pythonic exception-based error handling
  • C++ refactoring with internal readData/writeData helper functions
  • Renamed error enum for clarity: EASY_SDK_MOTOR_TORQUE_OFFEASY_SDK_TORQUE_STATUS_MISMATCH
  • Added support for reading Current and PWM values

Reviewed Changes

Copilot reviewed 86 out of 86 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
python/src/dynamixel_easy_sdk/motor.py Core Motor class with read/write operations and staged command support
python/src/dynamixel_easy_sdk/group_executor.py Handles sync/bulk read/write operations with status validation
python/src/dynamixel_easy_sdk/dynamixel_error.py Exception classes and error code definitions
python/src/dynamixel_easy_sdk/data_types.py Enums and dataclasses for operating modes, commands, and requests
python/src/dynamixel_easy_sdk/control_table.py Control table parser with caching
python/src/dynamixel_easy_sdk/connector.py Factory class for creating motors and group executors
python/src/dynamixel_easy_sdk/init.py Package exports
python/pyproject.toml Package configuration for PyPI distribution
python/src/dynamixel_easy_sdk/control_table/*.model Control table definition files for various motor models
c++/src/dynamixel_easy_sdk/motor.cpp Refactored with helper functions and improved mode checking
c++/src/dynamixel_easy_sdk/group_executor.cpp Added status request processing and signed value conversion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant update with the new Easy SDK for Python and substantial improvements to the C++ Easy SDK. The Python SDK is well-structured, following modern Python practices with dataclasses, enums, and proper exception handling. The C++ SDK has been refactored to be more robust and maintainable, with the introduction of helper functions like writeData and readData that reduce code duplication significantly.

I've found a few critical issues that should be addressed. In the C++ code, there's a potential for a dangling pointer in StagedCommand which could lead to crashes, and a minor bug in error reporting. In the Python code, there's a critical issue with the package name in pyproject.toml which will cause conflicts on PyPI, and a bug in the closePort method.

Overall, these are great improvements that make the SDKs more powerful and easier to use. Addressing the identified issues will make them more robust and safer for developers.

@ola31 ola31 added the enhancement New feature or request label Nov 17, 2025
@ola31 ola31 added this to Platform Nov 17, 2025
@ola31 ola31 moved this from 🌱 Todo to 📝 Pull Request in Platform Nov 17, 2025
@github-project-automation github-project-automation bot moved this to 🌱 Todo in Platform Nov 17, 2025
Copy link
Member

@yun-goon yun-goon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this creates two same control table folders, how about combining them into one?

Comment on lines 42 to 46
if not self._port_handler.openPort():
raise DxlRuntimeError('Failed to open the port')

if not self._port_handler.setBaudRate(baud_rate):
raise DxlRuntimeError('Failed to set baud rate')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use 'DxlErrorCode' instead of transferring the string directly?

if not self._port_handler.openPort():
    raise DxlRuntimeError(DxlErrorCode.SDK_COMM_PORT_BUSY)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

02b75d5
d55edd2
Raise DxlRuntimeError(DxlErrorCode.SDK_COMM_PORT_BUSY) when the port is in use. Other errors in this part are handled using string messages, since this is the only case where the busy error occurs.

results.append(intvalue)
return results

def _processStatusRequests(self, cmd: StagedCommand, data = None) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd.motor can be 'None', so wouldn't it be better to check it?

Copy link
Member Author

@GyuH13 GyuH13 Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the beginning of the function, filtering is done based on this classification.

    if not cmd.status_request:
        return

@GyuH13 GyuH13 self-assigned this Nov 18, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we trying to manage the control table in two different places? Can't we just use the control table already provided here (https://github.com/ROBOTIS-GIT/DynamixelSDK/tree/main/control_table)?
If multiple locations handle the same control table, keeping it updated will become difficult.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered that point.
If we don't include control_table in the Python package, the control table cannot be included when distributing via PyPI.
For now, we'll manage it separately, but I'll look into a way to integrate it later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered that point.
If we don't include it in the Python package, the control table cannot be included when distributing via PyPI.
For now, we'll manage it separately, but I'll look into a way to integrate it later.


class Connector:

PROTOCOL_VERSION = 2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why PROTOCOL_VERSION is managed inside the Connector class?
Is PROTOCOL_VERSION a variable that is only used within the Connector?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. it is only used in Connector.

sorted_list.begin(),
sorted_list.end(),
[](const StagedCommand & a, const StagedCommand & b) {
return a.id < b.id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using single-letter variable names like a or b can make the code harder to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the sort function, the lambda arguments can be named either a, b or cmd1, cmd2. I think there’s not much difference between the two. Do you think using cmd1, cmd2 would be better?

sorted_list.begin(),
sorted_list.end(),
[](const StagedCommand & a, const StagedCommand & b) {
return a.id == b.id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using single-letter variable names like a or b can make the code harder to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same answer with above.

Copy link
Member

@ola31 ola31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@nhw-robotis nhw-robotis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good!

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

Labels

enhancement New feature or request

Projects

Status: 📝 Pull Request

Development

Successfully merging this pull request may close these issues.

6 participants