-
Notifications
You must be signed in to change notification settings - Fork 211
Improved actionsplayer #3303
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
base: yarp-3.12
Are you sure you want to change the base?
Improved actionsplayer #3303
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 @randaz81, 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 a substantial architectural improvement to the Highlights
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
|
|
/gemini review |
|
/gemini review |
ab13ebf to
f7e0c39
Compare
|
/gemini review |
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.
Code Review
This pull request introduces significant improvements to the yarpActionsPlayer by refactoring its internal architecture to use PolyDriver for managing robot clients and remappers. This change enhances modularity and flexibility in configuring robot control. The configuration file format has been updated to reflect this new structure, and corresponding changes have been made in main.cpp to parse these new sections. Additionally, verbosity control has been added to the ControlThread, and the destructor logic has been improved for better resource management. New test cases have also been added to cover the updated remapping functionality.
However, during the review, several critical issues were identified in main.cpp related to the initialization and usage of PolyDriver and robotDriver instances within the loadConfiguration method. These issues involve dereferencing null pointers, which would lead to crashes at runtime. Please address these issues to ensure the stability and correctness of the new architecture.
f7e0c39 to
4d28ee7
Compare
|
/gemini review |
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.
Code Review
This pull request introduces significant improvements to the yarpActionsPlayer by refactoring the configuration to support multiple control board clients and remappers, making the player more flexible and powerful. The resource management in the destructor has also been made more robust by correctly stopping threads and clearing all allocated resources. I've added a few suggestions to improve maintainability, code clarity, and correctness.
| double m_home_position_timeout = 20.0; | ||
|
|
||
| public: | ||
| bool m_verbose = false; |
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.
| // stop the threads | ||
| if (m_wthread) | ||
| { | ||
| m_wthread->stop(); | ||
| yarp::os::Time::delay(0.100); | ||
| delete m_wthread; | ||
| m_wthread=nullptr; | ||
| } | ||
|
|
||
| if (m_bthread) | ||
| { | ||
| m_bthread->stop(); | ||
| yarp::os::Time::delay(0.100); | ||
| delete m_bthread; | ||
| m_bthread=nullptr; | ||
| } |
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.
The logic for stopping and deleting threads is duplicated for m_wthread and m_bthread. This could be extracted into a helper function to avoid repetition and improve readability. For example:
template<typename T>
void stopAndDeleteThread(T*& thread)
{
if (thread)
{
thread->stop();
yarp::os::Time::delay(0.100);
delete thread;
thread = nullptr;
}
}Then you can call stopAndDeleteThread(m_wthread); and stopAndDeleteThread(m_bthread);.
| //parse a line of the CLIENTS section | ||
| std::string client_name = bot_client_elem->get(0).toString(); | ||
| std::string remoteControlBoards = bot_client_elem->get(1).toString(); | ||
| if (m_robotClients[client_name] != nullptr) |
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.
Using m_robotClients[client_name] to check for existence has the side effect of inserting a new element if client_name is not found. While it works here because the default-constructed pointer is nullptr, it's cleaner and safer to use m_robotClients.count(client_name) > 0. This is also consistent with how you check for duplicates in m_robotRemappers and m_robotControllers later in the code.
| if (m_robotClients[client_name] != nullptr) | |
| if (m_robotClients.count(client_name) > 0) |
| if (clients_name==nullptr || clients_name->size() == 0) | ||
| { | ||
| yError() << "error in clients_name"; | ||
| return false; | ||
| } | ||
| if (axes_names.empty()) | ||
| { | ||
| yError() << "error in axes_names"; | ||
| return false; | ||
| } |
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.
The error messages error in clients_name and error in axes_names are not very descriptive. It would be more helpful for debugging to provide more context, such as the name of the remapper being processed. For example:
yError() << "Invalid 'clients_name' for remapper '" << remapper_name << "': it is null or empty.";yError() << "Invalid 'axes_names' for remapper '" << remapper_name << "': it is empty.";
No description provided.