fix check motion done + remove warning#3321
fix check motion done + remove warning#3321valegagge wants to merge 1 commit intorobotology:masterfrom
Conversation
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update the release notes by adding a file in |
Summary of ChangesHello @valegagge, 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 addresses two main areas: reducing noisy log output and refining error handling for device interfaces. It comments out several recurring warning/error messages to declutter the console and elevates the severity of a missing iJointBrake interface to ensure critical setup issues are more prominently reported. Additionally, it captures the return status of motion done checks for improved diagnostic capabilities. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request aims to fix an issue with checkMotionDone and remove some warnings. While the changes address the symptoms, some of them involve commenting out error and warning logs, which is not ideal as it can hide underlying problems. I've suggested alternative approaches, such as handling failures gracefully in the GUI to avoid repeated calls to unavailable functions, instead of silencing logs. Additionally, there's a critical issue in partitem.cpp where the return value of checkMotionDone is not checked before using its output parameter. This could lead to incorrect state representation in the GUI. I've provided a suggestion to fix this. The change from yCWarning to yCError for a missing iJointBrake interface is a good improvement, making setup issues more visible.
| ret_motdone = m_iPos->checkMotionDone(m_slow_k, &boolval); // using k to save bandwidth | ||
| m_done[m_slow_k] = boolval; // @randaz: are you sure about set true if ret_motdone==false ? |
There was a problem hiding this comment.
The value of the output parameter boolval is only guaranteed to be valid if checkMotionDone returns a success code. The current implementation assigns boolval to m_done[m_slow_k] regardless of the return value, which can lead to an incorrect state if the call fails. The assignment should be conditional on the success of the function call. Also, the comment left for @randaz should be removed and replaced with the correct logic.
ret_motdone = m_iPos->checkMotionDone(m_slow_k, &boolval); // using k to save bandwidth
if (ret_motdone)
{
m_done[m_slow_k] = boolval;
}| auto ret = m_RPC.isJointBrakedRPC(j); | ||
| if (!ret.ret) { | ||
| yCError(REMOTECONTROLBOARD, "Unable to isJointBraked"); | ||
| //yCError(REMOTECONTROLBOARD, "Unable to isJointBraked"); |
There was a problem hiding this comment.
Commenting out error logs is generally not a good practice as it can hide underlying issues and make debugging more difficult. If this error is being triggered frequently for non-critical reasons (e.g., an optional interface not being present), consider downgrading it to yCWarning or yCDebug. Alternatively, the calling code could handle this failure more gracefully, perhaps by checking for the interface's availability once and then avoiding repeated calls.
yCError(REMOTECONTROLBOARD, "Unable to isJointBraked");| if (!ret.ret) | ||
| { | ||
| yCError(CB_RPC, "isJointBraked() failed"); | ||
| //yCError(CB_RPC, "isJointBraked() failed"); |
There was a problem hiding this comment.
Silencing error logs can make it difficult to diagnose problems. This log indicates a failure in the underlying isJointBraked() implementation. If this failure is expected in some cases (e.g., the interface is optional), it might be better to handle it by logging at a lower severity level like yCWarning or yCDebug. Simply commenting it out hides the issue entirely.
| //yCError(CB_RPC, "isJointBraked() failed"); | |
| yCError(CB_RPC, "isJointBraked() failed"); |
| if (!ret_jntbrk) | ||
| { | ||
| yWarning() << "Missing Implementation of isJointBraked()"; | ||
| // yWarning() << "Missing Implementation of isJointBraked()"; |
There was a problem hiding this comment.
Commenting out this warning hides a recurring issue. If isJointBraked() is failing because the feature is not available on some hardware, the GUI should detect this and avoid calling it repeatedly in the update loop. A better approach would be to log the warning once and then set a flag to disable future calls for that part. For example, you could add a member variable m_jointBrakeIsAvailable to PartItem, initialized to true. If isJointBraked() fails, set this flag to false and log a warning. In subsequent updates, only call isJointBraked() if the flag is true.
yWarning() << "Missing Implementation of isJointBraked()";
In this PR, I try to fix the check motion done error and remove the annoying warnings:
I also added a comment for @randaz81 in the code: I think it’s better if checkMotionDone returns false if the function fails. What do you think?
cc @martinaxgloria