Skip to content

Add API for getting hardware error status #146

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

Closed
wants to merge 12 commits into from

Conversation

jonghee-son
Copy link
Member

Added a new method, getHardwareError, in the Dynamixel2Arduino class to retrieve the hardware error status of a DYNAMIXEL actuator. This method includes logic to handle unsupported models and specific error codes.

Copy link

@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.

Hello @jonghee-son, 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!

Summary of Changes

This pull request introduces a new API method, getHardwareError, to the Dynamixel2Arduino class. This method retrieves the hardware error status of a DYNAMIXEL actuator. The implementation includes specific logic to handle unsupported DYNAMIXEL models, as well as specific error codes. Additionally, the PR renames the LED control table items to DXL_LED for clarity and consistency.

Highlights

  • New API Method: A new method, getHardwareError, has been added to the Dynamixel2Arduino class to retrieve the hardware error status from a DYNAMIXEL actuator.
  • Model Support: The getHardwareError method includes logic to handle specific DYNAMIXEL models, returning an error code if the model is not supported.
  • LED Control Table Item Renaming: The control table items related to LED control have been renamed from LED to DXL_LED for better clarity and consistency.

Changelog

Click here to see the changelog
  • src/Dynamixel2Arduino.cpp
    • Renamed LED control table items to DXL_LED when setting LED state for specific PRO models (lines 613, 614, 616, 620).
    • Added getHardwareError method to retrieve the hardware error status of a DYNAMIXEL actuator (lines 918-943).
    • The getHardwareError method handles unregistered models by attempting to set the model number (lines 923-927).
    • The getHardwareError method returns an error if the model is not supported (lines 929-932).
    • The getHardwareError method reads the ERROR_CODE control table item for specific YM models (lines 933-936).
    • The getHardwareError method reads the HARDWARE_ERROR_STATUS control table item for other models (lines 937-940).
  • src/Dynamixel2Arduino.h
    • Added declaration of the getHardwareError method (lines 391-401).
    • Removed duplicate declaration of getHardwareError method (line 445).
  • src/actuator.cpp
    • Renamed LED control table items to DXL_LED in various control table definitions (lines 36, 88, 147, 200, 478).
    • Renamed LED_RED, LED_GREEN, and LED_BLUE control table items to DXL_LED_RED, DXL_LED_GREEN, and DXL_LED_BLUE in the pro_r_control_table definition (lines 322-324).
    • Renamed LED_RED, LED_GREEN, and LED_BLUE control table items to DXL_LED_RED, DXL_LED_GREEN, and DXL_LED_BLUE in the pro_ra_pro_plus_control_table definition (lines 380-382).
  • src/actuator.h
    • Renamed LED, LED_RED, LED_GREEN, and LED_BLUE control table items to DXL_LED, DXL_LED_RED, DXL_LED_GREEN, and DXL_LED_BLUE in the ControlTableItem namespace (lines 334-337).
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


A new API,
Error status we can see,
Dynamixel sings.

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.

Copy link

@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 new method getHardwareError to the Dynamixel2Arduino class, which retrieves the hardware error status of a DYNAMIXEL actuator. The implementation includes handling for unsupported models and specific error codes. Overall, the changes seem well-structured and add valuable functionality to the library.

Summary of Findings

  • Model Number Handling: The getHardwareError function attempts to retrieve the model number if it's unregistered. Consider adding a check to prevent infinite loops if setModelNumber consistently fails.
  • Error Code Handling: The function sets a library error code for unsupported models but doesn't provide a mechanism for the user to retrieve the specific hardware error code for supported models. Consider returning the error code or providing a separate function to access it.
  • Duplicated getHardwareError declaration: The getHardwareError method is declared twice in Dynamixel2Arduino.h, which is unnecessary.

Merge Readiness

The pull request introduces a useful feature, but there are a couple of issues that should be addressed before merging. Specifically, the potential for an infinite loop in getHardwareError and the duplicated declaration of the getHardwareError method should be fixed. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issue should be addressed before merging.

Comment on lines +923 to +927
if(model_num == UNREGISTERED_MODEL){
if(setModelNumber(id, getModelNumber(id)) == true){
model_num = getModelNumberFromTable(id);
}
}

Choose a reason for hiding this comment

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

high

What happens if setModelNumber always returns false? This could lead to an infinite loop. Consider adding a counter or a boolean flag to prevent this.

Suggested change
if(model_num == UNREGISTERED_MODEL){
if(setModelNumber(id, getModelNumber(id)) == true){
model_num = getModelNumberFromTable(id);
}
}
if(model_num == UNREGISTERED_MODEL){
static uint8_t retry_count = 0;
if(setModelNumber(id, getModelNumber(id)) == true){
model_num = getModelNumberFromTable(id);
retry_count = 0; // reset the counter if successful
} else {
retry_count++;
if (retry_count > 3) {
setLastLibErrCode(D2A_LIB_ERROR_UNKNOWN_MODEL_NUMBER);
return 0; // or some other appropriate error value
}
}
}

Signed-off-by: Jonghee Son <zzongaone@gmail.com>
Signed-off-by: Jonghee Son <zzongaone@gmail.com>
Signed-off-by: Jonghee Son <zzongaone@gmail.com>
…esentation of its use

Signed-off-by: Jonghee Son <zzongaone@gmail.com>
Signed-off-by: Jonghee Son <zzongaone@gmail.com>
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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy