-
Notifications
You must be signed in to change notification settings - Fork 4
Add unit test to creo2urdf #151
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: master
Are you sure you want to change the base?
Conversation
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.
Summary of Changes
Hello @Nicogene, 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 new unit testing framework for creo2urdf generated models, specifically targeting URDF consistency and correctness. It aims to improve the quality and reliability of exported robot models by validating key kinematic and sensor properties, addressing issue #141.
Highlights
- New Model Validation Test: A new C++ executable (
creo2urdf-model-test) has been added to perform comprehensive validation of URDF models, checking aspects like joint axis directions, base link configuration, sole frame placement, and force/torque sensor properties. - CMake Integration for Testing: The build system has been updated to enable testing via CTest when the
BUILD_TESTINGoption is enabled, and a newtestssubdirectory has been introduced to house the test suite. - Detailed URDF Property Checks: The new test includes specific checks for various robot model characteristics, such as the expected directions of numerous joint axes (e.g., torso, hip, shoulder, finger joints), the identity transform of the
base_linkrelative toroot_link, the parallel and symmetric placement ofl_soleandr_soleframes, and the correct orientation and coherence of force/torque sensors.
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.
Footnotes
-
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. ↩
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 a unit test for creo2urdf, which is a valuable addition for ensuring model quality. The changes correctly set up the testing infrastructure with CMake and provide a comprehensive test suite for the URDF models.
My review focuses on improving the new test code. I've identified a few critical correctness issues due to copy-paste errors, as well as several opportunities to enhance maintainability, readability, and efficiency. Addressing these points will make the new test suite more robust and easier to extend in the future.
| if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX) | ||
| { | ||
| std::cerr << "ergocub-model-test error: impossible to find base_link in model" << std::endl; | ||
| 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.
There's a copy-paste error in this conditional. You're checking rootLinkIdx for validity, but the error message refers to base_link. You should be checking base_linkIdx.
| if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX) | |
| { | |
| std::cerr << "ergocub-model-test error: impossible to find base_link in model" << std::endl; | |
| return false; | |
| if (base_linkIdx == iDynTree::FRAME_INVALID_INDEX) | |
| { | |
| std::cerr << "ergocub-model-test error: impossible to find base_link in model" << std::endl; | |
| return false; | |
| } |
tests/creo2urdf-model-test.cpp
Outdated
| if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX) | ||
| { | ||
| std::cerr << "ergocub-model-test error: impossible to find frame l_sole in model" << std::endl; | ||
| 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.
There's a copy-paste error in this conditional. You're checking rootLinkIdx for validity, but you probably meant to check l_sole.
| if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX) | |
| { | |
| std::cerr << "ergocub-model-test error: impossible to find frame l_sole in model" << std::endl; | |
| return false; | |
| if (l_sole == iDynTree::FRAME_INVALID_INDEX) | |
| { | |
| std::cerr << "ergocub-model-test error: impossible to find frame l_sole in model" << std::endl; | |
| return false; | |
| } |
tests/creo2urdf-model-test.cpp
Outdated
| if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX) | ||
| { | ||
| std::cerr << "ergocub-model-test error: impossible to find frame r_sole in model" << std::endl; | ||
| 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.
Similar to the check for l_sole, there's a copy-paste error here. You're checking rootLinkIdx for validity, but you should be checking r_sole.
| if (rootLinkIdx == iDynTree::FRAME_INVALID_INDEX) | |
| { | |
| std::cerr << "ergocub-model-test error: impossible to find frame r_sole in model" << std::endl; | |
| return false; | |
| if (r_sole == iDynTree::FRAME_INVALID_INDEX) | |
| { | |
| std::cerr << "ergocub-model-test error: impossible to find frame r_sole in model" << std::endl; | |
| return false; | |
| } |
| /** | ||
| * All the iCub have a odd and not null number of F/T sensors. | ||
| */ | ||
| bool checkFTSensorsAreOddAndNotNull(iDynTree::ModelLoader& mdlLoader) |
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.
| } | ||
|
|
||
|
|
||
| bool Model_isFrameNameUsed(const iDynTree::Model& model, const std::string frameName) |
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.
|
|
||
|
|
||
|
|
||
| const std::string modelPath = __argc > 1 ? __argv[1] : "model.urdf"; |
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 use of __argc and __argv is a Microsoft-specific extension. For better portability, it's recommended to use the standard argc and argv which are passed as arguments to main.
| const std::string modelPath = __argc > 1 ? __argv[1] : "model.urdf"; | |
| const std::string modelPath = argc > 1 ? argv[1] : "model.urdf"; |
It fixes #141